Skip to content

Instantly share code, notes, and snippets.

@satouuta0
Created August 26, 2013 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satouuta0/6341059 to your computer and use it in GitHub Desktop.
Save satouuta0/6341059 to your computer and use it in GitHub Desktop.
tree* varref(string program, parse* opthion){
tree* vname = name(program, option);
if(option->error) return vname;
return new varref_tree(vname);
}
@satouuta0
Copy link
Author

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])

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment