Created
August 26, 2013 12:45
-
-
Save satouuta0/6341059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tree* varref(string program, parse* opthion){ | |
tree* vname = name(program, option); | |
if(option->error) return vname; | |
return new varref_tree(vname); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
int while_stmt(string program, parse option){
int old_index = option->index;
if(program.substr(option->index, 5) != "while"){
option->error = 1;
return 0;
}
option->index += 5;
int cond = expr1(program, option);
if(program[option->index] != ':'){
option->error = 1;
option->index = old_index;
return 0;
}
skips(program, option);
int stmt = block(program, option);
if(program.substr(option->index, 3) != "end"){
option->error = 1;
option->index = old_index;
return 0;
}
return 0;//TODO
}
int for_stmt(string program, parse option){
int old_index = option->index;
if(program.substr(option->index, 3) != "for"){
option->error = 1;
return 0;
}
option->index += 3;
name(program, option);
if(program.substr(option->index, 2) != "in"){
option->error = 1;
option->index = old_index;
return 0;
}
option->index += 2;
int cond = expr1(program, option);
if(program[option->index] != ':'){
option->error = 1;
option->index = old_index;
return 0;
}
skips(program, option);
int stmt1 = block(program, option);
if(program.substr(option->index, 3) != "end"){
option->error = 1;
option->index = old_index;
return 0;
}
return 0;//TODO
}
/*
match [expr]:
if [expr1]:
[shori...]
if [expr2]:
[shori...]
else:
[shori...]
end
/
int match_stmt(string program, parse option){
int old_index = option->index;
if(program.substr(option->index, 5) != "match"){
option->error = 1;
return 0;
}
opthion->index += 5;
int expr;
if(program[2])
}