Related articles |
---|
yacc grammar and types l41484@alfa.ist.utl.pt (Umm) (1997-03-27) |
From: | Umm <l41484@alfa.ist.utl.pt> |
Newsgroups: | comp.compilers |
Date: | 27 Mar 1997 13:19:43 -0500 |
Organization: | Compilers Central |
Keywords: | yacc, parse, question, comment |
Who is the responsability of checking semantic value of a program? The
grammar parser or the interpreter/compiler itself. For example
Should i do it this way:
%union
{
int integer;
float real;
}
%token <integer> INT
%token <real> REAL
%%
expr : | INT
| REAL
| expr + expr
| expr - expr
;
or should i use something like:
expr : NUM
| expr + expr { /* here i would determine the semantics of the
expressions if it was a float or a int */ }
| expr - expr
;
(used a very simple example)
Basically the question is, who has the burden of watching the semantics,
the parser or the "user" code.
--
Tiago Umm Pascoal
l41484@alfa.ist.utl.pt
[You can do it either way. Which is easier or better depends on the language
you're parsing. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.