Aha, I just had to install `nimble install compiler`. Otherwise it did not find the package `compiler/parser`: $ cat parse_nimcode.nim import compiler/parser ... $ nim c -r parse_nimcode.nim Hint: used config file '/.../.local/nim/config/nim.cfg' [Conf] Hint: used config file '/.../.local/nim/config/config.nims' [Conf] ...................................................................... /.../parse_nimcode.nim(1, 16) Error: cannot open file: compiler/parser Run
But now it complains about a mismatch: import compiler/parser let code_string: string = "echo \"Hello world!\"" let code_ast = parseString(code_string) echo code_ast Run $ nim c -r parse_nimcode.nim ... /.../parse_nimcode.nim(7, 25) Error: type mismatch Expression: parseString(code_string) [1] code_string: string Expected one of (first mismatch at [position]): [2] proc parseString(s: string; cache: IdentCache; config: ConfigRef; filename: string = ""; line: int = 0; errorHandler: ErrorHandler = nil): PNode Run It probably needs those `cache: IdentCache` and `config: ConfigRef` in the arguments.