-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli_parser.h
105 lines (78 loc) · 1.62 KB
/
sli_parser.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* parser.h
*
* This file is part of NEST
*
* Copyright (C) 2004 by
* The NEST Initiative
*
* See the file AUTHORS for details.
*
* Permission is granted to compile and modify
* this file for non-commercial use.
* See the file LICENSE for details.
*
*/
#ifndef SLI_PARSER_H
#define SLI_PARSER_H
/*
SLI's parser.
*/
#include "sli_token.h"
#include "sli_tokenstack.h"
#include "sli_name.h"
#include "sli_tokenstack.h"
#include "sli_scanner.h"
#include <typeinfo>
#include <iostream>
namespace sli3
{
class Scanner;
class SLIInterpreter;
class Parser
{
Scanner* s;
TokenStack stack_;
Name open_array_;
Name close_array_;
enum ParseResult {
tokencontinue,
scancontinue,
tokencompleted,
noopenproc,
endprocexpected,
noopenarray,
endarrayexpected,
unexpectedeof
};
void init(std::istream &);
public:
Parser(void);
Parser(std::istream &);
bool operator()(SLIInterpreter &, Token&);
bool readToken(SLIInterpreter &sli, std::istream &is, Token &t)
{
s->source(&is);
return operator()(sli, t);
}
bool readSymbol(SLIInterpreter &sli, std::istream &is, Token &t)
{
s->source(&is);
return s->operator()(sli, t);
}
Scanner const* scan(void) const
{
return s;
}
void clear_context()
{
if(s !=NULL)
{
s->clear_context();
}
}
};
bool operator==(Parser const &, Parser const &);
std::ostream& operator<<(std::ostream&, const Parser&);
}
#endif