From 9abfc60db441e6d21edbc99f0ef38075fba85f36 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 19 Apr 2015 14:25:16 +0200 Subject: parse 'of' branches for macros properly --- tests/macros/tlexerex.nim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/macros/tlexerex.nim (limited to 'tests/macros') diff --git a/tests/macros/tlexerex.nim b/tests/macros/tlexerex.nim new file mode 100644 index 000000000..d348a4bcc --- /dev/null +++ b/tests/macros/tlexerex.nim @@ -0,0 +1,16 @@ + +import macros + +macro match*(s: cstring|string; pos: int; sections: untyped): untyped = + for sec in sections.children: + expectKind sec, nnkOfBranch + expectLen sec, 2 + result = newStmtList() + +when isMainModule: + var input = "the input" + var pos = 0 + match input, pos: + of r"[a-zA-Z_]\w+": echo "an identifier" + of r"\d+": echo "an integer" + of r".": echo "something else" -- cgit 1.4.1-2-gfad0 elect> This repository contains the Nim compiler, Nim's stdlib, tools, and documentation. (mirror)ahoang <ahoang@tilde.institute>
summary refs log blame commit diff stats
path: root/tests/iter/titer10.nim
blob: 6a6afc780560fd5ef1a79cc9eab5c36ab539d7d0 (plain) (tree)