]>
Commit | Line | Data |
---|---|---|
7341eedb JF |
1 | /* Cycript - The Truly Universal Scripting Language |
2 | * Copyright (C) 2009-2016 Jay Freeman (saurik) | |
b12a9965 JF |
3 | */ |
4 | ||
f95d2598 | 5 | /* GNU Affero General Public License, Version 3 {{{ */ |
b12a9965 | 6 | /* |
f95d2598 JF |
7 | * This program is free software: you can redistribute it and/or modify |
8 | * it under the terms of the GNU Affero General Public License as published by | |
9 | * the Free Software Foundation, either version 3 of the License, or | |
10 | * (at your option) any later version. | |
11 | ||
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
b12a9965 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f95d2598 JF |
15 | * GNU Affero General Public License for more details. |
16 | ||
17 | * You should have received a copy of the GNU Affero General Public License | |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
b12a9965 JF |
19 | **/ |
20 | /* }}} */ | |
21 | ||
22 | #ifndef CYCRIPT_DRIVER_HPP | |
23 | #define CYCRIPT_DRIVER_HPP | |
24 | ||
25 | #include <iostream> | |
26 | ||
27 | #include <stack> | |
28 | #include <string> | |
29 | #include <vector> | |
30 | ||
58afc6aa | 31 | #include "Location.hpp" |
8a392978 JF |
32 | #include "Options.hpp" |
33 | #include "Pooling.hpp" | |
34 | #include "Standard.hpp" | |
35 | ||
c5b15840 | 36 | struct CYClassTail; |
8a392978 JF |
37 | struct CYExpression; |
38 | struct CYScript; | |
39 | struct CYWord; | |
b12a9965 | 40 | |
9d2b125d | 41 | enum CYMark { |
9d2b125d JF |
42 | CYMarkScript, |
43 | CYMarkModule, | |
a4d849b7 | 44 | CYMarkExpression, |
9d2b125d JF |
45 | }; |
46 | ||
d9c91152 | 47 | class _visible CYDriver { |
b12a9965 | 48 | public: |
2c1d569a | 49 | CYPool &pool_; |
b12a9965 JF |
50 | void *scanner_; |
51 | ||
b900e1a4 JF |
52 | std::vector<char> buffer_; |
53 | bool tail_; | |
54 | ||
b12a9965 | 55 | std::stack<bool> in_; |
9d2b125d | 56 | std::stack<bool> return_; |
c5b15840 | 57 | std::stack<bool> super_; |
b900e1a4 | 58 | std::stack<bool> template_; |
9d2b125d | 59 | std::stack<bool> yield_; |
b12a9965 | 60 | |
c5b15840 JF |
61 | std::stack<CYClassTail *> class_; |
62 | ||
675ff733 JF |
63 | CYMark mark_; |
64 | int hold_; | |
65 | bool newline_; | |
a5662a53 | 66 | bool last_; |
b12a9965 | 67 | |
c3d9dbc7 | 68 | std::streambuf &data_; |
b12a9965 | 69 | |
d9c91152 | 70 | int debug_; |
b12a9965 | 71 | bool strict_; |
b900e1a4 | 72 | bool highlight_; |
b12a9965 JF |
73 | |
74 | enum Condition { | |
b12a9965 JF |
75 | XMLContentCondition, |
76 | XMLTagCondition, | |
77 | }; | |
78 | ||
79 | std::string filename_; | |
80 | ||
81 | struct Error { | |
82 | bool warning_; | |
58afc6aa | 83 | CYLocation location_; |
b12a9965 JF |
84 | std::string message_; |
85 | }; | |
86 | ||
87 | typedef std::vector<Error> Errors; | |
88 | ||
a7d8b413 | 89 | CYScript *script_; |
b12a9965 JF |
90 | Errors errors_; |
91 | ||
92 | bool auto_; | |
93 | ||
94 | struct Context { | |
95 | CYExpression *context_; | |
96 | ||
97 | Context(CYExpression *context) : | |
98 | context_(context) | |
99 | { | |
100 | } | |
101 | ||
102 | typedef std::vector<CYWord *> Words; | |
103 | Words words_; | |
104 | }; | |
105 | ||
106 | typedef std::vector<Context> Contexts; | |
107 | Contexts contexts_; | |
108 | ||
109 | CYExpression *context_; | |
110 | ||
111 | enum Mode { | |
112 | AutoNone, | |
113 | AutoPrimary, | |
114 | AutoDirect, | |
115 | AutoIndirect, | |
2fad14e5 JF |
116 | AutoMessage, |
117 | AutoResolve, | |
84096608 JF |
118 | AutoStruct, |
119 | AutoEnum, | |
b12a9965 JF |
120 | } mode_; |
121 | ||
122 | private: | |
123 | void ScannerInit(); | |
124 | void ScannerDestroy(); | |
125 | ||
126 | public: | |
c3d9dbc7 | 127 | CYDriver(CYPool &pool, std::streambuf &data, const std::string &filename = ""); |
b12a9965 JF |
128 | ~CYDriver(); |
129 | ||
90dd6ff1 | 130 | bool Parse(CYMark mark = CYMarkModule); |
2c1d569a | 131 | void Replace(CYOptions &options); |
d9c91152 | 132 | |
98711170 | 133 | void SetRegEx(bool equal); |
b12a9965 JF |
134 | void SetCondition(Condition condition); |
135 | ||
136 | void PushCondition(Condition condition); | |
137 | void PopCondition(); | |
138 | ||
58afc6aa | 139 | void Warning(const CYLocation &location, const char *message); |
b12a9965 JF |
140 | }; |
141 | ||
142 | #endif/*CYCRIPT_DRIVER_HPP*/ |