[antlr-interest] Problems with scoping (ID)*

Marwan Ajraoui marwan.alephn at gmail.com
Tue May 5 12:56:28 PDT 2009


Hi there;

I'm trying to get a scope of variables correspondant to method
declaration. but i'm geting this exception:

Exception in thread "main" java.util.EmptyStackException
	at java.util.Stack.peek(Unknown Source)
	at BTLParser.decl_var(BTLParser.java:462)
	at BTLParser.inst_decl(BTLParser.java:727)

If i put only one ID it does work;

Here is a part of my gramar:

decl_var 	: 	TAG_START_OPEN 'var' {System.out.println("ambito " +
$decl_funcion::ambito);}
				
				 ':' tipo  ids+=ID (',' ids+=ID)* ('=' value)? TAG_EMPTY_CLOSE
				 {
				 System.out.println("Definir un hash map para var con scope");	
				 System.out.println("ref "+$ids.toString() + " in ");				
				 }
	;


decl_funcion

scope {
    String ambito;
}
 	: TAG_START_OPEN 'function' tipo_return  '::' FN_ID
 	
 		{$decl_funcion::ambito = $FN_ID.text;}
 		
 	':' lista_params TAG_CLOSE lista_instrucciones TAG_END_OPEN
'function' TAG_CLOSE ;



Many thx in advance,
-- 
Marouane


More information about the antlr-interest mailing list