Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions source/rock/frontend/AstBuilder.ooc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import io/File, text/[EscapeSequence]
import io/[File, FileReader], text/[EscapeSequence], Precompiler

import structs/[ArrayList, List, Stack, HashMap]

Expand All @@ -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",
Expand Down Expand Up @@ -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()
}
Expand Down
4 changes: 4 additions & 0 deletions source/rock/frontend/Precompiler.ooc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

precompile: func(input: String) -> String {
input
}