Fixed add_children to actually add children correctly and only do the ambiguity at the right time. Still have the looking in map with non-existant key problem, but it is actually parsing nicely.

This commit is contained in:
Nathan Braswell
2015-08-12 23:15:41 -04:00
parent 8321b35a03
commit 4b6693ac1c
8 changed files with 84 additions and 36 deletions

View File

@@ -1,11 +1,12 @@
# comment
Goal = a ;
a = b | rec ;
a = b | rec "end" ;
b = "c":named_c ;
b = c "d":dname ;
c = "a" | d ;
d = e post_null post_non_null inherit_null ;
inherit_null = e | post_non_null ;
e = ;
e = f | ;
f = ;
post_null = "hi" ;

View File

@@ -52,11 +52,12 @@ fun main():int {
println(a.to_string())
a.calculate_state_automaton()
var parse.construct(a): parser
var result = parse.parse_input(string("inport a;"), string("fun name"))
var result = parse.parse_input(read_file(string("to_parse.krak")), string("fun name"))
/*var result = parse.parse_input(string("inport a;"), string("fun name"))*/
/*var result = parse.parse_input(string("fun main():int { return 0; }"), string("fun name"))*/
/*var result = parse.parse_input(string("ad"), string("fun name"))*/
/*var result = parse.parse_input(string("hibyed"), string("fun name"))*/
/*var result = parse.parse_input(string("hmmhmm"), string("fun name"))*/
/*var result = parse.parse_input(string("hmmhmmend"), string("fun name"))*/
/*var result = parse.parse_input(string("hid"), string("fun name"))*/
println("the tree")
println(syntax_tree_to_dot(result))

5
tests/to_parse.krak Normal file
View File

@@ -0,0 +1,5 @@
fun main(): int {
return 0
}