The way Marpa checks internally is this 1.) Look for G1 symbols on a RHS, but not on a LHS -- these are the G1 lexemes. 2.) Look for L0 symbols on a LHS, but not on a RHS -- these are the L0 lexemes. 3.) The two sets of lexemes (G1 and L0) *should* be the same. If not, an error is reported.
Note in this way of doing things, the order of rules plays no role, not even in the generation of the error message. Marpa doesn't even try to figure out what's a lexeme until both grammars are fully formed. The above ignores some details. For example, there is a :lexeme pseudo-rule, and any symbol specified in one of these pseudo-rules is required to also be both a L0 lexeme and a G1 lexeme, by the above definitions. On Wed, Mar 29, 2017 at 9:45 PM, Andreas Kupries <[email protected]> wrote: > > > OK! Quiz time! The following are off the top of my head, and untested: > > > > 1.) :start ::= A A ~ 'a' > > > > A is a lexeme and, yes, a lexeme should be OK as the start symbol. > > Good. > > > 2.) A ::= B C B ~ 'b' C ~ 'aa' B > > > > A lexeme is *NOT* OK on the RHS of an L0 rule, > > Good. That is easy to check for. > > > so B is *NOT* a lexeme. > > After the ruling above this is 'Six of one ...'. > > The two facts of > > (a) Being LHS of ~, and RHS of ::= ==> lexeme > (b) Being RHS of ~ ==> not lexeme > > are simply in conflict. Depending on the order we encounter the rules > we can error as either > > (i) Illegal use of lexeme X on the RHS of match rule .... > or (ii) Illegal use of plain lex symbol X as a lexeme. > > In the given example it would be (IMHO) error (i). But that is a bit > of a detail. > > The simple rule of "Lexeme forbidden on RHS of ~" is what I had hoped > for. Simple checking, and the lexemes form a neat layer on top of the > L0, at the bottom of G1. > > > Since the grammar is ill-formed, I'll pass on the question about <C>. > > No problem. With the ruling on B it became moot. > > > I'll deal with the last 3 separately. > > > I hope this helps! > > Yes, it did, thank you. > > -- > See you, > Andreas Kupries <[email protected]> > <http://core.tcl.tk/akupries/> > Developer @ SUSE > > Tcl'2017, Oct 16-20, Houston, TX, USA. http://www.tcl.tk/community/ > tcl2017/ > EuroTcl 2017, Jul 8-9, Berlin/DE, http://www.eurotcl.tcl3d.org/ > ------------------------------------------------------------ > ------------------- > > > > > -- > 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. > -- 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.
