Re: Parsing / Lexing question & P-code

Keith Thompson <>
25 Apr 2000 02:25:49 -0400

          From comp.compilers

Related articles
Parsing / Lexing question & P-code (Nicolás) (2000-04-14)
Re: Parsing / Lexing question & P-code (Herwig Huener) (2000-04-21)
Re: Parsing / Lexing question & P-code (Keith Thompson) (2000-04-25)
Re: Parsing / Lexing question & P-code (Sebastian Moleski) (2000-04-25)
| List of all articles for this month |

From: Keith Thompson <>
Newsgroups: comp.compilers
Date: 25 Apr 2000 02:25:49 -0400
Organization: CTS Network Services
References: 00-04-100 00-04-154
Keywords: parse, Pascal

Herwig Huener <> writes:
Nicolás wrote:
> But recently I came up with another idea: instead of returning an ID
> for any identifier, I looked up the identifier in the lexer, and
> returned ID_UNKNOWN, ID_FUNCTION, etc ... This allowed me to have much
> less error checking and no conflicts in the bison grammar.

How does this handle redeclarations in an inner scope? For example
(my Pascal syntax is a bit rusty, so this may not be entirely

function foo: integer;
      function inner: integer;
            foo: integer;

If the lexer thinks "foo" is a function name, the parser probably
isn't going to be happy about using it as the name of a variable.

On the other hand, if you write the grammar so that any kind of
identifier can be used in a new declaration, but the identifier in a
function call, for example, can only be an ID_FUNCTION, it might work.

Keith Thompson (The_Other_Keith) <>
San Diego Supercomputer Center <*> <>

Post a followup to this message

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