[antlr-interest] Gramar without semicolon
Monty Zukowski
monty at codetransform.com
Wed Jul 28 09:52:40 PDT 2004
It looks like your grammar should be working. Try turning on tracing
(-traceParser when invoking antlr.Tool) and also inspect the generated
code to get a feel for what antlr is trying to do.
Monty
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
On Jul 27, 2004, at 1:58 PM, Joan Pujol wrote:
> 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
>
>
>
>
>
>
>
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