Skip to content

Commit

Permalink
Read .use files in a simpler way
Browse files Browse the repository at this point in the history
  • Loading branch information
nddrylliog committed Feb 20, 2013
1 parent bcd5f99 commit ea99866
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions source/rock/middle/UseDef.ooc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import io/[File, FileReader]

// sdk stuff
import io/[File, FileReader, StringReader]
import structs/[List, ArrayList, HashMap]
import text/StringTokenizer

// our stuff
import ../frontend/BuildParams

/**
Expand Down Expand Up @@ -206,29 +209,18 @@ UseDef: class {
if(params veryVerbose) ("Reading use file " + file path) println()

while(reader hasNext?()) {
reader mark()
c := reader read()
line := reader readLine() trim(8 as Char /* backspace */) trim(0 as Char /* null byte */)

if(c == '\t' || c == ' ' || c == '\r' || c == '\n' || c == '\v') {
if(line empty?() || line startsWith?('#')) {
// skip comments
continue
}

if(c == '#') {
reader readUntil('\n')
continue
}
lineReader := StringReader new(line)
id := lineReader readUntil(':')
value := lineReader readAll() trim()

if(c == '=') {
// TODO: wasn't that used for platform-specific usefiles?
reader skipLine()
continue
}

reader rewind(1)
id := reader readUntil(':')
id = id trim() trim(8 as Char /* backspace */) trim(0 as Char /* null-character */)

value := reader readLine() trim()
"%s: %s" printfln(id, value)

if(id startsWith?("_")) {
// reserved ids for external tools (packaging, etc.)
Expand Down

0 comments on commit ea99866

Please sign in to comment.