OILS / cpp / osh_tdop.h View on Github | oilshell.org

52 lines, 32 significant
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
9using id_kind_asdl::Id_t;
10using syntax_asdl::arith_expr_t;
11using syntax_asdl::word_t;
12
13namespace tdop {
14
15class TdopParser; // forward declaration
16
17typedef arith_expr_t* (*LeftFunc)(TdopParser*, word_t*, arith_expr_t*, int);
18typedef arith_expr_t* (*NullFunc)(TdopParser*, word_t*, int);
19
20struct LeftInfo {
21 LeftFunc led;
22 int lbp;
23 int rbp;
24
25 DISALLOW_COPY_AND_ASSIGN(LeftInfo)
26};
27
28struct NullInfo {
29 NullFunc nud;
30 int bp;
31
32 DISALLOW_COPY_AND_ASSIGN(NullInfo)
33};
34
35class 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