[antlr-interest] Simple Rewrite Rule

Stephan Opfer stephan.opfer at gmx.net
Thu May 10 07:08:02 PDT 2012


Hi,

I somehow solved the problem with the help of this two website:
http://www.antlr.org/wiki/display/ANTLR3/How+to+remove+global+backtracking+from+your+grammar

http://www.antlr.org/wiki/display/~admin/2007/06/28/Token+stream+rewriting+with+rewrite+rules

Best Regards,
  Stephan


On 05/10/2012 02:49 PM, Stephan Opfer wrote:
> Hi,
> 
> thx for the advice. You were right saying that I want ^(OR  ^(NOT
> $f1)$f2)...
> 
> Now I have a little NoViableAltException with this Rule:
> 
>  9 formula	
> 10	:	f1=(NOT^? LPAREN! formula RPAREN!
> 11		| 	((FORALL^ | EXISTS^) VARIABLE)formula
> 12		) ( IMPLY f2=formula -> ^(OR  ^(NOT $f1) $f2))*;
> 
> The exception is about line 12.
> 
> [14:46:04] error(100): Test.g:12:27: syntax error: antlr:
> NoViableAltException(77@[921:1: rewrite_alternative options {k=1; } :
> ({...}? => rewrite_template | {...}? => ( rewrite_element )+ ->
> {!stream_rewrite_element.hasNext()}? ^( ALT[LT(1),"ALT"]
> EPSILON["epsilon"] EOA["<end-of-alt>"] ) -> ^( ALT[LT(1),"ALT"] (
> rewrite_element )+ EOA["<end-of-alt>"] ) | -> ^( ALT[LT(1),"ALT"]
> EPSILON["epsilon"] EOA["<end-of-alt>"] ) | {...}? ETC );])
> 
> Any suggestions? :)
> 
> Best Regards,
>   Stephan
> 
> On 05/10/2012 01:54 PM, Stephen Siegel wrote:
>> f1=formula '->' f2=formula -> '!' $f1 OR $f2;
>>
>> (but maybe you would rather have ^(OR  ^(NOT $f1) f2) for your AST output).
>> -Steve
>>
>> On May 10, 2012, at 7:49 AM, Stephan Opfer wrote:
>>
>>> Hi,
>>>
>>> can somebody help me with my little problem? I want to say something
>>> like this:
>>>
>>> implication: formula '->' formula -> '!' formula OR formula;
>>>
>>> How do I identify the two different formulas?
>>>
>>> Best Regards,
>>>  Stephan
>>>
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list