At 16:38 +0200 2005/04/18, Akim Demaille wrote:
 > Would you mind enlighten me as to how %printer works? -- It seems to
 > not be documented.

%printer { how to print $$ } SYMBOLS

e.g. in C++

%printer { debug_stream () << *$$; } "string" "identifier"
%printer { debug_stream () << $$; }  "integer"

If I look a bit into the output parser code, how error messages are written, then yyerror expects a full string. It might be too intrusive to change it accepting a stream instead. So it seems that one needs a command telling how to "stringize", or express (to "express" is opposite of to "parse") the token. For example:
%stringize { how to stringize $$ } "string" "identifier"


Then the %printer might use that, if the string value is somehow available via a symbol. E.g., in C++
%printer { debug_stream () << $$$ }
would generate a default printing rule, if $$$ represents the string value of the token at hand. (There is a tricky thing, if one admits a default printing rule, namely, if $$$ appears in its body, the default rule should only be defined for those tokens which has a %stringize definition.)


Otherwise, how and when is the defined %printer invoked for a particular token?
--
  Hans Aberg




Reply via email to