NEST  2.6.0,not_revisioned_source_dir@0
parser.h
Go to the documentation of this file.
1 /*
2  * parser.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef PARSER_H
24 #define PARSER_H
25 /*
26  SLI's parser.
27 */
28 
29 #include <typeinfo>
30 #include <iostream>
31 #include "token.h"
32 #include "tokenstack.h"
33 
34 
35 class Scanner;
36 
37 class Parser
38 {
40 
44 
45  enum ParseResult {
54  };
55 
56  void init(std::istream &);
57 
58 public:
59  Parser(void);
60  Parser(std::istream &);
61 
62  bool operator()(Token&);
63  bool readToken(std::istream &is, Token &t)
64  {
65  s->source(&is);
66  return operator()(t);
67  }
68 
69  bool readSymbol(std::istream &is, Token &t)
70  {
71  s->source(&is);
72  return s->operator()(t);
73  }
74 
75  Scanner const* scan(void) const
76  {
77  return s;
78  }
79 
81  {
82  if(s !=NULL)
83  {
84  s->clear_context();
85  }
86  }
87 };
88 
89 bool operator==(Parser const &, Parser const &);
90 
91 std::ostream& operator<<(std::ostream&, const Parser&);
92 
93 
94 
95 
96 #endif
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
std::ostream & operator<<(std::ostream &, const Parser &)
Definition: parser.cc:212
Definition: parser.h:50
bool operator()(Token &)
Definition: parser.cc:68
ParseResult
Definition: parser.h:45
void source(std::istream *)
Set new input stream.
Definition: scanner.cc:492
bool operator==(Parser const &, Parser const &)
Definition: parser.cc:207
Definition: tokenstack.h:38
void clear_context()
Definition: parser.h:80
void clear_context()
Definition: scanner.h:188
Scanner const * scan(void) const
Definition: parser.h:75
Token proctoken
Definition: parser.h:42
Scanner * s
Definition: parser.h:39
Definition: parser.h:49
bool readToken(std::istream &is, Token &t)
Definition: parser.h:63
Definition: scanner.h:38
void init(std::istream &)
Definition: parser.cc:45
Parser(void)
Definition: parser.cc:59
Definition: parser.h:47
Definition: parser.h:51
Definition: parser.h:46
Definition: parser.h:52
TokenStack ParseStack
Definition: parser.h:43
A type-independent container for C++-types.
Definition: token.h:68
Definition: parser.h:48
Definition: parser.h:37
Definition: parser.h:53
bool readSymbol(std::istream &is, Token &t)
Definition: parser.h:69
Token arraytoken
Definition: parser.h:41