[nem-en] Macros and syntax extensions.

Kamil Skalski kamil.skalski at gmail.com
Mon Apr 30 08:01:38 CEST 2007


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



More information about the devel-en mailing list