Hans,
see '<>' characters surrounding a symbol definition a few times
The < ... > characters delimit the text that will be made available
to the next action as 'yytext'. If you want to ignore spaces either
side of a number, you might write
number = [ \t]* < [0-9]+ > [ \t]* { (atoi yytext) }
The < and > have no other significance at all.
might point out the start symbol for example?
The first rule is implicitly the start symbol. If you want to start
elsewhere, let's say from the rule 'foo', then instead of
(yy-parse yy)
use
(yy-parse-from yy yy__foo)
On a different note: I read somewhere that PEG's aren't able to use
left-recursive parsing rules.
It depends on the implementation. The Jolt one currently cannot.
Yet at first sight the code generator doesn't
seem to complain when I write a few...
Detecting the potential for infinite left-recursion is not hard. One
(conservative) way is to write a function over the PEG operators
(which will also apply, by induction, to entire rules) that answers
whether an operator (or rule) must consume input to succeed. The
function is recursive but the recursion stops immediately at a
positive answer (meaning input must be consumed). For each non-
terminal in the grammar, apply the function and if it ever encounters
a rule more than once during the recursion then you have potentially
infinite left recursion.
Are Jolt PEG's more powerful than usual, or will I run into trouble
later on?
Currently they are not (this may change), and you will run into
trouble. OTOH, almost all of the interesting uses for left recursion
are subsumed by the PEG iteration operators.
Cheers,
Ian
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc