1 /* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
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.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
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/>.
22 #ifndef CYCRIPT_SYNTAX_HPP
23 #define CYCRIPT_SYNTAX_HPP
33 #include "Location.hpp"
34 #include "Options.hpp"
35 #include "Pooling.hpp"
38 double CYCastDouble(const char *value, size_t size);
39 double CYCastDouble(const char *value);
40 double CYCastDouble(CYUTF8String value);
42 void CYNumerify(std::ostringstream &str, double value);
44 enum CYStringifyMode {
45 CYStringifyModeLegacy,
46 CYStringifyModeCycript,
47 CYStringifyModeNative,
50 void CYStringify(std::ostringstream &str, const char *data, size_t size, CYStringifyMode mode);
52 // XXX: this really should not be here ... :/
53 void *CYPoolFile(CYPool &pool, const char *path, size_t *psize);
54 CYUTF8String CYPoolFileUTF8String(CYPool &pool, const char *path);
59 virtual void Output(struct CYOutput &out) const = 0;
80 CYOutput(std::streambuf &out, CYOptions &options) :
91 void Check(char value);
94 _finline void operator ()(char value) {
95 _assert(out_.sputc(value) != EOF);
100 position_.Columns(1);
103 _finline void operator ()(const char *data, std::streamsize size) {
104 _assert(out_.sputn(data, size) == size);
106 position_.Columns(size);
109 _finline void operator ()(const char *data) {
110 return operator ()(data, strlen(data));
113 CYOutput &operator <<(char rhs);
114 CYOutput &operator <<(const char *rhs);
116 _finline CYOutput &operator <<(const CYThing *rhs) {
122 _finline CYOutput &operator <<(const CYThing &rhs) {
133 struct CYPropertyName {
134 virtual bool Computed() const {
138 virtual bool Constructor() const {
142 virtual CYIdentifier *Identifier() {
146 virtual CYNumber *Number(CYContext &context) {
150 virtual CYExpression *PropertyName(CYContext &context) = 0;
151 virtual void PropertyName(CYOutput &out) const = 0;
162 CYNoBrace = (1 << 0),
163 CYNoFunction = (1 << 1),
164 CYNoClass = (1 << 2),
167 CYNoRightHand = (1 << 5),
168 CYNoDangle = (1 << 6),
169 CYNoInteger = (1 << 7),
170 CYNoColon = (1 << 8),
171 CYNoBFC = (CYNoBrace | CYNoFunction | CYNoClass),
174 _finline CYFlags operator ~(CYFlags rhs) {
175 return static_cast<CYFlags>(~static_cast<unsigned>(rhs));
178 _finline CYFlags operator &(CYFlags lhs, CYFlags rhs) {
179 return static_cast<CYFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs));
182 _finline CYFlags operator |(CYFlags lhs, CYFlags rhs) {
183 return static_cast<CYFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
186 _finline CYFlags &operator |=(CYFlags &lhs, CYFlags rhs) {
187 return lhs = lhs | rhs;
190 _finline CYFlags CYLeft(CYFlags flags) {
191 return flags & ~(CYNoDangle | CYNoInteger);
194 _finline CYFlags CYRight(CYFlags flags) {
195 return flags & ~CYNoBFC;
198 _finline CYFlags CYCenter(CYFlags flags) {
199 return CYLeft(CYRight(flags));
208 #define CYCompact(type) \
209 virtual CYCompactType Compact() const { \
210 return CYCompact ## type; \
217 void Single(CYOutput &out, CYFlags flags, CYCompactType request) const;
218 void Multiple(CYOutput &out, CYFlags flags = CYNoFlags) const;
219 virtual void Output(CYOutput &out) const;
221 virtual CYStatement *Replace(CYContext &context) = 0;
223 virtual CYCompactType Compact() const = 0;
224 virtual CYStatement *Return();
227 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
230 typedef CYList<CYStatement> CYStatements;
232 struct CYForInitializer :
235 virtual CYForInitializer *Replace(CYContext &context) = 0;
236 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
245 CYWord(const char *word) :
250 virtual bool Constructor() const {
251 return strcmp(word_, "constructor") == 0;
254 virtual const char *Word() const;
255 virtual void Output(CYOutput &out) const;
257 virtual CYExpression *PropertyName(CYContext &context);
258 virtual void PropertyName(CYOutput &out) const;
261 _finline std::ostream &operator <<(std::ostream &lhs, const CYWord &rhs) {
263 return lhs << rhs.Word();
266 enum CYIdentifierKind {
267 CYIdentifierArgument,
273 CYIdentifierVariable,
276 struct CYIdentifier :
277 CYNext<CYIdentifier>,
280 CYLocation location_;
284 CYIdentifier(const char *word) :
291 CYIdentifier *Identifier() override {
295 virtual const char *Word() const;
296 CYIdentifier *Replace(CYContext &context, CYIdentifierKind);
303 CYStatement *statement_;
305 CYLabel(CYIdentifier *name, CYStatement *statement) :
307 statement_(statement)
313 virtual CYStatement *Replace(CYContext &context);
314 virtual void Output(CYOutput &out, CYFlags flags) const;
317 struct CYCStringLess :
318 std::binary_function<const char *, const char *, bool>
320 _finline bool operator ()(const char *lhs, const char *rhs) const {
321 return strcmp(lhs, rhs) < 0;
325 struct CYIdentifierValueLess :
326 std::binary_function<CYIdentifier *, CYIdentifier *, bool>
328 _finline bool operator ()(CYIdentifier *lhs, CYIdentifier *rhs) const {
329 return CYCStringLess()(lhs->Word(), rhs->Word());
333 struct CYIdentifierFlags :
334 CYNext<CYIdentifierFlags>
336 CYIdentifier *identifier_;
337 CYIdentifierKind kind_;
341 CYIdentifierFlags(CYIdentifier *identifier, CYIdentifierKind kind, CYIdentifierFlags *next = NULL) :
342 CYNext<CYIdentifierFlags>(next),
343 identifier_(identifier),
355 CYIdentifierFlags *shadow_;
357 CYIdentifierFlags *internal_;
359 CYScope(bool transparent, CYContext &context);
361 CYIdentifierFlags *Lookup(CYContext &context, const char *word);
362 CYIdentifierFlags *Lookup(CYContext &context, CYIdentifier *identifier);
364 CYIdentifierFlags *Declare(CYContext &context, CYIdentifier *identifier, CYIdentifierKind kind);
365 void Merge(CYContext &context, const CYIdentifierFlags *flags);
367 void Close(CYContext &context, CYStatement *&statements);
368 void Close(CYContext &context);
377 CYScript(CYStatement *code) :
382 virtual void Replace(CYContext &context);
383 virtual void Output(CYOutput &out) const;
394 CYIdentifier *super_;
396 CYNonLocal *nonlocal_;
397 CYNonLocal *nextlocal_;
400 std::vector<CYIdentifier *> replace_;
402 CYContext(CYOptions &options) :
413 void ReplaceAll(CYStatement *&statement) {
414 if (statement == NULL)
416 CYStatement *next(statement->next_);
421 if (statement == NULL)
424 statement->SetNext(next);
427 template <typename Type_>
428 void Replace(Type_ *&value) {
429 for (;;) if (value == NULL)
432 Type_ *replace(value->Replace(*this));
433 if (replace != value)
439 void NonLocal(CYStatement *&statements);
440 CYIdentifier *Unique();
444 CYIdentifier *identifier_;
451 CYIdentifier *Target(CYContext &context) {
452 if (identifier_ == NULL)
453 identifier_ = context.Unique();
461 CYIdentifier *identifier_;
468 CYIdentifier *Identifier(CYContext &context) {
470 return next_->Identifier(context);
471 if (identifier_ == NULL)
472 identifier_ = context.Unique();
482 CYBlock(CYStatement *code) :
489 virtual CYStatement *Replace(CYContext &context);
491 virtual void Output(CYOutput &out, CYFlags flags) const;
493 virtual CYStatement *Return();
499 struct CYForInInitializer {
500 virtual CYStatement *Initialize(CYContext &context, CYExpression *value) = 0;
502 virtual CYTarget *Replace(CYContext &context) = 0;
503 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
506 struct CYFunctionParameter;
511 struct CYExpression :
514 virtual int Precedence() const = 0;
516 virtual bool RightHand() const {
520 virtual bool Eval() const {
524 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
526 virtual void Output(CYOutput &out) const;
527 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
528 void Output(CYOutput &out, int precedence, CYFlags flags) const;
530 virtual CYExpression *Replace(CYContext &context) = 0;
532 virtual CYExpression *Primitive(CYContext &context) {
536 virtual CYFunctionParameter *Parameter() const;
538 virtual CYNumber *Number(CYContext &context) {
542 virtual CYString *String(CYContext &context) {
546 virtual const char *Word() const {
555 virtual bool RightHand() const {
559 virtual bool IsNew() const {
563 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
565 virtual CYTarget *Replace(CYContext &context) = 0;
566 using CYExpression::Output;
569 #define CYAlphabetic(value) \
570 virtual bool Alphabetic() const { \
574 #define CYPrecedence(value) \
575 static const int Precedence_ = value; \
576 virtual int Precedence() const { \
577 return Precedence_; \
583 CYExpression *expression_;
586 CYCompound(CYExpression *expression, CYExpression *next) :
587 expression_(expression),
590 _assert(expression_ != NULL);
591 _assert(next != NULL);
596 virtual CYExpression *Replace(CYContext &context);
597 void Output(CYOutput &out, CYFlags flags) const;
599 virtual CYFunctionParameter *Parameter() const;
602 struct CYParenthetical :
605 CYExpression *expression_;
607 CYParenthetical(CYExpression *expression) :
608 expression_(expression)
614 virtual CYTarget *Replace(CYContext &context);
615 void Output(CYOutput &out, CYFlags flags) const;
620 struct CYFunctionParameter :
621 CYNext<CYFunctionParameter>,
626 CYFunctionParameter(CYBinding *binding, CYFunctionParameter *next = NULL) :
627 CYNext<CYFunctionParameter>(next),
632 void Replace(CYContext &context, CYStatement *&statements);
633 void Output(CYOutput &out) const;
636 struct CYComprehension :
637 CYNext<CYComprehension>,
640 CYComprehension(CYComprehension *next = NULL) :
641 CYNext<CYComprehension>(next)
645 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
646 CYFunctionParameter *Parameters(CYContext &context) const;
647 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
648 virtual void Output(CYOutput &out) const = 0;
651 struct CYForInComprehension :
655 CYExpression *iterable_;
657 CYForInComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) :
658 CYComprehension(next),
664 virtual CYFunctionParameter *Parameter(CYContext &context) const;
665 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
666 virtual void Output(CYOutput &out) const;
669 struct CYForOfComprehension :
673 CYExpression *iterable_;
675 CYForOfComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) :
676 CYComprehension(next),
682 virtual CYFunctionParameter *Parameter(CYContext &context) const;
683 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
684 virtual void Output(CYOutput &out) const;
687 struct CYIfComprehension :
692 CYIfComprehension(CYExpression *test, CYComprehension *next = NULL) :
693 CYComprehension(next),
698 virtual CYFunctionParameter *Parameter(CYContext &context) const;
699 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
700 virtual void Output(CYOutput &out) const;
703 struct CYArrayComprehension :
706 CYExpression *expression_;
707 CYComprehension *comprehensions_;
709 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
710 expression_(expression),
711 comprehensions_(comprehensions)
717 virtual CYTarget *Replace(CYContext &context);
718 virtual void Output(CYOutput &out, CYFlags flags) const;
724 CYLocation location_;
728 virtual CYExpression *Primitive(CYContext &context) {
736 virtual CYTarget *Replace(CYContext &context);
749 CYRange(uint64_t lo, uint64_t hi) :
754 bool operator [](uint8_t value) const {
755 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
758 void operator()(uint8_t value) {
761 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
765 extern CYRange DigitRange_;
766 extern CYRange WordStartRange_;
767 extern CYRange WordEndRange_;
782 CYString(const char *value) :
788 CYString(const char *value, size_t size) :
794 CYString(const CYWord *word) :
795 value_(word->Word()),
796 size_(strlen(value_))
800 const char *Value() const {
804 virtual CYIdentifier *Identifier() const;
805 virtual const char *Word() const;
807 virtual CYNumber *Number(CYContext &context);
808 virtual CYString *String(CYContext &context);
810 CYString *Concat(CYContext &out, CYString *rhs) const;
811 virtual void Output(CYOutput &out, CYFlags flags) const;
813 virtual CYExpression *PropertyName(CYContext &context);
814 virtual void PropertyName(CYOutput &out) const;
817 struct CYElementValue;
822 CYExpression *expression_;
825 CYSpan(CYExpression *expression, CYString *string, CYSpan *next) :
826 CYNext<CYSpan>(next),
827 expression_(expression),
832 CYElementValue *Replace(CYContext &context);
841 CYTemplate(CYString *string, CYSpan *spans) :
849 virtual CYString *String(CYContext &context);
851 virtual CYTarget *Replace(CYContext &context);
852 virtual void Output(CYOutput &out, CYFlags flags) const;
861 CYNumber(double value) :
866 double Value() const {
870 virtual CYNumber *Number(CYContext &context);
871 virtual CYString *String(CYContext &context);
873 virtual void Output(CYOutput &out, CYFlags flags) const;
875 virtual CYExpression *PropertyName(CYContext &context);
876 virtual void PropertyName(CYOutput &out) const;
882 CYExpression *expression_;
884 CYComputed(CYExpression *expression) :
885 expression_(expression)
889 virtual bool Computed() const {
893 virtual CYExpression *PropertyName(CYContext &context);
894 virtual void PropertyName(CYOutput &out) const;
903 CYRegEx(const char *value, size_t size) :
909 const char *Value() const {
913 virtual void Output(CYOutput &out, CYFlags flags) const;
919 virtual CYNumber *Number(CYContext &context);
920 virtual CYString *String(CYContext &context);
922 virtual void Output(CYOutput &out, CYFlags flags) const;
928 virtual CYTarget *Replace(CYContext &context);
929 virtual void Output(CYOutput &out, CYFlags flags) const;
937 virtual bool RightHand() const {
941 virtual bool Value() const = 0;
942 virtual void Output(CYOutput &out, CYFlags flags) const;
948 virtual bool Value() const {
952 virtual CYNumber *Number(CYContext &context);
953 virtual CYString *String(CYContext &context);
959 virtual bool Value() const {
963 virtual CYNumber *Number(CYContext &context);
964 virtual CYString *String(CYContext &context);
972 CYVariable(CYIdentifier *name) :
977 CYVariable(const char *name) :
978 name_(new($pool) CYIdentifier(name))
984 virtual bool Eval() const {
985 return strcmp(name_->Word(), "eval") == 0;
988 virtual CYTarget *Replace(CYContext &context);
989 virtual void Output(CYOutput &out, CYFlags flags) const;
991 virtual CYFunctionParameter *Parameter() const;
999 CYSymbol(const char *name) :
1006 virtual CYTarget *Replace(CYContext &context);
1007 virtual void Output(CYOutput &out, CYFlags flags) const;
1015 CYPrefix(CYExpression *rhs) :
1020 virtual bool Alphabetic() const = 0;
1021 virtual const char *Operator() const = 0;
1025 virtual CYExpression *Replace(CYContext &context);
1026 virtual void Output(CYOutput &out, CYFlags flags) const;
1035 CYInfix(CYExpression *lhs, CYExpression *rhs) :
1041 void SetLeft(CYExpression *lhs) {
1045 virtual bool Alphabetic() const = 0;
1046 virtual const char *Operator() const = 0;
1048 virtual CYExpression *Replace(CYContext &context);
1049 virtual void Output(CYOutput &out, CYFlags flags) const;
1057 CYPostfix(CYExpression *lhs) :
1062 virtual const char *Operator() const = 0;
1066 virtual CYExpression *Replace(CYContext &context);
1067 virtual void Output(CYOutput &out, CYFlags flags) const;
1070 struct CYAssignment :
1076 CYAssignment(CYTarget *lhs, CYExpression *rhs) :
1082 void SetRight(CYExpression *rhs) {
1086 virtual const char *Operator() const = 0;
1090 virtual CYExpression *Replace(CYContext &context);
1091 virtual void Output(CYOutput &out, CYFlags flags) const;
1099 CYExpression *value_;
1101 CYArgument(CYExpression *value, CYArgument *next = NULL) :
1102 CYNext<CYArgument>(next),
1108 CYArgument(CYWord *name, CYExpression *value, CYArgument *next = NULL) :
1109 CYNext<CYArgument>(next),
1115 CYArgument *Replace(CYContext &context);
1116 void Output(CYOutput &out) const;
1123 CYExpression *value_;
1126 CYClause(CYExpression *value, CYStatement *code) :
1132 void Replace(CYContext &context);
1133 virtual void Output(CYOutput &out) const;
1140 CYElement(CYElement *next) :
1141 CYNext<CYElement>(next)
1145 virtual bool Elision() const = 0;
1147 virtual void Replace(CYContext &context) = 0;
1150 struct CYElementValue :
1153 CYExpression *value_;
1155 CYElementValue(CYExpression *value, CYElement *next = NULL) :
1161 virtual bool Elision() const {
1162 return value_ == NULL;
1165 virtual void Replace(CYContext &context);
1166 virtual void Output(CYOutput &out) const;
1169 struct CYElementSpread :
1172 CYExpression *value_;
1174 CYElementSpread(CYExpression *value, CYElement *next = NULL) :
1180 virtual bool Elision() const {
1184 virtual void Replace(CYContext &context);
1185 virtual void Output(CYOutput &out) const;
1191 CYElement *elements_;
1193 CYArray(CYElement *elements = NULL) :
1198 virtual CYTarget *Replace(CYContext &context);
1199 virtual void Output(CYOutput &out, CYFlags flags) const;
1203 CYIdentifier *identifier_;
1204 CYExpression *initializer_;
1206 CYBinding(CYIdentifier *identifier, CYExpression *initializer = NULL) :
1207 identifier_(identifier),
1208 initializer_(initializer)
1212 CYTarget *Target(CYContext &context);
1214 virtual CYAssignment *Replace(CYContext &context, CYIdentifierKind kind);
1215 virtual void Output(CYOutput &out, CYFlags flags) const;
1218 struct CYForLexical :
1222 CYBinding *binding_;
1224 CYForLexical(bool constant, CYBinding *binding) :
1225 constant_(constant),
1230 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
1232 virtual CYTarget *Replace(CYContext &context);
1233 virtual void Output(CYOutput &out, CYFlags flags) const;
1236 struct CYForVariable :
1239 CYBinding *binding_;
1241 CYForVariable(CYBinding *binding) :
1246 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
1248 virtual CYTarget *Replace(CYContext &context);
1249 virtual void Output(CYOutput &out, CYFlags flags) const;
1256 CYBinding *binding_;
1258 CYBindings(CYBinding *binding, CYBindings *next = NULL) :
1259 CYNext<CYBindings>(next),
1264 CYExpression *Replace(CYContext &context, CYIdentifierKind kind);
1266 CYArgument *Argument(CYContext &context);
1267 CYFunctionParameter *Parameter(CYContext &context);
1269 virtual void Output(CYOutput &out) const;
1270 virtual void Output(CYOutput &out, CYFlags flags) const;
1276 CYBindings *bindings_;
1278 CYVar(CYBindings *bindings) :
1285 virtual CYForInitializer *Replace(CYContext &context);
1286 virtual void Output(CYOutput &out, CYFlags flags) const;
1293 CYBindings *bindings_;
1295 CYLexical(bool constant, CYBindings *bindings) :
1296 constant_(constant),
1303 virtual CYForInitializer *Replace(CYContext &context);
1304 virtual void Output(CYOutput &out, CYFlags flags) const;
1308 CYList<CYBindings> bindings_;
1309 CYList<CYStatement> statements_;
1311 operator bool() const {
1312 return statements_ != NULL;
1320 CYPropertyName *name_;
1322 CYProperty(CYPropertyName *name, CYProperty *next = NULL) :
1323 CYNext<CYProperty>(next),
1328 virtual bool Update() const;
1330 CYProperty *ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update);
1331 void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, bool protect);
1333 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) = 0;
1335 virtual void Replace(CYContext &context) = 0;
1336 virtual void Output(CYOutput &out) const;
1339 struct CYPropertyValue :
1342 CYExpression *value_;
1344 CYPropertyValue(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
1345 CYProperty(name, next),
1350 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1351 virtual void Replace(CYContext &context);
1352 virtual void Output(CYOutput &out) const;
1358 CYForInitializer *initializer_;
1359 CYExpression *test_;
1360 CYExpression *increment_;
1363 CYFor(CYForInitializer *initializer, CYExpression *test, CYExpression *increment, CYStatement *code) :
1364 initializer_(initializer),
1366 increment_(increment),
1373 virtual CYStatement *Replace(CYContext &context);
1374 virtual void Output(CYOutput &out, CYFlags flags) const;
1380 CYForInInitializer *initializer_;
1381 CYExpression *iterable_;
1384 CYForIn(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) :
1385 initializer_(initializer),
1386 iterable_(iterable),
1393 virtual CYStatement *Replace(CYContext &context);
1394 virtual void Output(CYOutput &out, CYFlags flags) const;
1397 struct CYForInitialized :
1400 CYBinding *binding_;
1401 CYExpression *iterable_;
1404 CYForInitialized(CYBinding *binding, CYExpression *iterable, CYStatement *code) :
1406 iterable_(iterable),
1413 virtual CYStatement *Replace(CYContext &context);
1414 virtual void Output(CYOutput &out, CYFlags flags) const;
1420 CYForInInitializer *initializer_;
1421 CYExpression *iterable_;
1424 CYForOf(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) :
1425 initializer_(initializer),
1426 iterable_(iterable),
1433 virtual CYStatement *Replace(CYContext &context);
1434 virtual void Output(CYOutput &out, CYFlags flags) const;
1440 CYProperty *properties_;
1442 CYObject(CYProperty *properties = NULL) :
1443 properties_(properties)
1447 CYTarget *Replace(CYContext &context, CYTarget *seed);
1449 virtual CYTarget *Replace(CYContext &context);
1450 void Output(CYOutput &out, CYFlags flags) const;
1456 CYExpression *object_;
1457 CYExpression *property_;
1459 CYMember(CYExpression *object, CYExpression *property) :
1465 void SetLeft(CYExpression *object) {
1470 struct CYDirectMember :
1473 CYDirectMember(CYExpression *object, CYExpression *property) :
1474 CYMember(object, property)
1480 virtual CYTarget *Replace(CYContext &context);
1481 virtual void Output(CYOutput &out, CYFlags flags) const;
1484 struct CYAttemptMember :
1487 CYAttemptMember(CYExpression *object, CYExpression *property) :
1488 CYMember(object, property)
1494 virtual CYTarget *Replace(CYContext &context);
1495 virtual void Output(CYOutput &out, CYFlags flags) const;
1498 struct CYIndirectMember :
1501 CYIndirectMember(CYExpression *object, CYExpression *property) :
1502 CYMember(object, property)
1508 virtual CYTarget *Replace(CYContext &context);
1509 virtual void Output(CYOutput &out, CYFlags flags) const;
1512 struct CYResolveMember :
1515 CYResolveMember(CYExpression *object, CYExpression *property) :
1516 CYMember(object, property)
1522 virtual CYTarget *Replace(CYContext &context);
1523 virtual void Output(CYOutput &out, CYFlags flags) const;
1526 struct CYSubscriptMember :
1529 CYSubscriptMember(CYExpression *object, CYExpression *property) :
1530 CYMember(object, property)
1536 virtual CYTarget *Replace(CYContext &context);
1537 virtual void Output(CYOutput &out, CYFlags flags) const;
1546 CYExpression *constructor_;
1547 CYArgument *arguments_;
1549 New(CYExpression *constructor, CYArgument *arguments = NULL) :
1550 constructor_(constructor),
1551 arguments_(arguments)
1555 virtual int Precedence() const {
1556 return arguments_ == NULL ? 2 : 1;
1559 virtual bool IsNew() const {
1563 virtual CYTarget *Replace(CYContext &context);
1564 virtual void Output(CYOutput &out, CYFlags flags) const;
1566 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1574 CYArgument *arguments_;
1576 CYApply(CYArgument *arguments = NULL) :
1577 arguments_(arguments)
1583 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1589 CYExpression *function_;
1591 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1597 virtual void Output(CYOutput &out, CYFlags flags) const;
1598 virtual CYTarget *Replace(CYContext &context);
1604 CYEval(CYArgument *arguments) :
1609 virtual void Output(CYOutput &out, CYFlags flags) const;
1610 virtual CYTarget *Replace(CYContext &context);
1620 CYBraced(CYTarget *lhs = NULL) :
1627 void SetLeft(CYTarget *lhs) {
1632 struct CYRubyBlock :
1637 CYRubyBlock(CYTarget *lhs, CYRubyProc *proc) :
1643 virtual CYTarget *Replace(CYContext &context);
1644 virtual void Output(CYOutput &out, CYFlags flags) const;
1646 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1654 CYExtend(CYTarget *lhs, CYProperty *properties = NULL) :
1660 virtual CYTarget *Replace(CYContext &context);
1661 virtual void Output(CYOutput &out, CYFlags flags) const;
1667 CYExpression *test_;
1669 CYStatement *false_;
1671 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1680 virtual CYStatement *Replace(CYContext &context);
1681 virtual void Output(CYOutput &out, CYFlags flags) const;
1683 virtual CYStatement *Return();
1689 CYExpression *test_;
1692 CYDoWhile(CYExpression *test, CYStatement *code) :
1700 virtual CYStatement *Replace(CYContext &context);
1701 virtual void Output(CYOutput &out, CYFlags flags) const;
1707 CYExpression *test_;
1710 CYWhile(CYExpression *test, CYStatement *code) :
1718 virtual CYStatement *Replace(CYContext &context);
1719 virtual void Output(CYOutput &out, CYFlags flags) const;
1723 CYFunctionParameter *parameters_;
1726 CYNonLocal *nonlocal_;
1729 CYIdentifier *super_;
1731 CYFunction(CYFunctionParameter *parameters, CYStatement *code) :
1732 parameters_(parameters),
1740 void Replace(CYContext &context);
1741 void Output(CYOutput &out) const;
1744 struct CYFunctionExpression :
1748 CYIdentifier *name_;
1750 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *code) :
1751 CYFunction(parameters, code),
1758 CYTarget *Replace(CYContext &context) override;
1759 virtual void Output(CYOutput &out, CYFlags flags) const;
1766 CYFatArrow(CYFunctionParameter *parameters, CYStatement *code) :
1767 CYFunction(parameters, code)
1773 CYExpression *Replace(CYContext &context) override;
1774 virtual void Output(CYOutput &out, CYFlags flags) const;
1781 CYRubyProc(CYFunctionParameter *parameters, CYStatement *code) :
1782 CYFunction(parameters, code)
1788 CYTarget *Replace(CYContext &context) override;
1789 virtual void Output(CYOutput &out, CYFlags flags) const;
1792 struct CYFunctionStatement :
1796 CYIdentifier *name_;
1798 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *code) :
1799 CYFunction(parameters, code),
1806 CYStatement *Replace(CYContext &context) override;
1807 virtual void Output(CYOutput &out, CYFlags flags) const;
1810 struct CYPropertyMethod;
1816 CYMethod(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1817 CYFunction(parameters, code),
1818 CYProperty(name, next)
1822 virtual CYFunctionExpression *Constructor();
1824 using CYProperty::Replace;
1825 virtual void Replace(CYContext &context);
1828 struct CYPropertyGetter :
1831 CYPropertyGetter(CYPropertyName *name, CYStatement *code, CYProperty *next = NULL) :
1832 CYMethod(name, NULL, code, next)
1836 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1837 virtual void Output(CYOutput &out) const;
1840 struct CYPropertySetter :
1843 CYPropertySetter(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1844 CYMethod(name, parameters, code, next)
1848 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1849 virtual void Output(CYOutput &out) const;
1852 struct CYPropertyMethod :
1855 CYPropertyMethod(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1856 CYMethod(name, parameters, code, next)
1860 bool Update() const override;
1862 virtual CYFunctionExpression *Constructor();
1864 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1865 virtual void Output(CYOutput &out) const;
1868 struct CYClassTail :
1871 CYExpression *extends_;
1873 CYFunctionExpression *constructor_;
1874 CYList<CYProperty> instance_;
1875 CYList<CYProperty> static_;
1877 CYClassTail(CYExpression *extends) :
1883 void Output(CYOutput &out) const;
1886 struct CYClassExpression :
1889 CYIdentifier *name_;
1892 CYClassExpression(CYIdentifier *name, CYClassTail *tail) :
1900 CYTarget *Replace(CYContext &context) override;
1901 virtual void Output(CYOutput &out, CYFlags flags) const;
1904 struct CYClassStatement :
1907 CYIdentifier *name_;
1910 CYClassStatement(CYIdentifier *name, CYClassTail *tail) :
1918 CYStatement *Replace(CYContext &context) override;
1919 virtual void Output(CYOutput &out, CYFlags flags) const;
1922 struct CYSuperCall :
1925 CYArgument *arguments_;
1927 CYSuperCall(CYArgument *arguments) :
1928 arguments_(arguments)
1934 CYTarget *Replace(CYContext &context) override;
1935 virtual void Output(CYOutput &out, CYFlags flags) const;
1938 struct CYSuperAccess :
1941 CYExpression *property_;
1943 CYSuperAccess(CYExpression *property) :
1950 CYTarget *Replace(CYContext &context) override;
1951 virtual void Output(CYOutput &out, CYFlags flags) const;
1957 CYExpression *expression_;
1959 CYExpress(CYExpression *expression) :
1960 expression_(expression)
1962 if (expression_ == NULL)
1968 CYForInitializer *Replace(CYContext &context) override;
1969 virtual void Output(CYOutput &out, CYFlags flags) const;
1971 virtual CYStatement *Return();
1977 CYIdentifier *label_;
1979 CYContinue(CYIdentifier *label) :
1986 CYStatement *Replace(CYContext &context) override;
1987 virtual void Output(CYOutput &out, CYFlags flags) const;
1993 CYIdentifier *label_;
1995 CYBreak(CYIdentifier *label) :
2002 CYStatement *Replace(CYContext &context) override;
2003 virtual void Output(CYOutput &out, CYFlags flags) const;
2009 CYExpression *value_;
2011 CYReturn(CYExpression *value) :
2018 CYStatement *Replace(CYContext &context) override;
2019 virtual void Output(CYOutput &out, CYFlags flags) const;
2022 struct CYYieldGenerator :
2025 CYExpression *value_;
2027 CYYieldGenerator(CYExpression *value) :
2034 CYExpression *Replace(CYContext &context) override;
2035 virtual void Output(CYOutput &out, CYFlags flags) const;
2038 struct CYYieldValue :
2041 CYExpression *value_;
2043 CYYieldValue(CYExpression *value) :
2050 virtual CYExpression *Replace(CYContext &context);
2051 virtual void Output(CYOutput &out, CYFlags flags) const;
2059 virtual CYForInitializer *Replace(CYContext &context);
2060 virtual void Output(CYOutput &out, CYFlags flags) const;
2068 CYFinally(CYStatement *code) :
2073 void Replace(CYContext &context);
2074 virtual void Output(CYOutput &out) const;
2077 struct CYTypeSpecifier :
2080 virtual CYTarget *Replace(CYContext &context) = 0;
2083 struct CYTypeError :
2089 virtual CYTarget *Replace(CYContext &context);
2090 virtual void Output(CYOutput &out) const;
2093 enum CYTypeSigning {
2099 struct CYTypeCharacter :
2102 CYTypeSigning signing_;
2104 CYTypeCharacter(CYTypeSigning signing) :
2109 virtual CYTarget *Replace(CYContext &context);
2110 virtual void Output(CYOutput &out) const;
2113 struct CYTypeInt128 :
2116 CYTypeSigning signing_;
2118 CYTypeInt128(CYTypeSigning signing) :
2123 virtual CYTarget *Replace(CYContext &context);
2124 virtual void Output(CYOutput &out) const;
2127 struct CYTypeIntegral :
2130 CYTypeSigning signing_;
2133 CYTypeIntegral(CYTypeSigning signing, int length = 1) :
2139 CYTypeIntegral *Long() {
2140 if (length_ != 1 && length_ != 2)
2146 CYTypeIntegral *Short() {
2153 CYTypeIntegral *Signed() {
2154 if (signing_ != CYTypeNeutral)
2156 signing_ = CYTypeSigned;
2160 CYTypeIntegral *Unsigned() {
2161 if (signing_ != CYTypeNeutral)
2163 signing_ = CYTypeUnsigned;
2167 virtual CYTarget *Replace(CYContext &context);
2168 virtual void Output(CYOutput &out) const;
2171 struct CYTypeFloating :
2176 CYTypeFloating(int length) :
2181 virtual CYTarget *Replace(CYContext &context);
2182 virtual void Output(CYOutput &out) const;
2191 virtual CYTarget *Replace(CYContext &context);
2192 virtual void Output(CYOutput &out) const;
2195 enum CYTypeReferenceKind {
2196 CYTypeReferenceStruct,
2197 CYTypeReferenceEnum,
2200 struct CYTypeReference :
2203 CYTypeReferenceKind kind_;
2204 CYIdentifier *name_;
2206 CYTypeReference(CYTypeReferenceKind kind, CYIdentifier *name) :
2212 virtual CYTarget *Replace(CYContext &context);
2213 virtual void Output(CYOutput &out) const;
2216 struct CYTypeVariable :
2219 CYIdentifier *name_;
2221 CYTypeVariable(CYIdentifier *name) :
2226 CYTypeVariable(const char *name) :
2227 name_(new($pool) CYIdentifier(name))
2231 virtual CYTarget *Replace(CYContext &context);
2232 virtual void Output(CYOutput &out) const;
2235 struct CYTypeFunctionWith;
2237 struct CYTypeModifier :
2238 CYNext<CYTypeModifier>
2240 CYTypeModifier(CYTypeModifier *next) :
2241 CYNext<CYTypeModifier>(next)
2245 virtual int Precedence() const = 0;
2247 virtual CYTarget *Replace_(CYContext &context, CYTarget *type) = 0;
2248 CYTarget *Replace(CYContext &context, CYTarget *type);
2250 virtual void Output(CYOutput &out, CYPropertyName *name) const = 0;
2251 void Output(CYOutput &out, int precedence, CYPropertyName *name, bool space) const;
2253 virtual CYTypeFunctionWith *Function() { return NULL; }
2256 struct CYTypeArrayOf :
2259 CYExpression *size_;
2261 CYTypeArrayOf(CYExpression *size, CYTypeModifier *next = NULL) :
2262 CYTypeModifier(next),
2269 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2270 void Output(CYOutput &out, CYPropertyName *name) const override;
2273 struct CYTypeConstant :
2276 CYTypeConstant(CYTypeModifier *next = NULL) :
2277 CYTypeModifier(next)
2283 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2284 void Output(CYOutput &out, CYPropertyName *name) const override;
2287 struct CYTypePointerTo :
2290 CYTypePointerTo(CYTypeModifier *next = NULL) :
2291 CYTypeModifier(next)
2297 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2298 void Output(CYOutput &out, CYPropertyName *name) const override;
2301 struct CYTypeVolatile :
2304 CYTypeVolatile(CYTypeModifier *next = NULL) :
2305 CYTypeModifier(next)
2311 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2312 void Output(CYOutput &out, CYPropertyName *name) const override;
2318 CYTypeSpecifier *specifier_;
2319 CYTypeModifier *modifier_;
2321 CYType(CYTypeSpecifier *specifier = NULL, CYTypeModifier *modifier = NULL) :
2322 specifier_(specifier),
2327 inline CYType *Modify(CYTypeModifier *modifier) {
2328 CYSetLast(modifier_) = modifier;
2332 void Output(CYOutput &out, CYPropertyName *name) const;
2334 virtual CYTarget *Replace(CYContext &context);
2335 virtual void Output(CYOutput &out) const;
2337 CYTypeFunctionWith *Function();
2340 struct CYTypedLocation :
2343 CYLocation location_;
2345 CYTypedLocation(const CYLocation &location) :
2351 struct CYTypedName :
2354 CYPropertyName *name_;
2356 CYTypedName(const CYLocation &location, CYPropertyName *name = NULL) :
2357 CYTypedLocation(location),
2363 struct CYEncodedType :
2368 CYEncodedType(CYType *typed) :
2375 virtual CYTarget *Replace(CYContext &context);
2376 virtual void Output(CYOutput &out, CYFlags flags) const;
2379 struct CYTypedParameter :
2380 CYNext<CYTypedParameter>,
2384 CYIdentifier *name_;
2386 CYTypedParameter(CYType *type, CYIdentifier *name, CYTypedParameter *next = NULL) :
2387 CYNext<CYTypedParameter>(next),
2393 CYArgument *Argument(CYContext &context);
2394 CYFunctionParameter *Parameters(CYContext &context);
2395 CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
2397 virtual void Output(CYOutput &out) const;
2400 struct CYTypedFormal {
2402 CYTypedParameter *parameters_;
2404 CYTypedFormal(bool variadic) :
2405 variadic_(variadic),
2415 CYTypedParameter *parameters_;
2418 CYLambda(CYType *typed, CYTypedParameter *parameters, CYStatement *code) :
2420 parameters_(parameters),
2427 virtual CYTarget *Replace(CYContext &context);
2428 virtual void Output(CYOutput &out, CYFlags flags) const;
2437 CYModule(CYWord *part, CYModule *next = NULL) :
2438 CYNext<CYModule>(next),
2443 CYString *Replace(CYContext &context, const char *separator) const;
2444 void Output(CYOutput &out) const;
2452 CYImport(CYModule *module) :
2459 virtual CYStatement *Replace(CYContext &context);
2460 virtual void Output(CYOutput &out, CYFlags flags) const;
2463 struct CYImportSpecifier :
2464 CYNext<CYImportSpecifier>
2467 CYIdentifier *binding_;
2469 CYImportSpecifier(CYWord *name, CYIdentifier *binding) :
2475 CYStatement *Replace(CYContext &context, CYIdentifier *module);
2478 struct CYImportDeclaration :
2481 CYImportSpecifier *specifiers_;
2484 CYImportDeclaration(CYImportSpecifier *specifiers, CYString *module) :
2485 specifiers_(specifiers),
2492 virtual CYStatement *Replace(CYContext &context);
2493 virtual void Output(CYOutput &out, CYFlags flags) const;
2496 struct CYExternalExpression :
2501 CYPropertyName *name_;
2503 CYExternalExpression(CYString *abi, CYType *type, CYPropertyName *name) :
2512 virtual CYTarget *Replace(CYContext &context);
2513 virtual void Output(CYOutput &out, CYFlags flags) const;
2516 struct CYExternalDefinition :
2521 CYIdentifier *name_;
2523 CYExternalDefinition(CYString *abi, CYType *type, CYIdentifier *name) :
2532 virtual CYStatement *Replace(CYContext &context);
2533 virtual void Output(CYOutput &out, CYFlags flags) const;
2536 struct CYTypeExpression :
2541 CYTypeExpression(CYType *typed) :
2548 virtual CYTarget *Replace(CYContext &context);
2549 virtual void Output(CYOutput &out, CYFlags flags) const;
2552 struct CYTypeDefinition :
2556 CYIdentifier *name_;
2558 CYTypeDefinition(CYType *type, CYIdentifier *name) :
2566 virtual CYStatement *Replace(CYContext &context);
2567 virtual void Output(CYOutput &out, CYFlags flags) const;
2570 struct CYTypeBlockWith :
2573 CYTypedParameter *parameters_;
2575 CYTypeBlockWith(CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
2576 CYTypeModifier(next),
2577 parameters_(parameters)
2583 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2584 void Output(CYOutput &out, CYPropertyName *name) const override;
2587 struct CYTypeFunctionWith :
2591 CYTypedParameter *parameters_;
2593 CYTypeFunctionWith(bool variadic, CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
2594 CYTypeModifier(next),
2595 variadic_(variadic),
2596 parameters_(parameters)
2602 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2603 void Output(CYOutput &out, CYPropertyName *name) const override;
2605 virtual CYTypeFunctionWith *Function() { return this; }
2608 struct CYTypeStructField :
2609 CYNext<CYTypeStructField>
2612 CYPropertyName *name_;
2614 CYTypeStructField(CYType *type, CYPropertyName *name, CYTypeStructField *next = NULL) :
2615 CYNext<CYTypeStructField>(next),
2622 struct CYStructTail :
2625 CYTypeStructField *fields_;
2627 CYStructTail(CYTypeStructField *fields) :
2632 CYTarget *Replace(CYContext &context);
2633 virtual void Output(CYOutput &out) const;
2636 struct CYTypeStruct :
2639 CYIdentifier *name_;
2640 CYStructTail *tail_;
2642 CYTypeStruct(CYIdentifier *name, CYStructTail *tail) :
2648 virtual CYTarget *Replace(CYContext &context);
2649 virtual void Output(CYOutput &out) const;
2652 struct CYStructDefinition :
2655 CYIdentifier *name_;
2656 CYStructTail *tail_;
2658 CYStructDefinition(CYIdentifier *name, CYStructTail *tail) :
2666 virtual CYStatement *Replace(CYContext &context);
2667 virtual void Output(CYOutput &out, CYFlags flags) const;
2670 struct CYEnumConstant :
2671 CYNext<CYEnumConstant>
2673 CYIdentifier *name_;
2676 CYEnumConstant(CYIdentifier *name, CYNumber *value, CYEnumConstant *next = NULL) :
2677 CYNext<CYEnumConstant>(next),
2687 CYIdentifier *name_;
2688 CYTypeSpecifier *specifier_;
2689 CYEnumConstant *constants_;
2691 CYTypeEnum(CYIdentifier *name, CYTypeSpecifier *specifier, CYEnumConstant *constants) :
2693 specifier_(specifier),
2694 constants_(constants)
2698 virtual CYTarget *Replace(CYContext &context);
2699 virtual void Output(CYOutput &out) const;
2708 CYIdentifier *name_;
2711 Catch(CYIdentifier *name, CYStatement *code) :
2717 void Replace(CYContext &context);
2718 virtual void Output(CYOutput &out) const;
2726 CYFinally *finally_;
2728 Try(CYStatement *code, Catch *_catch, CYFinally *finally) :
2737 virtual CYStatement *Replace(CYContext &context);
2738 virtual void Output(CYOutput &out, CYFlags flags) const;
2744 CYExpression *value_;
2746 Throw(CYExpression *value = NULL) :
2753 virtual CYStatement *Replace(CYContext &context);
2754 virtual void Output(CYOutput &out, CYFlags flags) const;
2762 CYExpression *scope_;
2765 CYWith(CYExpression *scope, CYStatement *code) :
2773 virtual CYStatement *Replace(CYContext &context);
2774 virtual void Output(CYOutput &out, CYFlags flags) const;
2780 CYExpression *value_;
2783 CYSwitch(CYExpression *value, CYClause *clauses) :
2791 virtual CYStatement *Replace(CYContext &context);
2792 virtual void Output(CYOutput &out, CYFlags flags) const;
2804 virtual CYStatement *Replace(CYContext &context);
2805 virtual void Output(CYOutput &out, CYFlags flags) const;
2808 struct CYCondition :
2811 CYExpression *test_;
2812 CYExpression *true_;
2813 CYExpression *false_;
2815 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
2824 virtual CYExpression *Replace(CYContext &context);
2825 virtual void Output(CYOutput &out, CYFlags flags) const;
2828 struct CYAddressOf :
2831 CYAddressOf(CYExpression *rhs) :
2836 virtual const char *Operator() const {
2842 virtual CYExpression *Replace(CYContext &context);
2850 CYIndirect(CYExpression *rhs) :
2855 // XXX: this should be checked
2858 virtual CYTarget *Replace(CYContext &context);
2859 virtual void Output(CYOutput &out, CYFlags flags) const;
2863 virtual CYExpression *Replace(CYContext &context);
2865 #define CYPostfix_(op, name, args...) \
2866 struct CY ## name : \
2869 CY ## name(CYExpression *lhs) : \
2874 virtual const char *Operator() const { \
2879 #define CYPrefix_(alphabetic, op, name, args...) \
2880 struct CY ## name : \
2883 CY ## name(CYExpression *rhs) : \
2888 CYAlphabetic(alphabetic) \
2890 virtual const char *Operator() const { \
2895 #define CYInfix_(alphabetic, precedence, op, name, args...) \
2896 struct CY ## name : \
2899 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
2904 CYAlphabetic(alphabetic) \
2905 CYPrecedence(precedence) \
2907 virtual const char *Operator() const { \
2912 #define CYAssignment_(op, name, args...) \
2913 struct CY ## name ## Assign : \
2916 CY ## name ## Assign(CYTarget *lhs, CYExpression *rhs) : \
2917 CYAssignment(lhs, rhs) \
2921 virtual const char *Operator() const { \
2926 CYPostfix_("++", PostIncrement)
2927 CYPostfix_("--", PostDecrement)
2929 CYPrefix_(true, "delete", Delete)
2930 CYPrefix_(true, "void", Void)
2931 CYPrefix_(true, "typeof", TypeOf)
2932 CYPrefix_(false, "++", PreIncrement)
2933 CYPrefix_(false, "--", PreDecrement)
2934 CYPrefix_(false, "+", Affirm)
2935 CYPrefix_(false, "-", Negate)
2936 CYPrefix_(false, "~", BitwiseNot)
2937 CYPrefix_(false, "!", LogicalNot)
2939 CYInfix_(false, 5, "*", Multiply, CYReplace)
2940 CYInfix_(false, 5, "/", Divide)
2941 CYInfix_(false, 5, "%", Modulus)
2942 CYInfix_(false, 6, "+", Add, CYReplace)
2943 CYInfix_(false, 6, "-", Subtract)
2944 CYInfix_(false, 7, "<<", ShiftLeft)
2945 CYInfix_(false, 7, ">>", ShiftRightSigned)
2946 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
2947 CYInfix_(false, 8, "<", Less)
2948 CYInfix_(false, 8, ">", Greater)
2949 CYInfix_(false, 8, "<=", LessOrEqual)
2950 CYInfix_(false, 8, ">=", GreaterOrEqual)
2951 CYInfix_(true, 8, "instanceof", InstanceOf)
2952 CYInfix_(true, 8, "in", In)
2953 CYInfix_(false, 9, "==", Equal)
2954 CYInfix_(false, 9, "!=", NotEqual)
2955 CYInfix_(false, 9, "===", Identical)
2956 CYInfix_(false, 9, "!==", NotIdentical)
2957 CYInfix_(false, 10, "&", BitwiseAnd)
2958 CYInfix_(false, 11, "^", BitwiseXOr)
2959 CYInfix_(false, 12, "|", BitwiseOr)
2960 CYInfix_(false, 13, "&&", LogicalAnd)
2961 CYInfix_(false, 14, "||", LogicalOr)
2963 CYAssignment_("=", )
2964 CYAssignment_("*=", Multiply)
2965 CYAssignment_("/=", Divide)
2966 CYAssignment_("%=", Modulus)
2967 CYAssignment_("+=", Add)
2968 CYAssignment_("-=", Subtract)
2969 CYAssignment_("<<=", ShiftLeft)
2970 CYAssignment_(">>=", ShiftRightSigned)
2971 CYAssignment_(">>>=", ShiftRightUnsigned)
2972 CYAssignment_("&=", BitwiseAnd)
2973 CYAssignment_("^=", BitwiseXOr)
2974 CYAssignment_("|=", BitwiseOr)
2976 #endif/*CYCRIPT_PARSER_HPP*/