summary refs log blame commit diff stats
path: root/tests/compile/tmacrostmt.nim
blob: 69b49f692cb47dd6e61344fade4d8df5bb24fb19 (plain) (tree)
1
2
             
                                               














                                                                 
import macros
macro case_token(n: stmt): stmt {.immediate.} =
  # 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