[antlr-interest] Assign words to a variable inside a rule ????

Austin Hastings Austin_Hastings at Yahoo.com
Tue Oct 30 09:11:05 PDT 2007


The last argument, length, is supposed to be a STRING_CONST. Maybe you 
need to say ... | "0" | "8" ) -- note quotes around 8?

=Austin

OJAY78 at gmx.de wrote:
> Hi,
>
> I have a problem with assigning words to variables inside a rule. This is the function:
>
> fillStrFunction returns[String value]
> 	:
> 	'fill' '(' source = parameter '|' ( mode='left' | mode ='right')  '|' replace = STRING_CONST '|' length = STRING_CONST ')' 
> 	{
> 		$value = FELHelper.fillStrFunction($source.value, $mode.text, $replace.text, $length.text);
> 	}
> 	;
>
> and here is the call of my function:
> fill( "678" | left | "0" | 8 ) -> "00000678"
>
>
> It results in a NoViableAltException, but why? Can anyone explain me I can access such words inside a rule?
>
> Thanks
>
>
>   



More information about the antlr-interest mailing list