Building a parser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vpawizard
    New Member
    • Nov 2006
    • 66

    #1

    Building a parser

    Hello,
    I am developing a small compiler which recognizes expression like 10+20,10-1*30 and so on. I am using Lex for generating Lexer and Yacc for parser. I created a header file defining the integer values for tokens and this header was included in both lexer and parser. Actually, I assigned some wrong values to tokens and parser did not work. Then I corrected the values and parser worked correctly. I want to know if there is any technique by which I can use both lex and yacc to build a compiler and "avoid assigning values" to tokens. i.e. I want some way so that the lexer sends the token back to parser and parser recognizes its correct type.

    Thanx in advance.
  • vpawizard
    New Member
    • Nov 2006
    • 66

    #2
    I got the solution after some googling....... .......

    bison -d xyz.y creates xyz.tab.h which automatically assigns integer values to kens which can be used by Lexer.

    Comment

    Working...