import string import vector import set import symbol import regex obj grammer (Object) { var rules: vector::vector var regexs: set::set fun construct(): grammer* { rules.construct() regexs.construct() } fun copy_construct(old: grammer*) { rules.copy_construct(&old->rules) regexs.copy_construct(&old->regexs) } fun operator=(other: grammer) { destruct() copy_construct(&other) } fun destruct() { rules.destruct() regexs.destruct() } } obj rule (Object) { var lhs: symbol::symbol var rhs: vector::vector var position: int var lookahead: set::set fun construct(): rule* { lhs.construct() rhs.construct() position = 0 lookahead.construct() } fun copy_construct(old: rule*) { lhs.copy_construct(&other->lhs) rhs.copy_construct(&other->rhs) position = other->position lookahead.copy_construct(&other->lookahead) } fun operator=(other: rule) { destruct() copy_construct(&other) } fun destruct() { lhs.destruct() rhs.destruct() lookahead.destruct() } }