a token scanner DFA for indirection operator * ?

RonG <rgesell@mb.sympatico.ca>
26 Mar 2004 22:38:44 -0500

          From comp.compilers

Related articles
a token scanner DFA for indirection operator * ? rgesell@mb.sympatico.ca (RonG) (2004-03-26)
Re: a token scanner DFA for indirection operator * ? alexc@std.com (Alex Colvin) (2004-04-03)
Re: a token scanner DFA for indirection operator * ? vbdis@aol.com (2004-04-03)
Re: a token scanner DFA for indirection operator * ? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2004-04-03)
Re: a token scanner DFA for indirection operator * ? casse@netcourrier.fr (=?ISO-8859-1?Q?Cass=E9_Hugues?=) (2004-04-15)
| List of all articles for this month |

From: RonG <rgesell@mb.sympatico.ca>
Newsgroups: comp.compilers
Date: 26 Mar 2004 22:38:44 -0500
Organization: MTS Internet
Keywords: C, lex, question, comment
Posted-Date: 26 Mar 2004 22:38:44 EST

Hi:


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
Ron Gesell


PS. I haven't looke at it yet, but I suspect the same situation can arise
with '&'.
[I think your life will be a lot easier if you interpret the tokens in
the parser, not the lexer. -John]


Post a followup to this message

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