LEX and symbol table

twallace@mason1.gmu.edu (Todd A Wallace)
Tue, 25 Oct 1994 15:04:43 GMT

          From comp.compilers

Related articles
LEX and symbol table twallace@mason1.gmu.edu (1994-10-25)
Re: LEX and symbol table vern@daffy.ee.lbl.gov (1994-11-01)
| List of all articles for this month |
Newsgroups: comp.compilers
From: twallace@mason1.gmu.edu (Todd A Wallace)
Keywords: lex, question, comment
Organization: George Mason University, Fairfax, Virginia, USA
Date: Tue, 25 Oct 1994 15:04:43 GMT

Newbie question:


I am working on a lexer for a simple compiler, and I have run up against
a problem that I don't know have to solve.


How do I know when the lexer is over- or under- specific? For instance,
should I group +,-,/,* into one group, or should I test for them
explicitly, like:


"+" {do something}
"-" {do something}
"/" {do something}
"*" {do something}


And do some things get put into the symbol table while others don't?


Thanks for any help or hints,
Todd Wallace
[It doesn't much matter whether you do your single character operators
as separarate rules or not. I'm more inclined to do this:


[+-=()*^!\[\],?/] { return yytext[0]; }


Re symbol table, some people recognize keywords in lexer rules, others put them
in the symbol table as funny symbols. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.