[nem-en] Macros and syntax extensions.
Sergei Tulentsev
sergei.tulentsev at gmail.com
Mon Apr 30 13:18:12 CEST 2007
Yeah, the code in PrettyPrinter seems to be what I need.
And one more off topic question:
every once in a while I see code like this
| GrammarElement.Keyword (k) => acc.Write (" ");
acc.Write(k);
acc.Write (" ")
Why not using sprintf, or $-string? Are there special reasons not to do
that? Or this code was writter before those macros and then nobody wanted to
rewrite it?
On 4/30/07, Kamil Skalski <kamil.skalski at gmail.com> wrote:
>
> Look at the PrettyPrinter class, it does exactly this - lookup custom
> syntax of a macro. However this will not be 100% accurate, since
> singly macro can have many possible ways to parse it (the syntax
> extensions are trees, not simple lists).
>
> Maybe it would be feasible to put the original tokens somehow into the
> MacroCall node... but I would prefer the less intrusive solution.
>
> 2007/4/30, Sergei Tulentsev <sergei.tulentsev at gmail.com>:
> > Now I bumped into this couple.
> >
> > In order to format the code, I get bodies of methods as PExpr's. There
> is
> > PExpr.MacroCall.
> > Fine.
> > Almost. :-)
> >
> > This is its definition:
> > // macros stuff
> > | MacroCall { name : Name; ns : NamespaceTree.Node;
> > parms : list [SyntaxElement]; }
> >
> > We see no sign of custom syntax that was probably introduced by the
> macro.
> > For example, the "if" macro.
> > if(cond)
> > true
> > else
> > false
> >
> > In this case we will have two elements in parms, literals "true" and
> > "false". But I also need to get parse information about "if" and "else"
> > (more specifically, locations)
> > Or... I need a way to get custom syntax description of that macro. So
> that
> > I can manually lookup parts of it in the token stream.
> >
> > Any ideas?
> >
> > --
> > Best wishes,
> > Sergei Tulentsev
> > Senior software engineer.
> >
> > SITRONICS Telecom Solutions, Moscow
> > http://www.sitels.ru
> > mob: + 7 916 507 7112
> > _______________________________________________
> > https://nemerle.org/mailman/listinfo/devel-en
> >
> >
>
>
> --
> Kamil Skalski
> http://nazgul.omega.pl
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
--
Best wishes,
Sergei Tulentsev
Senior software engineer.
SITRONICS Telecom Solutions, Moscow
http://www.sitels.ru
mob: + 7 916 507 7112
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman/pipermail/devel-en/attachments/20070430/dfaca553/attachment.html
More information about the devel-en
mailing list