Examples
The rule:
any-symbol: symbol
;is equivalent to
bash
any-symbol: symbol
( $1 )
;which, if it matched the string ‘"A"’, would return
emacs-lisp
( "A" )If this rule were used like this:
bash
%token <punctuation> EQUAL "="
...
assign: any-symbol EQUAL any-symbol
( $1 $3 )
;it would match ‘"A=B"’, and return
emacs-lisp
( ("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:
bash
%token <punctuation> EQUAL "="
...
assign: any-symbol EQUAL any-symbol
( ,$1 ,$3 )
;which would return
emacs-lisp
( "A" "B" )