OILS / _gen / osh / arith_parse.cc View on Github | oilshell.org

129 lines, 119 significant
1#include "cpp/osh.h"
2
3using syntax_asdl::arith_expr_t;
4using syntax_asdl::word_t;
5using tdop::TdopParser;
6
7namespace tdop {
8arith_expr_t* LeftAssign(TdopParser*, word_t*, arith_expr_t*, int);
9arith_expr_t* LeftBinaryOp(TdopParser*, word_t*, arith_expr_t*, int);
10arith_expr_t* LeftError(TdopParser*, word_t*, arith_expr_t*, int);
11arith_expr_t* NullConstant(TdopParser*, word_t*, int);
12arith_expr_t* NullError(TdopParser*, word_t*, int);
13arith_expr_t* NullParen(TdopParser*, word_t*, int);
14arith_expr_t* NullPrefixOp(TdopParser*, word_t*, int);
15}
16
17namespace arith_parse {
18arith_expr_t* LeftIncDec(TdopParser*, word_t*, arith_expr_t*, int);
19arith_expr_t* LeftIndex(TdopParser*, word_t*, arith_expr_t*, int);
20arith_expr_t* LeftTernary(TdopParser*, word_t*, arith_expr_t*, int);
21arith_expr_t* NullIncDec(TdopParser*, word_t*, int);
22arith_expr_t* NullUnaryMinus(TdopParser*, word_t*, int);
23arith_expr_t* NullUnaryPlus(TdopParser*, word_t*, int);
24}
25
26namespace arith_parse {
27
28tdop::LeftInfo kLeftLookup[] = {
29 { nullptr, 0, 0 }, // empty
30 { tdop::LeftError, 0, 0 },
31 { tdop::LeftError, 0, 0 },
32 { tdop::LeftBinaryOp, 1, 1 },
33 { tdop::LeftBinaryOp, 25, 25 },
34 { tdop::LeftBinaryOp, 25, 25 },
35 { tdop::LeftBinaryOp, 27, 27 },
36 { tdop::LeftBinaryOp, 27, 27 },
37 { tdop::LeftBinaryOp, 27, 27 },
38 { arith_parse::LeftIncDec, 33, 33 },
39 { arith_parse::LeftIncDec, 33, 33 },
40 { tdop::LeftBinaryOp, 29, 28 },
41 { tdop::LeftError, 0, 0 },
42 { tdop::LeftError, 0, 0 },
43 { arith_parse::LeftIndex, 33, 33 },
44 { tdop::LeftError, 0, 0 },
45 { tdop::LeftError, 0, 0 },
46 { arith_parse::LeftTernary, 5, 4 },
47 { tdop::LeftError, 0, 0 },
48 { tdop::LeftBinaryOp, 21, 21 },
49 { tdop::LeftBinaryOp, 21, 21 },
50 { tdop::LeftBinaryOp, 21, 21 },
51 { tdop::LeftBinaryOp, 21, 21 },
52 { tdop::LeftBinaryOp, 19, 19 },
53 { tdop::LeftBinaryOp, 19, 19 },
54 { tdop::LeftBinaryOp, 9, 9 },
55 { tdop::LeftBinaryOp, 7, 7 },
56 { tdop::LeftError, 0, 0 },
57 { tdop::LeftBinaryOp, 23, 23 },
58 { tdop::LeftBinaryOp, 23, 23 },
59 { tdop::LeftBinaryOp, 15, 15 },
60 { tdop::LeftBinaryOp, 11, 11 },
61 { tdop::LeftBinaryOp, 13, 13 },
62 { tdop::LeftError, 0, 0 },
63 { tdop::LeftAssign, 3, 2 },
64 { tdop::LeftAssign, 3, 2 },
65 { tdop::LeftAssign, 3, 2 },
66 { tdop::LeftAssign, 3, 2 },
67 { tdop::LeftAssign, 3, 2 },
68 { tdop::LeftAssign, 3, 2 },
69 { tdop::LeftAssign, 3, 2 },
70 { tdop::LeftAssign, 3, 2 },
71 { tdop::LeftAssign, 3, 2 },
72 { tdop::LeftAssign, 3, 2 },
73 { tdop::LeftAssign, 3, 2 },
74 { tdop::LeftError, 0, 0 },
75 { tdop::LeftError, 0, 0 },
76};
77
78tdop::NullInfo kNullLookup[] = {
79 { nullptr, 0 }, // empty
80 { tdop::NullConstant, -1 },
81 { tdop::NullError, -1 },
82 { tdop::NullError, 0 },
83 { arith_parse::NullUnaryPlus, 31 },
84 { arith_parse::NullUnaryMinus, 31 },
85 { tdop::NullError, 0 },
86 { tdop::NullError, 0 },
87 { tdop::NullError, 0 },
88 { arith_parse::NullIncDec, 31 },
89 { arith_parse::NullIncDec, 31 },
90 { tdop::NullError, 0 },
91 { tdop::NullParen, 0 },
92 { tdop::NullError, -1 },
93 { tdop::NullError, 0 },
94 { tdop::NullError, -1 },
95 { tdop::NullError, -1 },
96 { tdop::NullError, 0 },
97 { tdop::NullError, -1 },
98 { tdop::NullError, 0 },
99 { tdop::NullError, 0 },
100 { tdop::NullError, 0 },
101 { tdop::NullError, 0 },
102 { tdop::NullError, 0 },
103 { tdop::NullError, 0 },
104 { tdop::NullError, 0 },
105 { tdop::NullError, 0 },
106 { tdop::NullPrefixOp, 31 },
107 { tdop::NullError, 0 },
108 { tdop::NullError, 0 },
109 { tdop::NullError, 0 },
110 { tdop::NullError, 0 },
111 { tdop::NullError, 0 },
112 { tdop::NullPrefixOp, 31 },
113 { tdop::NullError, 0 },
114 { tdop::NullError, 0 },
115 { tdop::NullError, 0 },
116 { tdop::NullError, 0 },
117 { tdop::NullError, 0 },
118 { tdop::NullError, 0 },
119 { tdop::NullError, 0 },
120 { tdop::NullError, 0 },
121 { tdop::NullError, 0 },
122 { tdop::NullError, 0 },
123 { tdop::NullError, 0 },
124 { tdop::NullError, -1 },
125 { tdop::NullError, -1 },
126};
127
128};
129