[antlr-interest] backtrack + rule arguments + C target

Jim Idle jimi at temporal-wave.com
Thu Apr 1 07:01:15 PDT 2010


Please read the documentation:

@declarations {}
@init {}

Then search the list using antlr.markmail.org for hoisted predicates and local variables. It isn't the C target it is just that the local variable or parameter is out of scope for the predicate, so you must use scopes if you have to use semantic predicates (with parameters).

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Anton Bychkov
> Sent: Thursday, April 01, 2010 4:20 AM
> To: antlr-interest at antlr.org interest
> Subject: [antlr-interest] backtrack + rule arguments + C target
> 
> Hi.
> 
> I have some problems with backtrack option and rule arguments.
> 
> Example grammar:
> 
> grammar testbt;
> 
> options
> {
> 	language = C;
> 	backtrack = true;
> }
> 
> expr
> 	@init {
> 		int i = 1;
> 	}
> 	:
> 	num[i] | id[i]
> 	;
> 
> 
> num[int i]	:	'0'..'9'+;
> id[int i]	:	'a'..'z'+;
> 
> Generated files does not compile with error "error C2065: 'i' :
> undeclared identifier".
> (The problem is that C target does not insert rule arguments into
> argument list of autogenerated 'synpred' functions.)
> 
> How can I fix this?
> 
> 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