in reply to Re: Using Perl6 patterns/grammar definition for <I>output</I>?
in thread Using Perl6 patterns/grammar definition for 'output'?
Instead of $a := (\d+), write $a := <number_token> where number_token is itself defined as you show, or more complex such as (0|0[xX])\d+. Then, a derived grammar would override number_token to be something that formats, as opposed to something that accepts flexible input. Some standard mechanism would say "here is the string to be emitted" within the {} block of the rule.
Terminals, by definition, would need to contain code to format the output. Nonterminals just state the arrangement of terminals, and in the absence of alternation and repitition (push that down to a lower level rule) would be used as-is.
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Using Perl6 patterns/grammar definition for <I>output</I>?
by dpuu (Chaplain) on Sep 05, 2002 at 17:52 UTC | |
by John M. Dlugosz (Monsignor) on Sep 05, 2002 at 20:39 UTC | |
by dpuu (Chaplain) on Sep 05, 2002 at 21:28 UTC | |
by John M. Dlugosz (Monsignor) on Sep 06, 2002 at 15:49 UTC |