fork download
  1. using System;
  2.  
  3. macro @if (cond, e1, e2)
  4. syntax ("if", "(", cond, ")", e1, Optional (";"), "else", e2)
  5. {
  6. /*
  7.   <[ ]> defines an area of quasi-quotation, the Nemerle compiler transforms the code in it
  8.   to an AST tree, such transformations are somewhat similar to an Expression compiling in C#
  9.   */
  10. <[
  11. match ($cond : bool)
  12. {
  13. | true => $e1
  14. | _ => $e2
  15. }
  16. ]>
  17. }
  18.  
  19. // using this macro in code:
  20. def result = if (Console.ReadLine()> Console.ReadLine()) "greater" else "other";
  21.  
  22. Console.WriteLine(result)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
abc
d
compilation info
prog.nem:5:1:17:2: error: unbound type name `IMacro'
prog.nem:5:1:17:2: error: unbound type name `GrammarElement'
prog.nem:5:1:17:2: error: unbound type name `SyntaxElement'
prog.nem:5:1:17:2: error: unbound type name `SyntaxElement'
prog.nem:5:1:17:2: error: unbound type name `Typer'
prog.nem:5:1:17:2: error: unbound type name `SyntaxElement'
prog.nem:5:1:17:2: error: unbound type name `PExpr'
prog.nem:5:1:17:2: error: unbound type name `PExpr'
prog.nem:5:1:17:2: error: unbound type name `SyntaxElement'
stdout
Standard output is empty