summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xrod/pnimsyn.nim4
-rw-r--r--tests/accept/compile/tmacrostmt.nim17
2 files changed, 19 insertions, 2 deletions
diff --git a/rod/pnimsyn.nim b/rod/pnimsyn.nim
index 869d968b6..a894f2723 100755
--- a/rod/pnimsyn.nim
+++ b/rod/pnimsyn.nim
@@ -765,8 +765,8 @@ proc parseExprStmt(p: var TParser): PNode =
       addSon(result, a)
       getTok(p)
       skipComment(p, result)
-      if (p.tok.tokType == tkInd) or
-          not (p.tok.TokType in {tkOf, tkElif, tkElse, tkExcept}): 
+      if p.tok.tokType == tkSad: getTok(p)
+      if not (p.tok.TokType in {tkOf, tkElif, tkElse, tkExcept}): 
         addSon(result, parseStmt(p))
       while true: 
         if p.tok.tokType == tkSad: getTok(p)
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