It would probably be best to have two different grammars.
On Sat, Sep 1, 2012 at 4:23 PM, Aleksander Heintz <
alx...@alxandr.me> wrote:
> I'm trying to write a grammar that can be used in 2 different ways, one is
> an interactive console, the other is running a "script" through my
> interpreter. For the later the grammar basically looks like this:
>
> <Program> ::= <Statement List>
> <Statement> ::= <For Stmt> | .... | <Expression Stmt>
> <Expression Stmt> ::= <Expression> ';'
>
> (note a lot has been omitted to make the code short. This means that for
> instance a valid script may look like this:
>
> 2+3;
> 3+5*2;
>
> However, simply writing 2+2 would be invalid, cause that would not be a
> statement. However, when in interactive console, this should be valid, as
> the interactive console should run both valid scripts and valid expressions.
> So I was wondering, do I need to different grammars with different
> start-symbols? Or can I achieve this in some other way?
>
> --
> You received this message because you are subscribed to the Google Groups
> "GOLD Parsing System" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/gold-parsing-system/-/FK2U6EI_Vt8J.
> To post to this group, send email to
gold-pars...@googlegroups.com.
> To unsubscribe from this group, send email to
>
gold-parsing-sy...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/gold-parsing-system?hl=en.