1 | // Replacement for osh/arith_parse
|
2 |
|
3 | #ifndef FRONTEND_TDOP_H
|
4 | #define FRONTEND_TDOP_H
|
5 |
|
6 | #include "_gen/frontend/id_kind.asdl.h"
|
7 | #include "_gen/frontend/syntax.asdl.h"
|
8 |
|
9 | using id_kind_asdl::Id_t;
|
10 | using syntax_asdl::arith_expr_t;
|
11 | using syntax_asdl::word_t;
|
12 |
|
13 | namespace tdop {
|
14 |
|
15 | class TdopParser; // forward declaration
|
16 |
|
17 | typedef arith_expr_t* (*LeftFunc)(TdopParser*, word_t*, arith_expr_t*, int);
|
18 | typedef arith_expr_t* (*NullFunc)(TdopParser*, word_t*, int);
|
19 |
|
20 | struct LeftInfo {
|
21 | LeftFunc led;
|
22 | int lbp;
|
23 | int rbp;
|
24 |
|
25 | DISALLOW_COPY_AND_ASSIGN(LeftInfo)
|
26 | };
|
27 |
|
28 | struct NullInfo {
|
29 | NullFunc nud;
|
30 | int bp;
|
31 |
|
32 | DISALLOW_COPY_AND_ASSIGN(NullInfo)
|
33 | };
|
34 |
|
35 | class ParserSpec {
|
36 | public:
|
37 | // No fields
|
38 | ParserSpec() {
|
39 | }
|
40 | LeftInfo* LookupLed(Id_t id);
|
41 | NullInfo* LookupNud(Id_t id);
|
42 |
|
43 | static constexpr ObjHeader obj_header() {
|
44 | return ObjHeader::ClassFixed(kZeroMask, sizeof(ParserSpec));
|
45 | }
|
46 |
|
47 | DISALLOW_COPY_AND_ASSIGN(ParserSpec)
|
48 | };
|
49 |
|
50 | } // namespace tdop
|
51 |
|
52 | #endif // FRONTEND_TDOP_H
|