Next: , Previous: , Up: Bovine parser development [Contents]


4 Examples

The rule:

any-symbol: symbol
 ;

is equivalent to

any-symbol: symbol
 ( 1ドル )
 ;

which, if it matched the string ‘"A"’, would return

( "A" )

If this rule were used like this:

%token <punctuation> EQUAL "="
…
assign: any-symbol EQUAL any-symbol
 ( 1ドル 3ドル )
 ;

it would match ‘"A=B"’, and return

( ("A") ("B") )

The letters ‘A’ and ‘B’ come back in lists because ‘any-symbol’ is a nonterminal, not an actual lexical element.

To get a better result with nonterminals, use , to splice lists in like this:

%token <punctuation> EQUAL "="
…
assign: any-symbol EQUAL any-symbol
 ( ,1ドル ,3ドル )
 ;

which would return

( "A" "B" )

AltStyle によって変換されたページ (->オリジナル) /