ttryparseexpr.nim 433 B

12345678910111213141516171819202122232425
  1. discard """
  2. outputsub: '''Error: expression expected, but found '[EOF]' 45'''
  3. """
  4. # feature request #1473
  5. import macros
  6. macro test(text: string): untyped =
  7. try:
  8. result = parseExpr(text.strVal)
  9. except ValueError:
  10. result = newLit getCurrentExceptionMsg()
  11. const
  12. valid = 45
  13. a = test("foo&&")
  14. b = test("valid")
  15. c = test("\"") # bug #2504
  16. echo a, " ", b
  17. static:
  18. # Issue #9918
  19. discard parseStmt("echo(1+1);")