Re: a token scanner DFA for indirection operator * ?

vbdis@aol.com (VBDis)
3 Apr 2004 09:10:52 -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: vbdis@aol.com (VBDis)
Newsgroups: comp.compilers
Date: 3 Apr 2004 09:10:52 -0500
Organization: AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com
References: 04-03-102
Keywords: lex
Posted-Date: 03 Apr 2004 09:10:51 EST

RonG <rgesell@mb.sympatico.ca> schreibt:


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


Doesn't '*' have 3 meanings?
1. multiply
2. dereference
3. pointer (in declaration, cast-expression)


>Is it possible to determine '*' with just the previous token and a
>lookahead char, or do I need to introduce a flag?


For (3) the scanner must be able to distinguish between type names and other
identifiers.


>PS. I haven't looke at it yet, but I suspect the same situation can arise
>with '&'.


And with '++' and '--' as prefix or postfix operators, and '+' and '-' as unary
or binary operators...


>[I think your life will be a lot easier if you interpret the tokens in
>the parser, not the lexer. -John]


Agreed.


DoDi


Post a followup to this message

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