Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- expr : expr[ var_name ] '+' ident[ other_var_name ] ( some_action(var_name, other_var_name)) | ident[ third_var ] (some_other_action(third_var))
- std::wstring ShiftIdent() {
- auto ident = current_token->codepoints; // for example
- current_token++;
- return ident;
- }
- void ShiftPlus() {
- current_token++;
- }
- T ShiftExpr() {
- T t;
- switch(current_token->type) {
- case ident:
- auto internal_var = ShiftIdent();
- while(true) {
- switch(current_token->type) {
- case '+':
- ShiftPlus();
- switch(current_token->type) {
- case ident:
- auto&& other_var_name = ShiftIdent();
- {
- auto&& other_var_name = internal_var;
- auto&& var_name = t;
- t = some_action(var_name, other_var_name));
- };
- break;
- default:
- error();
- }
- break;
- default:
- {
- auto&& third_var = internal_var;
- return some_other_action(third_var);
- }
- };
- }
- break;
- default:
- error();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement