How do I implement check_type() ?
Fri, 22 May 2009 19:08:43 -0700 (PDT)

          From comp.compilers

Related articles
How do I implement check_type() ? (2009-05-22)
Re: How do I implement check_type() ? (Hans-Peter Diettrich) (2009-05-25)
Re: How do I implement check_type() ? (Michiel Helvensteijn) (2009-05-25)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: Fri, 22 May 2009 19:08:43 -0700 (PDT)
Organization: Compilers Central
Keywords: question, C++
Posted-Date: 24 May 2009 19:33:20 EDT

I am transforming the YACC grammar and LEX specification into a very
simple C++ interpreter. I am only adding classes from C++ to the
grammar referenced below. I parse all of the input source code file
into an Abstract Syntax Tree.

In the case of this project I need to return TYPE_NAME from the lexer
whenever I encounter a Class name. The problem seems to be that only
the parser knows whether or not the IDENTIFIER is a class name or not,
and yet the lexer sees the name before it goes to the parser.

What is the simplest way to get around this problem?

int check_type()
* pseudo code --- this is what it should check
* if (yytext == type_name)
* return(TYPE_NAME);
* return(IDENTIFIER);

* it actually will only return IDENTIFIER


Post a followup to this message

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