[antlr-interest] action syntax - "#"

Michael Brade brade at informatik.uni-muenchen.de
Wed Mar 8 02:24:05 PST 2006


Hi,

On Wednesday 08 March 2006 01:41, frank uno wrote:
> We are working with a part of the ANTLR grammar for
> XQuery from the eXist project.
>
> We are unable to find any documentation for the symbol
> - "#" used in the action syntax part.
Look in antlr-2.7.6/antlr/actions/java/action.g for a short explanation.

> For Example:
>
> quantifiedInVarBinding throws XPathException
> { String varName; }:
> 	DOLLAR! varName=qName! ( typeDeclaration )? "in"!
> exprSingle
> 	{ #quantifiedInVarBinding = #(#[VARIABLE_BINDING,
> varName], #quantifiedInVarBinding); }
> 	;
In addition to what Stanimir said, there's an even shorter version:

quantifiedInVarBinding throws XPathException
{ String varName; }:
	DOLLAR! varName=qName! ( typeDeclaration )? "in"! exprSingle
	{ ## = #([VARIABLE_BINDING, varName], ##); }
	;

*if* I understand you correctly and all you want to do is add an imaginary 
token VARIABLE_BINDING on top of the tree generated by that rule with the 
contents of the variable being the descendents of it.

Cheers,
-- 
Michael Brade;                 KDE Developer, Student of Computer Science
  |-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
  °--web: http://www.kde.org/people/michaelb.html

KDE 4: Beyond Your Expectations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060308/9e539cd0/attachment.bin


More information about the antlr-interest mailing list