diff options
Diffstat (limited to 'spec/inputs/macro-export.mp')
-rw-r--r-- | spec/inputs/macro-export.mp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/inputs/macro-export.mp b/spec/inputs/macro-export.mp new file mode 100644 index 0000000..b6079ca --- /dev/null +++ b/spec/inputs/macro-export.mp | |||
@@ -0,0 +1,28 @@ | |||
1 | export macro block config = (debugging = true)-> | ||
2 | global debugMode = debugging == "true" | ||
3 | global debugMacro = true | ||
4 | "" | ||
5 | |||
6 | export macro expr showMacro = (name,res)-> | ||
7 | if debugMacro | ||
8 | "do | ||
9 | txt = #{res} | ||
10 | print '[macro '..#{name}..']' | ||
11 | print txt | ||
12 | txt" | ||
13 | else | ||
14 | res | ||
15 | |||
16 | export macro block asserts = (cond)-> | ||
17 | if debugMode | ||
18 | $showMacro "assert", "assert #{cond}" | ||
19 | else | ||
20 | "" | ||
21 | |||
22 | export macro expr assert = (cond)-> | ||
23 | if debugMode | ||
24 | $showMacro "assert", "assert #{cond}" | ||
25 | else | ||
26 | "#{cond}" | ||
27 | |||
28 | $config! | ||