Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1186 | 1186 |
| 1187 #define FOR_EACH_REG_EXP_NODE_TYPE(VISIT) \ | 1187 #define FOR_EACH_REG_EXP_NODE_TYPE(VISIT) \ |
| 1188 VISIT(Disjunction) \ | 1188 VISIT(Disjunction) \ |
| 1189 VISIT(Alternative) \ | 1189 VISIT(Alternative) \ |
| 1190 VISIT(Assertion) \ | 1190 VISIT(Assertion) \ |
| 1191 VISIT(CharacterClass) \ | 1191 VISIT(CharacterClass) \ |
| 1192 VISIT(Atom) \ | 1192 VISIT(Atom) \ |
| 1193 VISIT(Quantifier) \ | 1193 VISIT(Quantifier) \ |
| 1194 VISIT(Capture) \ | 1194 VISIT(Capture) \ |
| 1195 VISIT(Lookahead) \ | 1195 VISIT(Lookahead) \ |
| 1196 VISIT(Backreference) \ | |
| 1196 VISIT(Empty) | 1197 VISIT(Empty) |
| 1197 | 1198 |
| 1198 | 1199 |
| 1199 class RegExpVisitor; | 1200 class RegExpVisitor; |
| 1200 template <typename Char> class RegExpNode; | 1201 template <typename Char> class RegExpNode; |
| 1201 #define FORWARD_DECLARE(Name) class RegExp##Name; | 1202 #define FORWARD_DECLARE(Name) class RegExp##Name; |
| 1202 FOR_EACH_REG_EXP_NODE_TYPE(FORWARD_DECLARE) | 1203 FOR_EACH_REG_EXP_NODE_TYPE(FORWARD_DECLARE) |
| 1203 #undef FORWARD_DECLARE | 1204 #undef FORWARD_DECLARE |
| 1204 | 1205 |
| 1205 | 1206 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1333 | 1334 |
| 1334 | 1335 |
| 1335 class RegExpCapture: public RegExpTree { | 1336 class RegExpCapture: public RegExpTree { |
| 1336 public: | 1337 public: |
| 1337 explicit RegExpCapture(RegExpTree* body) | 1338 explicit RegExpCapture(RegExpTree* body) |
| 1338 : body_(body) { } | 1339 : body_(body) { } |
| 1339 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1340 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1340 RegExpTree* body() { return body_; } | 1341 RegExpTree* body() { return body_; } |
| 1341 private: | 1342 private: |
| 1342 RegExpTree* body_; | 1343 RegExpTree* body_; |
| 1343 }; | 1344 }; |
|
Lasse Reichstein
2008/10/28 10:09:52
Now we have back-references with an index, the cap
| |
| 1344 | 1345 |
| 1345 | 1346 |
| 1346 class RegExpLookahead: public RegExpTree { | 1347 class RegExpLookahead: public RegExpTree { |
| 1347 public: | 1348 public: |
| 1348 RegExpLookahead(RegExpTree* body, bool is_positive) | 1349 RegExpLookahead(RegExpTree* body, bool is_positive) |
| 1349 : body_(body), | 1350 : body_(body), |
| 1350 is_positive_(is_positive) { } | 1351 is_positive_(is_positive) { } |
| 1351 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1352 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1352 RegExpTree* body() { return body_; } | 1353 RegExpTree* body() { return body_; } |
| 1353 bool is_positive() { return is_positive_; } | 1354 bool is_positive() { return is_positive_; } |
| 1354 private: | 1355 private: |
| 1355 RegExpTree* body_; | 1356 RegExpTree* body_; |
| 1356 bool is_positive_; | 1357 bool is_positive_; |
| 1357 }; | 1358 }; |
| 1358 | 1359 |
| 1359 | 1360 |
| 1361 class RegExpBackreference: public RegExpTree { | |
| 1362 public: | |
| 1363 explicit RegExpBackreference(int index) : index_(index) { } | |
| 1364 virtual void* Accept(RegExpVisitor* visitor, void* data); | |
| 1365 int index() { return index_; } | |
| 1366 private: | |
| 1367 int index_; | |
| 1368 }; | |
| 1369 | |
| 1370 | |
| 1360 class RegExpEmpty: public RegExpTree { | 1371 class RegExpEmpty: public RegExpTree { |
| 1361 public: | 1372 public: |
| 1362 RegExpEmpty() { } | 1373 RegExpEmpty() { } |
| 1363 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1374 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1364 static RegExpEmpty* GetInstance() { return &kInstance; } | 1375 static RegExpEmpty* GetInstance() { return &kInstance; } |
| 1365 private: | 1376 private: |
| 1366 static RegExpEmpty kInstance; | 1377 static RegExpEmpty kInstance; |
| 1367 }; | 1378 }; |
| 1368 | 1379 |
| 1369 | 1380 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 #undef DEF_VISIT | 1426 #undef DEF_VISIT |
| 1416 | 1427 |
| 1417 private: | 1428 private: |
| 1418 bool stack_overflow_; | 1429 bool stack_overflow_; |
| 1419 }; | 1430 }; |
| 1420 | 1431 |
| 1421 | 1432 |
| 1422 } } // namespace v8::internal | 1433 } } // namespace v8::internal |
| 1423 | 1434 |
| 1424 #endif // V8_AST_H_ | 1435 #endif // V8_AST_H_ |
| OLD | NEW |