Skip to content

Instantly share code, notes, and snippets.

@bluenote10
Created May 13, 2015 10:21
Show Gist options
  • Save bluenote10/3787977625e6bf63e6af to your computer and use it in GitHub Desktop.
Save bluenote10/3787977625e6bf63e6af to your computer and use it in GitHub Desktop.
MacroStringParseTest
macro stringParseTest(s: string): stmt =
let trueString = s.strVal
let ne = parseExpr(trueString)
let ns = parseStmt(trueString)
echo treeRepr(ne)
echo treeRepr(ns)
# looking good:
# Infix
# Ident !"+"
# Ident !"y"
# IntLit 1
#
# But how to get the type of the parsed node here? (int in the example)
# even ns.getType yields Error: node has no type
# let t = ns.getType
# echo "Type is: ", t.repr
result = quote do:
echo "does nothing"
var y = 1
stringParseTest("y+1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment