自作言語nullptrのインタープリターです。
| Revision | 3fe66ee3ed4c9b6729ac53759a7112cbee4b171d (tree) |
|---|---|
| Time | 2015-08-15 00:27:41 |
| Author | VOSystems <diverge.vosystems@gmai...> |
| Commiter | VOSystems |
Preprocesor is almost finished. NEXT->Interpreter
| @@ -175,6 +175,33 @@ void Preprocessor::LoadLib(Library& module) | ||
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | +void RegID(VOSystemsNullptr::System::IdentifierList& idlist, uint8_t type, const VOSystemsNullptr::System::FileOperator& fope, string line) | |
| 179 | +{ | |
| 180 | + VOSystemsNullptr::System::Identifier id; | |
| 181 | + id.type=type; | |
| 182 | + id.pos=fope.GetStreamOffset(); | |
| 183 | + | |
| 184 | + string::iterator start,end; | |
| 185 | + switch(type){ | |
| 186 | + case VOSystemsNullptr::System::NotFound: | |
| 187 | + default: | |
| 188 | + break; | |
| 189 | + | |
| 190 | + case VOSystemsNullptr::System::IntType: | |
| 191 | + start=line.begin()+4; | |
| 192 | + break; | |
| 193 | + case VOSystemsNullptr::System::StringType: | |
| 194 | + start=line.begin()+7; | |
| 195 | + case VOSystemsNullptr::System::BoolType: | |
| 196 | + start=line.begin()+5; | |
| 197 | + } | |
| 198 | + id.name=string(start,line.begin()+line.find_first_of('(')); | |
| 199 | + | |
| 200 | + idlist.push_back(id); | |
| 201 | + | |
| 202 | + return; | |
| 203 | +} | |
| 204 | + | |
| 178 | 205 | void Preprocessor::LoadId(System::IdentifierList& list) |
| 179 | 206 | { |
| 180 | 207 | regex |
| @@ -184,19 +211,17 @@ void Preprocessor::LoadId(System::IdentifierList& list) | ||
| 184 | 211 | |
| 185 | 212 | System::FileOperator fope(m_src,";"); |
| 186 | 213 | string line; |
| 187 | - System::Identifier id; | |
| 188 | - | |
| 189 | 214 | do{ |
| 190 | 215 | line=fope(); |
| 191 | 216 | |
| 192 | 217 | if(regex_match(line,bool_regex)){ |
| 193 | - id.type=System::BoolType; | |
| 218 | + RegID(list,System::BoolType,fope,line); | |
| 194 | 219 | |
| 195 | 220 | }else if(regex_match(line,int_regex)){ |
| 196 | - id.type=System::IntType; | |
| 221 | + RegID(list,System::IntType,fope,line); | |
| 197 | 222 | |
| 198 | 223 | }else if(regex_match(line,str_regex)){ |
| 199 | - id.type=System::StringType; | |
| 224 | + RegID(list,System::StringType,fope,line); | |
| 200 | 225 | |
| 201 | 226 | } |
| 202 | 227 |
| @@ -111,6 +111,8 @@ namespace VOSystemsNullptr | ||
| 111 | 111 | std::string operator()(void); |
| 112 | 112 | std::string operator()(size_t startpoint); |
| 113 | 113 | std::string operator=(std::string source); |
| 114 | + | |
| 115 | + streamoff GetStreamOffset(void) const; | |
| 114 | 116 | }; |
| 115 | 117 | |
| 116 | 118 | class StringModule |