Right, again I do apologize for the size of the grammar, as I haven't put 
together a sensible testing and regression framework for grammars yet.

There's only one problem with your explanation here, and that is that 
you've described why you think the error would happen in the version that 
actually works, not in the modified one that doesn't. (Which is why I'm so 
mystified, because I see the logic of what I think you're describing, but 
it doesn't seem to apply to this case.)

I'll try to isolate this into a more manageable grammar today, and I also 
want to put together a handy command-line testing facility for grammars so 
I can more easily try out alternatives.  I'll keep you posted.

On Friday, May 2, 2014 2:30:40 AM UTC+2, Jeffrey Kegler wrote:
>
>  I can take a guess at what is happening.  Since, as Ron points out, the 
> example is a bit large, I did not check this in detail, so feel free to 
> follow up if this does not help.
>
>  G1 thinks that <name> is a lexeme.  L0 disagrees.
>
> In more detail, G1 finds that <name> is on the RHS of one of its rules, 
> and not on a LHS.  So G1 concludes that <name> is a lexeme.  L0 looks for 
> <name> on the *LHS* of one of its rules.  It does find it on the LHS of an 
> L0 rule, as required.  But it also finds this:
>
>    names ~ name+
>
> Here <name> appears on the RHS of an L0 rule, which tells Marpa that is it 
> not a lexeme, after all.   One solution (if my guess is right) is to 
> rewrite so that <name> is not on the RHS of any L0 rules.
>
> What Marpa is doing is figuring out the boundary between G1 and L0 for 
> you, based on how you used the symbols.  If you use them inconsistently, it 
> can't do this and complains.  One of its messages of complaint is the one 
> you got.
>
> In the doc 
> https://metacpan.org/pod/distribution/Marpa-R2/pod/Scanless.podthere's an 
> even more detailed discussion of this.
>
> Again, feel free to follow up if this doesn't help.
>
> -- jeffrey
>
> On 05/01/2014 02:43 PM, Michael Roberts wrote:
>  
> Apologies in advance for not cutting my grammar down to isolate the error, 
> but I'm having a problem understanding an error when I try to modify the 
> following grammar: 
>
>  :default ::= action => [name,values]
> lexeme default = latm => 1
> :start ::= line
>
>  line ::= name_group sep parmgroup sep sigil sep comment
> name_group ::= tag | tag whitespace names
>
>  sep ::= whitespace
> sep ::=
> whitespace ~ [\s]+
>
>  tag ::= tag_name
> tag_name ~ <plain tag> | <annotation tag>
> <plain tag> ~ [\w]+
> <annotation tag> ~ '[' <plain tag> ']'
>
>  names ~ name+
> name ~ [\w]+
>
>  parmgroup ::= paren_group | bracket_group | string
> parmgroup ::=
> paren_group ::= '(' parm_list ')'
> bracket_group ::= '[' parm_list ']'
> parm_list ::= parm* separator => <comma>
> parm ::= words | words '=' string
> words ~ name+
>
>  sigil ::= ':' | '::' | ':*' | '{' | '[' | '<' | '('
>       | sigil template_spec
> sigil ::=
>       
> template_spec ::= '?' <up_to_comment>
> <up_to_comment> ~ [^#]
>
>  <comma> ~ [,]
>
>  string ::= sqstr || dqstr            # Strings stolen from 
> MarpaX::Demo::JSONParser
> sqstr ~ sq <sq contents> sq
> dqstr ~ dq <dq contents> dq
> sq ~ [']
> dq ~ ["]
> <sq contents> ~ <sq char>*
> <dq contents> ~ <dq char>*
> <sq char> ~ [^'\\] | '\' <any char>
> <dq char> ~ [^"\\] | '\' <any char>
> <any char> ~ [\d\D]
>
>  comment ::= hash_comment             # No comment, or comment consisting 
> of a hash followed by everything else in the string.
> comment ::=
> hash_comment ~ '#' anything
> anything ~ <any char>*
>
>  The above grammar works fine on my test string, but when I make "names" 
> a ::=-rule instead of a ~-rule, like this:
>
>  names ::= name
>
>  I get the following error:
>
>  A lexeme in G1 is not a lexeme in any of the lexers: name
>  
>  OK, so 'name' is clearly still a lexeme in a lexer if I understand the 
> terminology correctly. What am I missing?  I get a similar error if I try 
> to use "separator => whitespace" - except now it can't find whitespace. 
> Clearly I am entirely barking up the wrong tree here.
>
>   -- 
> 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] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
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.

Reply via email to