Results 1 to 6 of 6

Thread: Flex, Bison and qmake

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Location
    kingston.on.ca
    Posts
    17
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flex, Bison and qmake

    I had a feeling it'll be something like that...

    I've tried poking around a bit with it, but couldn't get it to work, It would appear in the makefile, but not under the "all" target...

    I'll try it some more tomorrow, as I am not currently at work now If there's any other documentation on that feature it would be great to know.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Flex, Bison and qmake

    Try something like this (not tested):
    Qt Code:
    1. FLEXINPUTS = parser.l
    2. flex_c.output = lex.yy.c
    3. flex_c.input = FLEXINPUTS # it has to be done using a variable
    4. flex_c.commands = flex parser.l
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Location
    kingston.on.ca
    Posts
    17
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flex, Bison and qmake

    for some reason, that wasn't working too well yesterday when I tried poking at it, but works now...

    For the interested, my full qmake project file, at least for this testing app is as follows

    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.00a) Thu Sep 7 15:54:07 2006
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET +=
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. HEADERS += parse.h parser.y.h parseTest.h
    12. #LEXSOURCES += parser.l
    13. #YACCSOURCES += parser.y
    14. SOURCES += main.cpp parseTest.cpp
    15.  
    16. # Flex/bison specifics
    17.  
    18. #QMAKE_LEX = flex
    19. #QMAKE_YACC = bison
    20.  
    21. #QMAKE_YACCFLAGS = -d -o y.tab.c
    22. #QMAKE_YACC_HEADER =
    23. #QMAKE_YACC_SOURCE =
    24.  
    25. FLEXSOURCES = parser.l
    26. BISONSOURCES = parser.y
    27.  
    28. flex.commands = flex ${QMAKE_FILE_IN}
    29. flex.input = FLEXSOURCES
    30. flex.output = lex.yy.c
    31. flex.variable_out = SOURCES
    32. flex.depends = y.tab.h
    33. flex.name = flex
    34. QMAKE_EXTRA_COMPILERS += flex
    35.  
    36. bison.commands = bison -d -t -y ${QMAKE_FILE_IN} && mv y.tab.c y.tab.cpp
    37. bison.input = BISONSOURCES
    38. bison.output = y.tab.cpp
    39. bison.variable_out = SOURCES
    40. bison.name = bison
    41. QMAKE_EXTRA_COMPILERS += bison
    42.  
    43. bisonheader.commands = @true
    44. bisonheader.input = BISONSOURCES
    45. bisonheader.output = y.tab.h
    46. bisonheader.variable_out = HEADERS
    47. bisonheader.name = bison header
    48. bisonheader.depends = y.tab.cpp
    49. QMAKE_EXTRA_COMPILERS += bisonheader
    To copy to clipboard, switch view to plain text mode 

    I'll have to add windows and linux-specific definitions for the move command in the bison.commands, but apart from that it works fairly nicely.

    Still I'm not sure why it wasn't working yesterday..but's that's not important.

  4. #4
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flex, Bison and qmake

    Hi all,
    I know it is a very old thread but I used it to implement my bison/flex parser with Qt, at least I tried.

    I wrote a .pro file:

    Qt Code:
    1. # Flex/bison specifics
    2. FLEXSOURCES = VHDLParser.l
    3. BISONSOURCES = VHDLParser.y
    4.  
    5. #flex definition
    6. flex.name = Flex
    7. flex.input = FLEXSOURCES
    8. flex.output = ${QMAKE_FILE_BASE}.cpp
    9. flex.commands = flex -i -o${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
    10. #flex.CONFIG += target_predeps
    11. flex.variable_out = SOURCES
    12. QMAKE_EXTRA_COMPILERS += flex
    13.  
    14. #bison definition
    15. bison.name = Bison
    16. bison.input = BISONSOURCES
    17. bison.output = ${QMAKE_FILE_BASE}.cpp
    18. bison.commands = bison -d -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
    19. bison.clean = position.hh stack.hh location.hh VHDLParser.hpp
    20. bison.CONFIG += target_predeps
    21. bison.variable_out = SOURCES
    22. QMAKE_EXTRA_COMPILERS += bison
    23.  
    24. OTHER_FILES += \
    25. $$BISONSOURCES \
    26. $$FLEXSOURCES
    To copy to clipboard, switch view to plain text mode 

    But when I build my project, the flex compiler simply doesn't start. I can clearly see bison running in the console but not flex.
    Of course, when comes the time to link every object files, it doesn't work beceause yylex() is missing ...

    Please tell me what's wrong with this .pro.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.