Connecting Tech Pros Worldwide Forums | Help | Site Map

Building a parser

vpawizard's Avatar
Member
 
Join Date: Nov 2006
Posts: 66
#1: Nov 13 '06
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's Avatar
Member
 
Join Date: Nov 2006
Posts: 66
#2: Nov 16 '06

re: Building a parser


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.
Reply