Skip to content

Commit

Permalink
Fixed all other tests. Enjoy
Browse files Browse the repository at this point in the history
  • Loading branch information
nddrylliog committed Oct 1, 2010
1 parent 89fff8f commit cfce3af
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions step3/decadence.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import structs/ArrayList

// decadenceParser now takes the Parser instance as an argument
// and now also the path of the file to parse.
decadenceParse: extern proto func (this: Parser, path: String)
decadenceParse: extern proto func (this: Parser, path: CString)

main: func (args: ArrayList<String>) -> Int {

if(args size() < 2) {
if(args size < 2) {
"Syntax: %s FILE" printfln(args[0])
return 1
}
Expand Down
4 changes: 2 additions & 2 deletions step5/ast/BinaryOp.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ BinaryOp: class extends Expr {
left, right: Expr

init: func (=type, =left, =right) {
"[%s] %s" printfln(class name, toString())
"[%s] %s" printfln(class name toCString(), toString() toCString())
}

toString: func -> String {
"%s %s %s" format(left toString(), type, right toString())
"%s %s %s" format(left toString() toCString(), type toCString(), right toString() toCString())
}

}
2 changes: 1 addition & 1 deletion step5/ast/Number.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Number: class extends Expr {
value: LLong

init: func (=value) {
"[%s] %s" printfln(class name, toString())
"[%s] %s" printfln(class name toCString(), toString() toCString())
}

toString: func -> String {
Expand Down
2 changes: 1 addition & 1 deletion step5/ast/Program.ooc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import structs/ArrayList, text/Buffer
import structs/ArrayList
import Expr

/**
Expand Down
14 changes: 7 additions & 7 deletions step5/decadence.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Parser: class {
decadenceParse(this, path)
}

gotNumber: unmangled func (number: String) -> Number {
Number new(number toLLong())
gotNumber: unmangled func (number: CString) -> Number {
Number new(number toString() toLLong())
}

gotBinaryOp: unmangled func (type: String, left, right: Expr) -> BinaryOp {
BinaryOp new(type clone(), left, right)
gotBinaryOp: unmangled func (type: CString, left, right: Expr) -> BinaryOp {
BinaryOp new(type toString() clone(), left, right)
}

onExpr: unmangled func (e: Expr) {
Expand All @@ -32,14 +32,14 @@ Parser: class {

}

stringClone: unmangled func (s: String) -> String { s clone() }
stringClone: unmangled func (s: CString) -> CString { s clone() }

// decadenceParser's prototype
decadenceParse: extern proto func (this: Parser, path: String)
decadenceParse: extern proto func (this: Parser, path: CString)

// entry point
main: func (args: ArrayList<String>) -> Int {
if(args size() < 2) {
if(args size < 2) {
"Syntax: %s FILE" printfln(args[0])
return 1
}
Expand Down
6 changes: 3 additions & 3 deletions step6/source/Backend.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Backend: class implements Visitor {
(output, exitCode) := Process new(["gcc", "-o", name, name + ".c"]) getOutput()
output print()
if(exitCode == 0) {
"Done! Executable is in %s. Have fun!" printfln(name)
"Done! Executable is in %s. Have fun!" printfln(name toCString())
} else {
"Failed :(\nKeeping %s around for inspection." printfln(name + ".c")
"Failed :(\nKeeping %s around for inspection." printfln((name + ".c") toCString())
}
}

Expand All @@ -44,7 +44,7 @@ Backend: class implements Visitor {

visitBinaryOp: func (b: BinaryOp) {
b left accept(this)
fw writef(" %s ", b type)
fw writef(" %s ", b type toCString())
b right accept(this)
}

Expand Down
12 changes: 6 additions & 6 deletions step6/source/Parser.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Parser: class {
decadenceParse(this, path)
}

gotNumber: unmangled func (number: String) -> Number {
Number new(number toLLong())
gotNumber: unmangled func (number: CString) -> Number {
Number new(number toString() toLLong())
}

gotBinaryOp: unmangled func (type: String, left, right: Expr) -> BinaryOp {
BinaryOp new(type clone(), left, right)
gotBinaryOp: unmangled func (type: CString, left, right: Expr) -> BinaryOp {
BinaryOp new(type clone() toString(), left, right)
}

onExpr: unmangled func (e: Expr) {
Expand All @@ -31,7 +31,7 @@ Parser: class {

}

stringClone: unmangled func (s: String) -> String { s clone() }
stringClone: unmangled func (s: CString) -> CString { s clone() }

// decadenceParser's prototype
decadenceParse: extern proto func (this: Parser, path: String)
decadenceParse: extern proto func (this: Parser, path: CString)
2 changes: 1 addition & 1 deletion step6/source/ast/BinaryOp.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BinaryOp: class extends Expr {
init: func (=type, =left, =right) {}

toString: func -> String {
"%s %s %s" format(left toString(), type, right toString())
"%s %s %s" format(left toString() toCString(), type toCString(), right toString() toCString())
}

accept: func (v: Visitor) {
Expand Down
2 changes: 1 addition & 1 deletion step6/source/ast/Program.ooc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import structs/ArrayList, text/Buffer
import structs/ArrayList
import Expr, Visitor

/**
Expand Down
4 changes: 2 additions & 2 deletions step6/source/decadence.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import ast/Program, Parser, Backend

// entry point
main: func (args: ArrayList<String>) -> Int {
if(args size() < 2) {
"Syntax: %s FILE" printfln(args[0])
if(args size < 2) {
"Syntax: %s FILE" printfln(args[0] toCString())
return 1
}

Expand Down
2 changes: 1 addition & 1 deletion step7/source/Parser.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Parser: class {
}

gotAssignment: unmangled func (left: CString, right: Expr) -> Assignment {
Assignment new(left toString() clone(), right)
Assignment new(left clone() toString(), right)
}

gotVariableAccess: unmangled func (name: CString) -> VariableAccess {
Expand Down
2 changes: 1 addition & 1 deletion step7/source/ast/Assignment.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Assignment: class extends Node {
init: func (=left, =right) {}

toString: func -> String {
"%s = %s" format(left, right toString())
"%s = %s" format(left toCString(), right toString() toCString())
}

accept: func (v: Visitor) {
Expand Down
2 changes: 1 addition & 1 deletion step7/source/ast/BinaryOp.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BinaryOp: class extends Expr {
init: func (=type, =left, =right) {}

toString: func -> String {
"%s %s %s" format(left toString(), type, right toString())
"%s %s %s" format(left toString() toCString(), type toCString(), right toString() toCString())
}

accept: func (v: Visitor) {
Expand Down
2 changes: 1 addition & 1 deletion step7/source/decadence.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ast/Program, Parser, Backend
// entry point
main: func (args: ArrayList<String>) -> Int {
if(args size < 2) {
("Syntax: "+args[0]+ " FILE") println()
("Syntax: " + args[0] + " FILE") println()
return 1
}

Expand Down
1 change: 1 addition & 0 deletions step7/tests/number.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
1 change: 1 addition & 0 deletions step7/tests/plus.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 + 2

0 comments on commit cfce3af

Please sign in to comment.