-
|
Title, essentially. Lets say I have a source code slice in memory. I saw |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The minimal steps to turn a source buffer into an AST would look something like this: var comp = aro.Compilation.initDefault(gpa, std.fs.cwd());
defer comp.deinit();
const your_source = try comp.addSourceFromBuffer("<your buffer>", your_buffer);
const builtin = try comp.generateBuiltinMacros(.include_system_defines, null);
var pp = try aro.Preprocessor.initDefault(&comp);
defer pp.deinit();
try pp.preprocessSources(&.{ source, builtin });
var tree = try pp.parse();
defer tree.deinit(); |
Beta Was this translation helpful? Give feedback.
Compilationtakes a folder that should be used as cwd, it should probably use aDriver.Filesystemto provide even better encapsulation withFilesystem.fake. Easiest way to get aCompilationis to just pass itstd.fs.cwd(). Then you can useCompilation.addSourceFromBuffer()to turn your[]u8into aSoucethat can be passed toPreprocessor.preprocessSources().The minimal steps to turn a source buffer into an AST would look something like this: