Artificial AST

2024-03-05 Thread janAkali
Why not try it? Here's example implementation: import std/[macros] macro foo(): untyped = result = newStmtList( infix( newLit(1), "*", infix( newLit(2), "+", newLit(3) ) )

Artificial AST

2024-03-05 Thread sls1005
Because 1 + 2 * 3 Run will become Infix Ident "+" IntLit 1 Infix Ident "*" IntLit 2 IntLit 3 Run or alike, while (1 + 2) * 3 Run becomes Infix Ident "

Artificial AST

2024-03-05 Thread Araq
Why wouldn't your example be valid? The compiler checks the AST after macro expansion, it can reject it and produce an error message. To be honest, I doubt I understood your question.

Artificial AST

2024-03-04 Thread sls1005
What will happen if the AST generated by a macro is obviously artificial or unnatural (that will never come from the code parser)? For example, Infix Ident "*" Infix Ident "+" IntLit 1 IntLit 2 IntLit 3 Run Is it still vaild?