Some more work, and a --parse-only option to support the new kraken.vim vim plugin that adds Syntastic support (and syntax highlighting)

This commit is contained in:
Nathan Braswell
2015-07-03 18:34:46 -04:00
parent 2fcace72ed
commit b62c3e729f
12 changed files with 155 additions and 58 deletions

View File

@@ -2,6 +2,29 @@ import string
import vector
import set
import symbol
import regex
obj grammer (Object) {
var rules: vector::vector<rule>
var regexs: set::set<regex>
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
@@ -16,10 +39,10 @@ obj rule (Object) {
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)
lhs.copy_construct(&other->lhs)
rhs.copy_construct(&other->rhs)
position = other->position
lookahead.copy_construct(&other->lookahead)
}
fun operator=(other: rule) {
destruct()

View File

@@ -1,4 +1,4 @@
import string:*;
import string;
import mem:*
__if_comp__ __C__ simple_passthrough """
@@ -32,7 +32,7 @@ fun print(toPrint: char) : void {
return;
}
fun print(toPrint: string) : void {
fun print(toPrint: string::string) : void {
var charArr = toPrint.toCharArray()
defer delete(charArr)
print(charArr);
@@ -73,3 +73,29 @@ fun print(toPrint: double) : void{
return;
}
// Ok, just some DEAD simple file io for now
fun read_file(path: string::string): string::string {
var char_path = path.toCharArray()
defer delete(char_path)
var data: char*
__if_comp__ __C__ {
simple_passthrough(char_path = char_path:data = data:) """
FILE *fp = fopen(char_path, "r");
fseek(fp, 0L, SEEK_END);
long size = ftell(fp);
fseek(fp, 0L, SEEK_SET);
char *data = malloc(size+1);
size_t readSize = fread(data, 1, size, fp);
data[readSize] = 0;
fclose(fp);
"""
}
var toRet = string::string(data)
__if_comp__ __C__ {
simple_passthrough(data = data::) """
free(data)
"""
}
return toRet
}