Richard Thrippleton wrote:
Gary R. Van Sickle wrote:
  
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.
    
Is there any reason that you can't do STRUCT["STRUCT"] (in the case 
where you don't have a token to derive from such as $lc)?
Also, if you want to derive from a nonterminal such as the output of a 
rule, $rule.start can be derived from (the first token successfully 
matched by that rule).
  
Basically, this is the only time that setting the value of an imaginary token to its name by default is useful. I did not want the overhead of initializing tokens when they are not used and I changed the way that text is stored for tokens. I can probably make such tokens use a fixed pointer to the token names array; the fact that I did not probably being an oversight.

Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to