4 ms·
I didn't say recursion never works. I say most of the times, it doesn't. There is no alternation in the example you provide, for instance. Had you written it
by grondilu 9y ago
I didn't say recursion never works. I say most of the times, it doesn't. There is no alternation in the example you provide, for instance.
Had you written it like this:
grammar {
rule TOP { <string> }
rule string { <[a..z]> | <string><[a..z]> }
}
as inspired by the rule mentioned above in the ECMAscript reference, it would fail.
- zengargoyle 9y agoI'm probably off the mark a little bit.... but 'rule' implies that whitespace is really <.ws> (totally ignored white space matching thingy). '|' is the Longest-Match-First (different from Perl/PCRE/etc). LMF is not possible in the case where it is not a DFA... the implicit <.ws> that is there by using 'rule' and having a space might be your problem... :) TL;DR Don't forget that 'rule' does <.ws> magic. This may or may not actually be part of the problem... I have seen a similar sort of thing and only half understand the answer i got.. Check your implicit <.ws> and '|' LMF.
- grondilu 9y agoI had tried replacing 'rule' by 'token' and it did not change much.