[antlr-interest] Gramar without semicolon
Joan Pujol
joanpujol at gmail.com
Tue Jul 27 13:58:34 PDT 2004
Hi,
I've to write a compiler for a pseudocode language to
use in a elearning platform.
The pseudocode language, at first, don't use semicolon
to end instructions(it's only used as a separator to
use multiple instructions in a single line). And I
have some problems with the gramar.
I make a simple case with only two instructions an if
and an assignament:
instructions: (instruction)+;
instruction: inst_if | inst_assig;
inst_if: IF expr THEN (NL)* instructions (ELSE (NL)*
instructions)? ENDIF ((NL)+ |SEMICOLON instruction);
inst_assig: IDENT ASSIG expr ((NL)+ |SEMICOLON
instruction);
This I think that works quite well and recognizes
thinks like
IF expr THEN inst1;inst2
ELSE inst1
END IF
But it can't recognize
IF expr THEN inst1 ELSE inst2 END IF
And I don't know how to manage this, I think that I've
to use semantic predicates but I am a little confused.
Somebody knows how to manage this, or has implemented
a similar grammar (without semicolon and similar to
Visual Basic)
Cheers,
=====
---
Joan Jesús Pujol Espinar
______________________________________________
Yahoo! lanza su nueva tecnología de búsquedas
¿te atreves a comparar?
http://www.viralbusquedas.yahoo.es
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list