cpp

Coverage Report

Created: 2023-03-07 20:24

/home/andy/git/oilshell/oil/cpp/pgen2.h
Line
Count
Source (jump to first uncovered line)
1
// pgen2.h
2
3
#ifndef LEAKY_PGEN2_H
4
#define LEAKY_PGEN2_H
5
6
#include "_gen/frontend/id_kind.asdl.h"
7
#include "_gen/frontend/syntax.asdl.h"
8
#include "mycpp/runtime.h"
9
10
// Hacky forward declaration for translated pgen2/pnode.py
11
// Note: it's probably better to express PNode in ASDL, like Token.
12
namespace pnode {
13
class PNode;
14
}
15
// Hacky stub
16
namespace grammar {
17
class Grammar;
18
}
19
20
namespace parse {
21
22
class ParseError {
23
 public:
24
  ParseError(Str* msg, int type_, syntax_asdl::Token* tok);
25
26
  Str* msg;
27
  syntax_asdl::Token* tok;
28
  int type;
29
};
30
31
class Parser {
32
 public:
33
  // In C, the grammar is a constant, so the grammar arg is ignored.  (We can't
34
  // get easily rid of it because the call site has to type check and run in
35
  // Python.)
36
0
  explicit Parser(grammar::Grammar* grammar) {
37
0
  }
38
  void setup(int start);
39
  bool addtoken(int typ, syntax_asdl::Token* opaque, int ilabel);
40
41
  // Probably should delete these
42
  // void shift(int typ, syntax_asdl::Token* opaque, int newstate);
43
  // void push(int typ, syntax_asdl::Token* opaque, Tuple2<List<List<Tuple2<int,
44
  // int>*>*>*, Dict<int, int>*>* newdfa, int newstate);  void pop();
45
46
  // grammar::Grammar* grammar;
47
  pnode::PNode* rootnode;
48
  // List<parse::_StackItem*>* stack;
49
};
50
51
}  // namespace parse
52
53
#endif  // LEAKY_PGEN2_H