@@ -516,27 +516,29 @@ proc lineInfo*(arg: NimNode): string =
516516 # # Return line info in the form `filepath(line, column)`.
517517 $ arg.lineInfoObj
518518
519- proc internalParseExpr (s: string ): NimNode {.
519+ proc internalParseExpr (s, filename : string ): NimNode {.
520520 magic : " ParseExprToAst" , noSideEffect .}
521521
522- proc internalParseStmt (s: string ): NimNode {.
522+ proc internalParseStmt (s, filename : string ): NimNode {.
523523 magic : " ParseStmtToAst" , noSideEffect .}
524524
525525proc internalErrorFlag * (): string {.magic : " NError" , noSideEffect .}
526526 # # Some builtins set an error flag. This is then turned into a proper
527527 # # exception. **Note**: Ordinary application code should not call this.
528528
529- proc parseExpr * (s: string ): NimNode {.noSideEffect .} =
529+ proc parseExpr * (s: string ; filename: string = " " ): NimNode {.noSideEffect .} =
530530 # # Compiles the passed string to its AST representation.
531531 # # Expects a single expression. Raises `ValueError` for parsing errors.
532- result = internalParseExpr (s)
532+ # # A filename can be given for more informative errors.
533+ result = internalParseExpr (s, filename)
533534 let x = internalErrorFlag ()
534535 if x.len > 0 : raise newException (ValueError , x)
535536
536- proc parseStmt * (s: string ): NimNode {.noSideEffect .} =
537+ proc parseStmt * (s: string ; filename: string = " " ): NimNode {.noSideEffect .} =
537538 # # Compiles the passed string to its AST representation.
538539 # # Expects one or more statements. Raises `ValueError` for parsing errors.
539- result = internalParseStmt (s)
540+ # # A filename can be given for more informative errors.
541+ result = internalParseStmt (s, filename)
540542 let x = internalErrorFlag ()
541543 if x.len > 0 : raise newException (ValueError , x)
542544
0 commit comments