Skip to content
Discussion options

You must be logged in to vote

Compilation takes a folder that should be used as cwd, it should probably use a Driver.Filesystem to provide even better encapsulation with Filesystem.fake. Easiest way to get a Compilation is to just pass it std.fs.cwd(). Then you can use Compilation.addSourceFromBuffer() to turn your []u8 into a Souce that can be passed to Preprocessor.preprocessSources().

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

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@heysokam
Comment options

Answer selected by heysokam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants