diff --git a/source/rock/frontend/AstBuilder.ooc b/source/rock/frontend/AstBuilder.ooc index d034a45e..8e0ed765 100644 --- a/source/rock/frontend/AstBuilder.ooc +++ b/source/rock/frontend/AstBuilder.ooc @@ -1,5 +1,5 @@ -import io/File, text/[EscapeSequence] +import io/[File, FileReader], text/[EscapeSequence], Precompiler import structs/[ArrayList, List, Stack, HashMap] @@ -18,6 +18,7 @@ import ../middle/[FunctionDecl, VariableDecl, TypeDecl, ClassDecl, CoverDecl, TemplateDef, SafeNavigation] nq_parse: extern proto func (AstBuilder, CString) -> Int +nq_memparse: extern proto func (AstBuilder, CString, Int) -> Int // reserved C99 keywords reservedWords := ["auto", "int", "long", "char", "register", "short", "do", @@ -73,7 +74,10 @@ AstBuilder: class { module addUse(Use new("system", params, module token)) - result := nq_parse(this, modulePath) + file := FileReader new(modulePath, "rb") + content := precompile(file readAll()) + file close() + result := nq_memparse(this, content toCString(), content size) if(result == -1) { Exception new(This, "File " +modulePath + " not found") throw() } diff --git a/source/rock/frontend/Precompiler.ooc b/source/rock/frontend/Precompiler.ooc new file mode 100644 index 00000000..89350f8a --- /dev/null +++ b/source/rock/frontend/Precompiler.ooc @@ -0,0 +1,4 @@ + +precompile: func(input: String) -> String { + input +}