@@ -511,27 +511,29 @@ proc lineInfo*(arg: NimNode): string =
511511 # # Return line info in the form `filepath(line, column)`.
512512 $ arg.lineInfoObj
513513
514- proc internalParseExpr (s: string ): NimNode {.
514+ proc internalParseExpr (s, filename : string ): NimNode {.
515515 magic : " ParseExprToAst" , noSideEffect .}
516516
517- proc internalParseStmt (s: string ): NimNode {.
517+ proc internalParseStmt (s, filename : string ): NimNode {.
518518 magic : " ParseStmtToAst" , noSideEffect .}
519519
520520proc internalErrorFlag * (): string {.magic : " NError" , noSideEffect .}
521521 # # Some builtins set an error flag. This is then turned into a proper
522522 # # exception. **Note**: Ordinary application code should not call this.
523523
524- proc parseExpr * (s: string ): NimNode {.noSideEffect .} =
524+ proc parseExpr * (s: string ; filename: string = " " ): NimNode {.noSideEffect .} =
525525 # # Compiles the passed string to its AST representation.
526526 # # Expects a single expression. Raises `ValueError` for parsing errors.
527- result = internalParseExpr (s)
527+ # # A filename can be given for more informative errors.
528+ result = internalParseExpr (s, filename)
528529 let x = internalErrorFlag ()
529530 if x.len > 0 : raise newException (ValueError , x)
530531
531- proc parseStmt * (s: string ): NimNode {.noSideEffect .} =
532+ proc parseStmt * (s: string ; filename: string = " " ): NimNode {.noSideEffect .} =
532533 # # Compiles the passed string to its AST representation.
533534 # # Expects one or more statements. Raises `ValueError` for parsing errors.
534- result = internalParseStmt (s)
535+ # # A filename can be given for more informative errors.
536+ result = internalParseStmt (s, filename)
535537 let x = internalErrorFlag ()
536538 if x.len > 0 : raise newException (ValueError , x)
537539
0 commit comments