summaryrefslogtreecommitdiff
path: root/cli/parser.hxx
blob: f09816f60c81d06259ac2275a0a884b48cc177fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// file      : cli/parser.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#ifndef CLI_PARSER_HXX
#define CLI_PARSER_HXX

#include <string>
#include <istream>

class token;
class lexer;

class parser
{
public:
  struct invalid_input {};

  void
  parse (std::istream& is, std::string const& id);

private:
  struct error {};

  void
  def_unit ();

  void
  include_decl ();

  bool
  decl (token&);

  void
  namespace_def ();

  void
  class_def ();

  bool
  option_def (token&);

  bool
  qualified_name (token&);

  bool
  fundamental_type (token&);

private:
  void
  recover (token& t);

private:
  bool valid_;
  lexer* lexer_;
  std::string const* id_;
};

#endif // CLI_PARSER_HXX