Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Flex + bison + Qt
Forum Updated to NodeBB v4.3 + New Features

Flex + bison + Qt

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 2 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    I'm trying to generate a code for parsing a language in my Qt plain C++ project. Lexer and Parser code are working properly. I tried them separately (not in a qt project):
    @
    bison -d -o parser.cpp ./parser.y
    flex -o lexer.cpp ./lexer.l
    g++ -o ./test ./main.cpp ./lexer.cpp ./parser.cpp ./parser.hpp -lfl -m
    @
    Trying to add flex and bison commands to .pro by QMAKE_EXTRA_COMPILERS I'm getting 37 errors.
    @
    TEMPLATE = app
    CONFIG += console
    CONFIG -= qt

    SOURCES += main.cpp
    LIBS += -lfl

    OTHER_FILES +=
    parser.y
    lexer.l

    FLEXSOURCES = lexer.l
    BISONSOURCES = parser.y

    bison.commands = bison -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
    bison.input = BISONSOURCES
    bison.output = parser.cpp
    bison.variable_out = SOURCES
    bison.name = bisonsource ${QMAKE_FILE_IN}
    QMAKE_EXTRA_COMPILERS += bison

    bisonheader.commands = @true
    bisonheader.input = BISONSOURCES
    bisonheader.output = parser.hpp
    bisonheader.variable_out = HEADERS
    bisonheader.name = bisonheader ${QMAKE_FILE_IN}
    bisonheader.depends = parser.cpp
    QMAKE_EXTRA_COMPILERS += bisonheader

    flex.commands = flex -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
    flex.input = FLEXSOURCES
    flex.output = lexer.cpp
    flex.variable_out = SOURCES
    flex.depends = parser.hpp
    flex.name = flex ${QMAKE_FILE_IN}
    QMAKE_EXTRA_COMPILERS += flex
    @

    errors:
    @
    lexer.cpp: In function 'int yylex()':
    lexer.cpp:562:9: error: 'yy_init' was not declared in this scope
    lexer.cpp:570:11: error: 'yy_start' was not declared in this scope
    .... // and a lot of undeclared errors...
    @

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pritamghanghas
      wrote on last edited by
      #2

      have look at qjson project, it uses bison and works for me.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved