[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing sub-grammars



Niklas,
  From what I am aware, there is no way to write a
"sub" grammar in SableCC; however, I think there might
be a better solution.
  SableCC uses the visitor design pattern to handle
interpretation of a program. You can write two
different walkers; one will correctly parse every
production; the other will sub-class it and will
over-ride only the illegal productions (illegal
according to the "small" grammar) and produce some
error. This way maximizes code re-use.

(-> SR

PS: Please wait for a few more responses from the
list; my knowledge of SableCC still isn't up-to-date
with the latest version.


--- Niklas Matthies <ml_sablecc-user@xxxxxxxx> wrote:

> Hello,
> 
> I'm new to this list, and I have a question with
> regard to SableCC,
> which I am in the process of evaluating for use in a
> project:
> 
> Is ist possible to have sub-grammars of a given
> grammar and have --
> in addition to the parser for the full grammar -- a
> parser for that
> sub-grammar (i.e. which only accepts expressions of
> the sub-grammar),
> without having to write two seperate grammar
> definitions and getting
> duplicate node classes for the tokens/productions of
> the sub-grammar?
> 
> Background: We have input fields in the user
> interface of our
> application where only certain (sub-)expressions of
> our language
> should be accepted. To illustrate, imagine a Java
> interpreter where
> on the one hand you can enter complete Java source
> files, but during
> execution of such a program you may only enter Java
> expressions to be
> evaluated by the interpreter for debugging purposes
> (like "watches" in
> a debugger).
> 
> -- Niklas Matthies
> 
> _______________________________________________
> SableCC-user mailing list
> SableCC-user@xxxxxxxxxxx
>
http://sablecc.org/lists/control/listinfo/sablecc-user
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com