@Christopher: Good point. There's a special :discard rule, one which
tells the lexer to simply throw things away. Whitespace and comments are
usually handled this way. I am guessing, but if that hasn't been tried,
it is usually what it is best to do.
There are quite a few examples of this method of handling whitespace and
comments -- several in the synopsis sections of the main Marpa::R2
documentation. So for a first cut at a discard-rule-based solution,
there are lots of examples to cut-and-paste.
-- jeffrey
On 05/01/2014 05:47 PM, Christopher Layne wrote:
On May 1, 2014, at 17:30, Jeffrey Kegler <[email protected]>
wrote:
If you use them inconsistently, it can't do this and complains. One of its
messages of complaint is the one you got.
In essence this is an ambiguous or possibly even impossible parse, right?
On 05/01/2014 02:43 PM, Michael Roberts wrote:
line ::= name_group sep parmgroup sep sigil sep comment
name_group ::= tag | tag whitespace names
sep ::= whitespace
sep ::=
whitespace ~ [\s]+
sigil ::= ':' | '::' | ':*' | '{' | '[' | '<' | '('
| sigil template_spec
sigil ::=
Question to how others handle things like sep and sigil above. Since they
appear nullable is one not actually trying to say in essence that it's optional?
I usually do something like make this (some chars ommited):
line ::= stuff sep_opt sigil_opt stuff
sep_opt ::= sep*
sep ::= sepword
sigil_opt ::= sigil*
sigil ::= sigilword
sepword ~ whitespace
sigilword ~ ':'
As a way of expressing 0 or 1 of sep or sigil to indicate it's optional. Am I
making life hard for myself and should instead be using nullable alternatives?
Related to this, this is definitely one area where it seems like life would be easier if
the scanless interface supported sep? and sigil? or even just straight quantified rules
since it's capable of internally synthesizing rules like the above and one cannot use
sep* and sigil* unless they're the only quantified rhs rule. The latter is almost always
able to be "wrapped" and if scanless could do it automatically it would speed
up writing grammars. Thoughts?
-cl
--
You received this message because you are subscribed to the Google Groups "marpa
parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.