[antlr-interest] What is $Symbols

Paul Keir paul at paulkeir.com
Thu Jun 21 13:10:35 PDT 2007


Hi,

In the ANTLR C Grammar there is a global scope:

scope Symbols { Set types; }

which is updated when new typedefs are discovered during parsing. A 
reference to $Symbols becomes a reference to a java.util.stack, and I'm 
often using things like $Symbols.size() and $Symbols[i]::types.

Well there's the background, but could someone be so kind as to tell me 
what exactly it's a stack of? I'm passing it to my own java object, and 
I'd like to iterate over its contents like

public void my_method(Stack sym) {
            for (Object depth : sym)
                depth.types.add("hello");   // e.g.
}

But that doesn't work. The 'for' bit is fine, but the next 'add' line 
results in a 'cannot find symbol' error. I'd like to get more specific 
than 'Object', but there's my problem. Can anyone help?

Paul



More information about the antlr-interest mailing list