~ehmry/dhall-nim

b490366099baa9888129409ec4864b9f079163b5 — Emery Hemingway 9 months ago b371b05 staging
Add main proc to parser
1 files changed, 22 insertions(+), 0 deletions(-)

M src/dhall/parse.nim
M src/dhall/parse.nim => src/dhall/parse.nim +22 -0
@@ 880,3 880,25 @@ proc parseDhall*(code: string): Term {.gcsafe.} =
    raise newException(ValueError, "failed to parse Dhall expression")
  assert(stack.len == 1, "parser did not backtrack during match")
  pop()

when isMainModule:
  import ./binary, ./render, ./resolution
  import std/nimprof, std/times
  let buf = stdin.readAll
  if buf != "":
    let
      a = cpuTime()
      term = parseDhall(buf)
      b = cpuTime()
    echo "parse time: ", b - a
    let
      c = cpuTime()
      bin = term.encode
      d = cpuTime()
    echo "encode time: ", d - c
    let
      e = cpuTime()
      dec = bin.decodeDhall
      f = cpuTIme()
    echo "decode time: ", f - e
    stdout.write $term.semanticHash, "\n"