Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created June 13, 2015 13:45
Show Gist options
  • Save taotetek/173cc40c372c8b43217b to your computer and use it in GitHub Desktop.
Save taotetek/173cc40c372c8b43217b to your computer and use it in GitHub Desktop.
import os, streams, parsexml, strutils, macros
macro readModelAndBuildAST(filename: string): stmt =
let
inputString = slurp(filename.strVal)
var s = newStringStream(inputString)
var x: XmlParser
open(x, s, filename)
next(x)
while true:
case x.kind
of xmlEof: break
of xmlElementOpen, xmlElementStart:
case x.elementName
of "constant":
x.next
echo x.attrKey
echo x.attrValue
x.next
echo x.attrKey
echo x.attrValue
else: discard
else: discard
next(x)
parse.nim(9, 9) Error: type mismatch: got (XmlParser, StringStream, NimNode)
but expected one of:
system.open(f: var File, filename: string, mode: FileMode, bufSize: int)
parsexml.open(my: var XmlParser, input: Stream, filename: string, options: set[XmlParseOption])
system.open(f: var File, filehandle: FileHandle, mode: FileMo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment