Basic AST

This commit is contained in:
Nathan Braswell
2018-06-18 19:04:24 -04:00
parent e898e7b285
commit b5ce776726
6 changed files with 274 additions and 9 deletions

View File

@@ -88,6 +88,15 @@ fun operator+(first: *char, second: ref str): str {
fun operator+(first: int, second: ref str): str {
return to_string(first) + second
}
fun operator*(first: *char, second: int): str {
return str(first) * second
}
fun operator*(first: int, second: *char): str {
return str(second) * first
}
fun operator*(first: int, second: ref str): str {
return second * first
}
fun str(in:*char):str {
var out.construct(in):str
@@ -191,6 +200,13 @@ obj str (Object, Serializable, Hashable) {
return *this == str
}
fun operator*(n: int): str {
var to_ret.construct(): str
while (n-- > 0)
to_ret += *this
return to_ret
}
fun operator+(c: char): str {
var to_ret = *this
to_ret += c