[antlr-interest] 3.1.4 + C runtime: Imaginary tokens lost their names?

Gary R. Van Sickle g.r.vansickle at att.net
Thu Apr 2 22:07:09 PDT 2009


Here's a new one: My imaginary tokens aren't getting printable names now
unless I explicitly set them via a rule like this:

struct_or_union_specifier
	: [...whatever...]
	| lc='struct' IDENTIFIER -> ^(STRUCT[$lc, "STRUCT"] IDENTIFIER)
....

If in my calling program I do this:

	printf((const char*)TheAST.tree->toStringTree(TheAST.tree)->chars);

I get the following:

( ( int) (DIRECT_DECLARATOR abc (PARAM_TYPE_LIST ( ( ( int)
(DIRECT_DECLARATOR nothing))))) (COMPOUND_STATEMENT (RETURN 1))) ( ( int)
(DIRECT_DECLARATOR main (PARAM_TYPE_LIST ( ( ( int) (DIRECT_DECLARATOR
dummy))))) (COMPOUND_STATEMENT ( ( int) ( (DIRECT_DECLARATOR var)))
(FUNCTION_CALL call1 1.2 0) (FUNCTION_CALL CreateThread thread1)
(FUNCTION_CALL CreateThread thread2) (FUNCTION_CALL StartMultitasking)
(RETURN 0)))

Every one of the "( "'s up there is an imaginary token that I can't do the
"$lc" thing to because they derive from nonterminals.  This is using "ANTLR
Parser Generator  Version 3.1.4-SNAPSHOT Mar 31, 2009 24:26:37" and the
latest 3.1.3 C runtime.

Any idea what's going wrong?  Is it me or ANTLR?

-- 
Gary R. Van Sickle



More information about the antlr-interest mailing list