Little break work on grammer, added Object trait to other stdlib objects

This commit is contained in:
Nathan Braswell
2015-06-30 02:40:46 -04:00
parent 91f801d14f
commit 2fcace72ed
7 changed files with 41 additions and 7 deletions

34
stdlib/grammer.krak Normal file
View File

@@ -0,0 +1,34 @@
import string
import vector
import set
import symbol
obj rule (Object) {
var lhs: symbol::symbol
var rhs: vector::vector<symbol::symbol>
var position: int
var lookahead: set::set<symbol::symbol>
fun construct(): rule* {
lhs.construct()
rhs.construct()
position = 0
lookahead.construct()
}
fun copy_construct(old: rule*) {
lhs.copy_construct(&rule->lhs)
rhs.copy_construct(&rule->rhs)
position = rule->position
lookahead.copy_construct(&rule->lookahead)
}
fun operator=(other: rule) {
destruct()
copy_construct(&other)
}
fun destruct() {
lhs.destruct()
rhs.destruct()
lookahead.destruct()
}
}