|a token scanner DFA for indirection operator * ? email@example.com (RonG) (2004-03-26)|
|Re: a token scanner DFA for indirection operator * ? firstname.lastname@example.org (Alex Colvin) (2004-04-03)|
|Re: a token scanner DFA for indirection operator * ? email@example.com (2004-04-03)|
|Re: a token scanner DFA for indirection operator * ? firstname.lastname@example.org (Dmitry A. Kazakov) (2004-04-03)|
|Re: a token scanner DFA for indirection operator * ? email@example.com (=?ISO-8859-1?Q?Cass=E9_Hugues?=) (2004-04-15)|
|Date:||26 Mar 2004 22:38:44 -0500|
|Keywords:||C, lex, question, comment|
|Posted-Date:||26 Mar 2004 22:38:44 EST|
I'm trying to write a token scanner for C, and I'm wondering if there is a
detrministic finite automata (DFA) or state machine for the '*'
indirection operator(IOP), or if differentiation between the multiply
operator and the IOP is better left to the parser. Right now my scanner
keeps track of the previous token and also has a lookahead char. My
biggest problem occurs when the previous token is a right parenthesis. In
this case, the parenthesis can enclolse:
1.an expression ( in which case '*' is the multiply operator )
2.a boolean expressian after an 'if' or 'while' ( in which case '*', if
followed by an alphabetic char or underscore, is an IOP )
3.the conditions for a 'for' statement.
I imagine that I could have a flag variable telling me whether the
previous right parenthesis token closed an arithmetic expression, but I
was wondering if I was overlooking something.
Is it possible to determine '*' with just the previous token and a
lookahead char, or do I need to introduce a flag?
thanks in advance
PS. I haven't looke at it yet, but I suspect the same situation can arise
[I think your life will be a lot easier if you interpret the tokens in
the parser, not the lexer. -John]
Return to the
Search the comp.compilers archives again.