1 /* Cycript - Remove Execution Server and Disassembler
2 * Copyright (C) 2009 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #include "location.hh"
48 #include "Pooling.hpp"
50 template <typename Type_>
64 void SetNext(Type_ *next) {
70 virtual void Output(struct CYOutput &out) const = 0;
86 CYOutput(std::ostream &out) :
94 void Check(char value);
97 CYOutput &operator <<(char rhs);
98 CYOutput &operator <<(const char *rhs);
100 _finline CYOutput &operator <<(const CYThing *rhs) {
106 _finline CYOutput &operator <<(const CYThing &rhs) {
112 struct CYPropertyName {
113 virtual void PropertyName(CYOutput &out) const = 0;
126 CYNoBrace = (1 << 0),
127 CYNoFunction = (1 << 1),
130 CYNoRightHand = (1 << 4),
131 CYNoDangle = (1 << 5),
132 CYNoBF = (CYNoBrace | CYNoFunction),
138 CYContext(apr_pool_t *pool) :
143 template <typename Type_>
144 void Replace(Type_ *&value) {
146 while (Type_ *replace = value->Replace(*this))
154 void Single(CYOutput &out, CYFlags flags) const;
155 void Multiple(CYOutput &out, CYFlags flags = CYNoFlags) const;
157 CYStatement *ReplaceAll(CYContext &context);
159 virtual CYStatement *Replace(CYContext &context) = 0;
162 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
165 struct CYStatements {
175 operator CYStatement *() const {
179 CYStatements &operator ->*(CYStatement *next) {
181 if (first_ == NULL) {
184 } else for (;; last_ = last_->next_)
185 if (last_->next_ == NULL) {
195 virtual CYExpression *ClassName(CYContext &context, bool object) = 0;
196 virtual void ClassName(CYOutput &out, bool object) const = 0;
206 CYWord(const char *word) :
211 const char *Value() const {
215 virtual void Output(CYOutput &out) const;
217 virtual CYExpression *ClassName(CYContext &context, bool object);
218 virtual void ClassName(CYOutput &out, bool object) const;
219 virtual void PropertyName(CYOutput &out) const;
222 _finline std::ostream &operator <<(std::ostream &lhs, const CYWord &rhs) {
223 return lhs << rhs.Value();
226 struct CYIdentifier :
229 CYIdentifier(const char *word) :
239 CYStatement *statement_;
241 CYLabel(CYIdentifier *name, CYStatement *statement) :
243 statement_(statement)
247 virtual CYStatement *Replace(CYContext &context);
248 virtual void Output(CYOutput &out, CYFlags flags) const;
254 CYStatement *statements_;
256 CYProgram(CYStatement *statements) :
257 statements_(statements)
261 virtual void Replace(CYContext &context);
263 virtual void Output(CYOutput &out) const;
270 CYStatement *statements_;
272 CYBlock(CYStatement *statements) :
273 statements_(statements)
277 virtual CYStatement *Replace(CYContext &context);
279 virtual void Output(CYOutput &out) const;
280 virtual void Output(CYOutput &out, CYFlags flags) const;
307 std::string filename_;
311 cy::location location_;
312 std::string message_;
315 typedef std::vector<Error> Errors;
322 void ScannerDestroy();
325 CYDriver(const std::string &filename);
328 void SetCondition(Condition condition);
330 void Warning(const cy::location &location, const char *message);
333 struct CYForInitialiser {
334 virtual void For(CYOutput &out) const = 0;
337 struct CYForInInitialiser {
338 virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
339 virtual const char *ForEachIn() const = 0;
340 virtual void ForEachIn(CYOutput &out) const = 0;
341 virtual CYExpression *ForEachIn(CYContext &out) = 0;
344 struct CYExpression :
345 CYNext<CYExpression>,
351 virtual unsigned Precedence() const = 0;
353 virtual bool RightHand() const {
357 virtual void For(CYOutput &out) const;
358 virtual void ForIn(CYOutput &out, CYFlags flags) const;
360 virtual const char *ForEachIn() const;
361 virtual void ForEachIn(CYOutput &out) const;
362 virtual CYExpression *ForEachIn(CYContext &out);
364 virtual void Output(CYOutput &out) const;
365 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
366 void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
368 virtual CYExpression *ClassName(CYContext &context, bool object);
369 virtual void ClassName(CYOutput &out, bool object) const;
371 CYExpression *ReplaceAll(CYContext &context);
373 virtual CYExpression *Replace(CYContext &context) = 0;
375 virtual const char *Word() const {
380 #define CYAlphabetic(value) \
381 virtual bool Alphabetic() const { \
385 #define CYPrecedence(value) \
386 virtual unsigned Precedence() const { \
390 #define CYRightHand(value) \
391 virtual bool RightHand() const { \
398 CYExpression *expressions_;
400 CYCompound(CYExpression *expressions) :
401 expressions_(expressions)
405 void AddPrev(CYExpression *expression) {
406 CYExpression *last(expression);
407 while (last->next_ != NULL)
409 last->SetNext(expressions_);
410 expressions_ = expression;
415 virtual CYExpression *Replace(CYContext &context);
416 void Output(CYOutput &out, CYFlags flags) const;
419 struct CYFunctionParameter :
420 CYNext<CYFunctionParameter>,
425 CYFunctionParameter(CYIdentifier *name, CYFunctionParameter *next = NULL) :
426 CYNext<CYFunctionParameter>(next),
431 virtual void Output(CYOutput &out) const;
434 struct CYComprehension :
435 CYNext<CYComprehension>,
438 void Output(CYOutput &out) const;
439 virtual const char *Name() const = 0;
441 virtual void Begin_(CYOutput &out) const = 0;
443 virtual void End_(CYOutput &out) const {
446 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
447 CYFunctionParameter *Parameters(CYContext &context) const;
448 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
451 struct CYForInComprehension :
457 CYForInComprehension(CYIdentifier *name, CYExpression *set) :
463 virtual const char *Name() const {
464 return name_->Value();
467 virtual void Begin_(CYOutput &out) const;
469 virtual CYFunctionParameter *Parameter(CYContext &context) const;
470 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
473 struct CYForEachInComprehension :
479 CYForEachInComprehension(CYIdentifier *name, CYExpression *set) :
485 virtual const char *Name() const {
486 return name_->Value();
489 virtual void Begin_(CYOutput &out) const;
490 virtual void End_(CYOutput &out) const;
492 virtual CYFunctionParameter *Parameter(CYContext &context) const;
493 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
496 struct CYIfComprehension :
501 CYIfComprehension(CYExpression *test) :
506 virtual const char *Name() const {
510 virtual void Begin_(CYOutput &out) const;
512 virtual CYFunctionParameter *Parameter(CYContext &context) const;
513 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
516 struct CYArrayComprehension :
519 CYExpression *expression_;
520 CYComprehension *comprehensions_;
522 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
523 expression_(expression),
524 comprehensions_(comprehensions)
530 virtual CYExpression *Replace(CYContext &context);
531 virtual void Output(CYOutput &out, CYFlags flags) const;
544 virtual CYExpression *Replace(CYContext &context);
558 CYRange(uint64_t lo, uint64_t hi) :
563 bool operator [](uint8_t value) const {
564 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
567 void operator()(uint8_t value) {
570 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
574 extern CYRange DigitRange_;
575 extern CYRange WordStartRange_;
576 extern CYRange WordEndRange_;
591 CYString(const char *value) :
597 CYString(const char *value, size_t size) :
603 CYString(const CYWord *word) :
604 value_(word->Value()),
605 size_(strlen(value_))
609 const char *Value() const {
613 virtual const char *Word() const;
615 virtual void Output(CYOutput &out, CYFlags flags) const;
616 virtual void PropertyName(CYOutput &out) const;
619 struct CYSelectorPart :
620 CYNext<CYSelectorPart>,
626 CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next) :
627 CYNext<CYSelectorPart>(next),
633 CYString *Replace(CYContext &context);
634 virtual void Output(CYOutput &out) const;
640 CYSelectorPart *name_;
642 CYSelector(CYSelectorPart *name) :
649 virtual CYExpression *Replace(CYContext &context);
650 virtual void Output(CYOutput &out, CYFlags flags) const;
659 CYNumber(double value) :
664 double Value() const {
668 virtual void Output(CYOutput &out, CYFlags flags) const;
669 virtual void PropertyName(CYOutput &out) const;
677 CYRegEx(const char *value) :
682 const char *Value() const {
686 virtual void Output(CYOutput &out, CYFlags flags) const;
698 virtual void Output(CYOutput &out, CYFlags flags) const;
710 virtual CYExpression *Replace(CYContext &context);
711 virtual void Output(CYOutput &out, CYFlags flags) const;
717 virtual bool Value() const = 0;
718 virtual void Output(CYOutput &out, CYFlags flags) const;
730 virtual bool Value() const {
744 virtual bool Value() const {
754 CYVariable(CYIdentifier *name) :
762 virtual CYExpression *Replace(CYContext &context);
763 virtual void Output(CYOutput &out, CYFlags flags) const;
771 CYPrefix(CYExpression *rhs) :
776 virtual bool Alphabetic() const = 0;
777 virtual const char *Operator() const = 0;
781 virtual CYExpression *Replace(CYContext &context);
782 virtual void Output(CYOutput &out, CYFlags flags) const;
791 CYInfix(CYExpression *lhs, CYExpression *rhs) :
797 void SetLeft(CYExpression *lhs) {
801 virtual bool Alphabetic() const = 0;
802 virtual const char *Operator() const = 0;
804 virtual CYExpression *Replace(CYContext &context);
805 virtual void Output(CYOutput &out, CYFlags flags) const;
813 CYPostfix(CYExpression *lhs) :
818 virtual const char *Operator() const = 0;
822 virtual CYExpression *Replace(CYContext &context);
823 virtual void Output(CYOutput &out, CYFlags flags) const;
826 struct CYAssignment :
832 CYAssignment(CYExpression *lhs, CYExpression *rhs) :
838 void SetLeft(CYExpression *lhs) {
842 virtual const char *Operator() const = 0;
844 virtual CYExpression *Replace(CYContext &context);
845 virtual void Output(CYOutput &out, CYFlags flags) const;
853 CYExpression *value_;
855 CYArgument(CYExpression *value, CYArgument *next = NULL) :
856 CYNext<CYArgument>(next),
862 CYArgument(CYWord *name, CYExpression *value, CYArgument *next = NULL) :
863 CYNext<CYArgument>(next),
869 void Replace(CYContext &context);
870 void Output(CYOutput &out) const;
887 CYStatement *statements_;
889 CYClause(CYExpression *_case, CYStatement *statements) :
891 statements_(statements)
895 virtual void Replace(CYContext &context);
896 virtual void Output(CYOutput &out) const;
903 CYExpression *value_;
905 CYElement(CYExpression *value, CYElement *next) :
906 CYNext<CYElement>(next),
911 void Replace(CYContext &context);
912 void Output(CYOutput &out) const;
918 CYElement *elements_;
920 CYArray(CYElement *elements = NULL) :
925 virtual CYExpression *Replace(CYContext &context);
926 virtual void Output(CYOutput &out, CYFlags flags) const;
929 struct CYDeclaration :
932 CYIdentifier *identifier_;
933 CYExpression *initialiser_;
935 CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser) :
936 identifier_(identifier),
937 initialiser_(initialiser)
941 virtual void ForIn(CYOutput &out, CYFlags flags) const;
943 virtual const char *ForEachIn() const;
944 virtual void ForEachIn(CYOutput &out) const;
945 virtual CYExpression *ForEachIn(CYContext &out);
947 void Replace(CYContext &context);
949 virtual void Output(CYOutput &out, CYFlags flags) const;
952 struct CYDeclarations :
953 CYNext<CYDeclarations>,
957 CYDeclaration *declaration_;
959 CYDeclarations(CYDeclaration *declaration, CYDeclarations *next) :
960 CYNext<CYDeclarations>(next),
961 declaration_(declaration)
965 virtual void For(CYOutput &out) const;
967 void Replace(CYContext &context);
969 virtual void Output(CYOutput &out) const;
970 virtual void Output(CYOutput &out, CYFlags flags) const;
976 CYDeclarations *declarations_;
978 CYVar(CYDeclarations *declarations) :
979 declarations_(declarations)
983 virtual CYStatement *Replace(CYContext &context);
984 virtual void Output(CYOutput &out, CYFlags flags) const;
990 CYDeclarations *declarations_;
993 CYLet(CYDeclarations *declarations, CYStatement *statements) :
994 declarations_(declarations),
999 virtual CYStatement *Replace(CYContext &context);
1000 virtual void Output(CYOutput &out, CYFlags flags) const;
1006 CYStatement *Replace(CYContext &context) const;
1007 void Output(CYOutput &out) const;
1010 struct CYMessageParameter :
1011 CYNext<CYMessageParameter>
1014 CYExpression *type_;
1015 CYIdentifier *name_;
1017 CYMessageParameter(CYWord *tag, CYExpression *type, CYIdentifier *name) :
1024 CYFunctionParameter *Parameters(CYContext &context) const;
1025 CYSelector *Selector(CYContext &context) const;
1026 CYSelectorPart *SelectorPart(CYContext &context) const;
1033 CYExpression *type_;
1034 CYMessageParameter *parameters_;
1035 CYStatement *statements_;
1037 CYMessage(bool instance, CYExpression *type, CYMessageParameter *parameter, CYStatement *statements) :
1038 instance_(instance),
1040 parameters_(parameter),
1041 statements_(statements)
1045 CYStatement *Replace(CYContext &context, bool replace) const;
1046 void Output(CYOutput &out, bool replace) const;
1051 CYExpression *super_;
1053 CYMessage *messages_;
1055 CYClass(CYClassName *name, CYExpression *super, CYField *fields, CYMessage *messages) :
1063 CYExpression *Replace_(CYContext &context);
1064 virtual void Output(CYOutput &out, CYFlags flags) const;
1067 struct CYClassExpression :
1071 CYClassExpression(CYClassName *name, CYExpression *super, CYField *fields, CYMessage *messages) :
1072 CYClass(name, super, fields, messages)
1078 virtual CYExpression *Replace(CYContext &context);
1079 virtual void Output(CYOutput &out, CYFlags flags) const;
1082 struct CYClassStatement :
1086 CYClassStatement(CYClassName *name, CYExpression *super, CYField *fields, CYMessage *messages) :
1087 CYClass(name, super, fields, messages)
1091 virtual CYStatement *Replace(CYContext &context);
1092 virtual void Output(CYOutput &out, CYFlags flags) const;
1099 CYMessage *messages_;
1101 CYCategory(CYClassName *name, CYMessage *messages) :
1107 virtual CYStatement *Replace(CYContext &context);
1108 virtual void Output(CYOutput &out, CYFlags flags) const;
1114 CYForInitialiser *initialiser_;
1115 CYExpression *test_;
1116 CYExpression *increment_;
1119 CYFor(CYForInitialiser *initialiser, CYExpression *test, CYExpression *increment, CYStatement *code) :
1120 initialiser_(initialiser),
1122 increment_(increment),
1127 virtual CYStatement *Replace(CYContext &context);
1128 virtual void Output(CYOutput &out, CYFlags flags) const;
1134 CYForInInitialiser *initialiser_;
1138 CYForIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1139 initialiser_(initialiser),
1145 virtual CYStatement *Replace(CYContext &context);
1146 virtual void Output(CYOutput &out, CYFlags flags) const;
1149 struct CYForEachIn :
1152 CYForInInitialiser *initialiser_;
1156 CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1157 initialiser_(initialiser),
1163 virtual CYStatement *Replace(CYContext &context);
1164 virtual void Output(CYOutput &out, CYFlags flags) const;
1171 CYPropertyName *name_;
1172 CYExpression *value_;
1174 CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
1175 CYNext<CYProperty>(next),
1181 void Replace(CYContext &context);
1182 virtual void Output(CYOutput &out) const;
1188 CYProperty *properties_;
1190 CYObject(CYProperty *properties) :
1191 properties_(properties)
1195 virtual CYExpression *Replace(CYContext &context);
1196 void Output(CYOutput &out, CYFlags flags) const;
1202 CYIdentifier *name_;
1205 CYCatch(CYIdentifier *name, CYStatement *statements) :
1211 void Replace(CYContext &context);
1212 virtual void Output(CYOutput &out) const;
1218 CYExpression *self_;
1219 CYArgument *arguments_;
1221 CYSend(CYExpression *self, CYArgument *arguments) :
1223 arguments_(arguments)
1229 virtual CYExpression *Replace(CYContext &context);
1230 virtual void Output(CYOutput &out, CYFlags flags) const;
1236 CYExpression *object_;
1237 CYExpression *property_;
1239 CYMember(CYExpression *object, CYExpression *property) :
1245 void SetLeft(CYExpression *object) {
1249 void Replace_(CYContext &context);
1252 struct CYDirectMember :
1255 CYDirectMember(CYExpression *object, CYExpression *property) :
1256 CYMember(object, property)
1263 virtual CYExpression *Replace(CYContext &context);
1264 virtual void Output(CYOutput &out, CYFlags flags) const;
1267 struct CYIndirectMember :
1270 CYIndirectMember(CYExpression *object, CYExpression *property) :
1271 CYMember(object, property)
1278 virtual CYExpression *Replace(CYContext &context);
1279 virtual void Output(CYOutput &out, CYFlags flags) const;
1285 CYExpression *constructor_;
1286 CYArgument *arguments_;
1288 CYNew(CYExpression *constructor, CYArgument *arguments) :
1289 constructor_(constructor),
1290 arguments_(arguments)
1294 virtual unsigned Precedence() const {
1295 return arguments_ == NULL ? 2 : 1;
1300 virtual CYExpression *Replace(CYContext &context);
1301 virtual void Output(CYOutput &out, CYFlags flags) const;
1307 CYExpression *function_;
1308 CYArgument *arguments_;
1310 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1311 function_(function),
1312 arguments_(arguments)
1319 virtual CYExpression *Replace(CYContext &context);
1320 virtual void Output(CYOutput &out, CYFlags flags) const;
1326 CYExpression *test_;
1328 CYStatement *false_;
1330 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1337 virtual CYStatement *Replace(CYContext &context);
1338 virtual void Output(CYOutput &out, CYFlags flags) const;
1344 CYExpression *test_;
1347 CYDoWhile(CYExpression *test, CYStatement *code) :
1353 virtual CYStatement *Replace(CYContext &context);
1354 virtual void Output(CYOutput &out, CYFlags flags) const;
1360 CYExpression *test_;
1363 CYWhile(CYExpression *test, CYStatement *code) :
1369 virtual CYStatement *Replace(CYContext &context);
1370 virtual void Output(CYOutput &out, CYFlags flags) const;
1374 CYIdentifier *name_;
1375 CYFunctionParameter *parameters_;
1378 CYFunction(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1380 parameters_(parameters),
1385 virtual void Replace_(CYContext &context);
1386 virtual void Output(CYOutput &out, CYFlags flags) const;
1389 struct CYFunctionExpression :
1393 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1394 CYFunction(name, parameters, statements)
1401 virtual CYExpression *Replace(CYContext &context);
1402 virtual void Output(CYOutput &out, CYFlags flags) const;
1405 struct CYFunctionStatement :
1409 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1410 CYFunction(name, parameters, statements)
1414 virtual CYStatement *Replace(CYContext &context);
1415 virtual void Output(CYOutput &out, CYFlags flags) const;
1421 CYExpression *expression_;
1423 CYExpress(CYExpression *expression) :
1424 expression_(expression)
1428 virtual CYStatement *Replace(CYContext &context);
1429 virtual void Output(CYOutput &out, CYFlags flags) const;
1435 CYIdentifier *label_;
1437 CYContinue(CYIdentifier *label) :
1442 virtual CYStatement *Replace(CYContext &context);
1443 virtual void Output(CYOutput &out, CYFlags flags) const;
1449 CYIdentifier *label_;
1451 CYBreak(CYIdentifier *label) :
1456 virtual CYStatement *Replace(CYContext &context);
1457 virtual void Output(CYOutput &out, CYFlags flags) const;
1463 CYExpression *value_;
1465 CYReturn(CYExpression *value) :
1470 virtual CYStatement *Replace(CYContext &context);
1471 virtual void Output(CYOutput &out, CYFlags flags) const;
1477 virtual CYStatement *Replace(CYContext &context);
1478 virtual void Output(CYOutput &out, CYFlags flags) const;
1486 CYFinally(CYStatement *statements) :
1491 void Replace(CYContext &context);
1492 virtual void Output(CYOutput &out) const;
1500 CYFinally *finally_;
1502 CYTry(CYStatement *statements, CYCatch *_catch, CYFinally *finally) :
1509 virtual CYStatement *Replace(CYContext &context);
1510 virtual void Output(CYOutput &out, CYFlags flags) const;
1516 CYExpression *value_;
1518 CYThrow(CYExpression *value) :
1523 virtual CYStatement *Replace(CYContext &context);
1524 virtual void Output(CYOutput &out, CYFlags flags) const;
1530 CYExpression *scope_;
1533 CYWith(CYExpression *scope, CYStatement *code) :
1539 virtual CYStatement *Replace(CYContext &context);
1540 virtual void Output(CYOutput &out, CYFlags flags) const;
1546 CYExpression *value_;
1549 CYSwitch(CYExpression *value, CYClause *clauses) :
1555 virtual CYStatement *Replace(CYContext &context);
1556 virtual void Output(CYOutput &out, CYFlags flags) const;
1559 struct CYCondition :
1562 CYExpression *test_;
1563 CYExpression *true_;
1564 CYExpression *false_;
1566 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
1575 virtual CYExpression *Replace(CYContext &context);
1576 virtual void Output(CYOutput &out, CYFlags flags) const;
1579 struct CYAddressOf :
1582 CYAddressOf(CYExpression *rhs) :
1587 virtual const char *Operator() const {
1593 virtual CYExpression *Replace(CYContext &context);
1599 CYIndirect(CYExpression *rhs) :
1604 virtual const char *Operator() const {
1610 virtual CYExpression *Replace(CYContext &context);
1613 #define CYPostfix_(op, name) \
1614 struct CY ## name : \
1617 CY ## name(CYExpression *lhs) : \
1622 virtual const char *Operator() const { \
1627 #define CYPrefix_(alphabetic, op, name) \
1628 struct CY ## name : \
1631 CY ## name(CYExpression *rhs) : \
1636 CYAlphabetic(alphabetic) \
1638 virtual const char *Operator() const { \
1643 #define CYInfix_(alphabetic, precedence, op, name) \
1644 struct CY ## name : \
1647 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
1652 CYAlphabetic(alphabetic) \
1653 CYPrecedence(precedence) \
1655 virtual const char *Operator() const { \
1660 #define CYAssignment_(op, name) \
1661 struct CY ## name ## Assign : \
1664 CY ## name ## Assign(CYExpression *lhs, CYExpression *rhs) : \
1665 CYAssignment(lhs, rhs) \
1671 virtual const char *Operator() const { \
1676 CYPostfix_("++", PostIncrement)
1677 CYPostfix_("--", PostDecrement)
1679 CYPrefix_(true, "delete", Delete)
1680 CYPrefix_(true, "void", Void)
1681 CYPrefix_(true, "typeof", TypeOf)
1682 CYPrefix_(false, "++", PreIncrement)
1683 CYPrefix_(false, "--", PreDecrement)
1684 CYPrefix_(false, "+", Affirm)
1685 CYPrefix_(false, "-", Negate)
1686 CYPrefix_(false, "~", BitwiseNot)
1687 CYPrefix_(false, "!", LogicalNot)
1689 CYInfix_(false, 5, "*", Multiply)
1690 CYInfix_(false, 5, "/", Divide)
1691 CYInfix_(false, 5, "%", Modulus)
1692 CYInfix_(false, 6, "+", Add)
1693 CYInfix_(false, 6, "-", Subtract)
1694 CYInfix_(false, 7, "<<", ShiftLeft)
1695 CYInfix_(false, 7, ">>", ShiftRightSigned)
1696 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
1697 CYInfix_(false, 8, "<", Less)
1698 CYInfix_(false, 8, ">", Greater)
1699 CYInfix_(false, 8, "<=", LessOrEqual)
1700 CYInfix_(false, 8, ">=", GreaterOrEqual)
1701 CYInfix_(true, 8, "instanceof", InstanceOf)
1702 CYInfix_(true, 8, "in", In)
1703 CYInfix_(false, 9, "==", Equal)
1704 CYInfix_(false, 9, "!=", NotEqual)
1705 CYInfix_(false, 9, "===", Identical)
1706 CYInfix_(false, 9, "!==", NotIdentical)
1707 CYInfix_(false, 10, "&", BitwiseAnd)
1708 CYInfix_(false, 11, "^", BitwiseXOr)
1709 CYInfix_(false, 12, "|", BitwiseOr)
1710 CYInfix_(false, 13, "&&", LogicalAnd)
1711 CYInfix_(false, 14, "||", LogicalOr)
1713 CYAssignment_("=", )
1714 CYAssignment_("*=", Multiply)
1715 CYAssignment_("/=", Divide)
1716 CYAssignment_("%=", Modulus)
1717 CYAssignment_("+=", Add)
1718 CYAssignment_("-=", Subtract)
1719 CYAssignment_("<<=", ShiftLeft)
1720 CYAssignment_(">>=", ShiftRightSigned)
1721 CYAssignment_(">>>=", ShiftRightUnsigned)
1722 CYAssignment_("&=", BitwiseAnd)
1723 CYAssignment_("^=", BitwiseXOr)
1724 CYAssignment_("|=", BitwiseOr)
1726 #endif/*CYPARSER_HPP*/