On 02/05/2013 06:08 PM, Jacob Carlborg wrote:
On 2013-02-05 16:24, Timon Gehr wrote:

I'd prefer if it needn't be.

macro match(Context context, Ast ast, string code){
     ...
     if(...) context.error("invalid syntax", code[a..b]);
     // (slice of code describes exact location where error
     // is shown to user at the call site.)
     ...
}

The whole point of AST macros is that the compiler will do the lexing
and parsing of the code. It will then just return an AST and it's up to
the developer of the macro to implement the semantics.


If it's just about lexing and parsing, you need a lexer and a parser, not a macro.

If the code is just passed as a string to the macro

That's just one option. Not all macros need to add syntax.

you would then need to lex and parse in addition to implementing the semantics

If one chooses to do so. Parser generators can be provided.

and we would be no better than the current situation with string mixins.


We surely would be better.

Reply via email to