Fix nested closures and related bugs

This commit is contained in:
Nathan Braswell
2015-07-05 02:34:45 -04:00
parent d44ce47d1e
commit cfadf7cebb
13 changed files with 101 additions and 56 deletions

View File

@@ -34,17 +34,23 @@ fun load_grammer(path: string::string): grammer {
/*io::print("parts: ")*/
/*parts.for_each(fun(i :string::string){ io::print(i); io::print(" "); })*/
/*io::println()*/
gram.rules.add(rule(symbol::symbol(parts[0], true),
parts.slice(1,-1).map(fun(i: string::string):symbol::symbol {
return symbol::symbol(i, true);
})
))
/*gram.rules.add(rule(symbol::symbol(parts[0], true),*/
/*parts.slice(1,-1).map(fun(i: string::string):symbol::symbol {*/
/*return symbol::symbol(i, true);*/
/*})*/
/*))*/
var rightSide = vector::vector<symbol::symbol>()
parts.slice(1,-1).for_each( fun(part: string::string) {
if (part == "|") {
gram.rules.add(rule(symbol::symbol(parts[0], false), rightSide))
rightSide = vector::vector<symbol::symbol>()
} else {
rightSide.add(symbol::symbol(part, part[0] == '"'))
}
})
gram.rules.add(rule(symbol::symbol(parts[0], false), rightSide))
})
/*gram.rules.add(rule(symbol::symbol("test", true), vector::vector(symbol::symbol("rhs", true))))*/
/*gram.rules.add(rule(symbol::symbol("lhs", true), vector::vector(symbol::symbol("rhs2", true))))*/
/*gram.regexs.add(regex::regex("reg"))*/
return gram
}

View File

@@ -68,6 +68,10 @@ obj string (Object) {
fun operator==(other: string): bool {
return length() == other.length() && !util::range(length()).any_true(fun(i: int):bool { return data[i] != other[i]; } )
}
fun operator==(other: *char): bool {
var str.construct(other) : string
return *this == str
}
fun operator+(str: *char): string {
var newStr.construct(str):string