# @Chronos [She/Her] figured I could ping+paste, since you mentioned you were # doing some experimenting with the compiler: import "$nim"/compiler/[ ast, parser, options, msgs, idents, pathutils, syntaxes ] proc readAST (file :string) :ast.PNode= var conf = options.newConfigRef() let fileIdx = msgs.fileInfoIdx(conf, pathutils.AbsoluteFile file) var pars :parser.Parser if syntaxes.setupParser(pars, fileIdx, idents.newIdentCache(), conf): result = parser.parseAll(pars) parser.closeParser(pars) # This is all it takes to read a file and return an AST in the exact shape that # the compiler has internally# Instead of building the entire compiler+vm+etc, it takes about 2s to compile # these imports # Thought you might find it useful for your experiments too✍️