View difference between Paste ID: d0Ued173 and s0BdikJQ
SHOW: | | - or go back to the newest paste.
1
expr : expr[ var_name ] '+' ident[ other_var_name ] ( some_action(var_name, other_var_name)) | ident[ third_var ] (some_other_action(third_var))
2
3
std::wstring ShiftIdent() {
4
    auto ident = current_token->codepoints; // for example
5
    current_token++;
6
    return ident;
7
}
8
9
void ShiftPlus() {
10
    current_token++;
11
}
12
13
T ShiftExpr() {
14
    T t;
15
    switch(current_token->type) {
16
    case ident:
17
        auto internal_var = ShiftIdent();
18
        {
19
            auto&& third_var = internal_var;
20
            t = some_other_action(third_var);
21
        }
22
        while(true) {
23
            switch(current_token->type) {
24
            case '+':
25
                ShiftPlus();
26
                switch(current_token->type) {
27
                case ident:
28
                    auto&& other_var_name = ShiftIdent();
29
                    {
30
                        auto&& var_name = t;
31
                        t = some_action(var_name, other_var_name));
32
                    };
33
                    continue;
34
                default:
35
                    error();
36
                }
37
            case end:
38
                break;
39
            default:
40
                error();
41
            };
42
        }
43
        break;
44
    default:
45
        error();
46
    }
47
    return std::move(t);
48
}