[nem-en] Questions about macros
Kamil Skalski
kamil.skalski at gmail.com
Fri Jun 9 19:11:55 CEST 2006
Probably 'syntax' is indeed too weak for your needs. You should try
the token stream feature:
http://nemerle.org/Syntax_extensions
You can take a look in ncc/testsuite/positive/macrolib.n and
macroprog.n for the example with XML literals.
I guess my approach would be to define macro with raw token syntax
extension, which begins with 'from' keyword. It would take the stream,
cut it into parts delimited by query syntax keywords (like 'select',
'orderby', 'where') and then try to use standard parser's methods to
parse those partial token streams into PExpr.
2006/6/9, Alejandro Serrano <trupill at yahoo.es>:
> Hi again,
> I've got some more questions about macros.
>
> 1) Is there any way to reuse the "where" keyword? I used "syntax
> ("from", clause, Optional ("wherex", where_clause), Optional("select",
> select_clause))", it compiles fine, but when used it complains about
> "where on a raw expression".
>
> 2) How can I look for expressions? I mean I want to have this string
>
> from x in c where x > 2 select x + 1groupby x, x+1 ascending
>
> to be extracted as:
>
> from (x in c)
> where (x > 2) <-- x > 2 as a expression
> select (x+1)
> groupby (x, (x+1) ascending) <-- I should get some array or list
> containing the expressions
>
> and all these expressions can be on any order, so I should get an array
> with all of them
>
> I don't want to bother, just please point me on the right direction,
> because I feel using the "syntax" syntax (:-) is very limited for this
> case. I've looked in documentation and in the library, and I've only
> found something near what I'm looking for in Alias macro, which rceives
> a list[PExpr]. However, in that case commas delimit the PExpr, in my
> case they do not.
>
> Thanks in advance
>
>
>
>
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list