diff options
author | dom96 <dominikpicheta@googlemail.com> | 2011-04-04 23:12:24 +0100 |
---|---|---|
committer | dom96 <dominikpicheta@googlemail.com> | 2011-04-04 23:12:24 +0100 |
commit | ffd05510bd8e0f8ca294497eb6b8062a3d80b7a1 (patch) | |
tree | d99bb4f870c8836eb4ff001b27ba8762ccc9d402 /tests/accept/compile | |
parent | 7e62c39f8ed137e05505f21ca6759a377b1afcdc (diff) | |
download | Nim-ffd05510bd8e0f8ca294497eb6b8062a3d80b7a1.tar.gz |
fixes #27
Diffstat (limited to 'tests/accept/compile')
-rw-r--r-- | tests/accept/compile/tmacrostmt.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/accept/compile/tmacrostmt.nim b/tests/accept/compile/tmacrostmt.nim new file mode 100644 index 000000000..5d1403dac --- /dev/null +++ b/tests/accept/compile/tmacrostmt.nim @@ -0,0 +1,17 @@ +import macros +macro case_token(n: stmt): stmt = + # creates a lexical analyzer from regular expressions + # ... (implementation is an exercise for the reader :-) + nil + +case_token: # this colon tells the parser it is a macro statement +of r"[A-Za-z_]+[A-Za-z_0-9]*": + return tkIdentifier +of r"0-9+": + return tkInteger +of r"[\+\-\*\?]+": + return tkOperator +else: + return tkUnknown + +case_token: inc i |