]> git.saurik.com Git - cycript.git/blob - Parser.hpp
ebcbb7f8f577b48ca154d52427d1f18fd0e4598d
[cycript.git] / Parser.hpp
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2010 Jay Freeman (saurik)
3 */
4
5 /* GNU Lesser General Public License, Version 3 {{{ */
6 /*
7 * Cycript is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * Cycript is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
19 **/
20 /* }}} */
21
22 #ifndef CYPARSER_HPP
23 #define CYPARSER_HPP
24
25 #include <iostream>
26
27 #include <string>
28 #include <vector>
29 #include <map>
30 #include <set>
31
32 #include <cstdio>
33 #include <cstdlib>
34
35 #include "location.hh"
36 #include "Pooling.hpp"
37 #include "Options.hpp"
38
39 class CYContext;
40
41 template <typename Type_>
42 struct CYNext {
43 Type_ *next_;
44
45 CYNext() :
46 next_(NULL)
47 {
48 }
49
50 CYNext(Type_ *next) :
51 next_(next)
52 {
53 }
54
55 void SetNext(Type_ *next) {
56 next_ = next;
57 }
58 };
59
60 #define CYForEach(value, list) \
61 for (__typeof__(*list) *value(list); value != NULL; value = value->next_)
62
63 struct CYThing {
64 virtual ~CYThing() {
65 }
66
67 virtual void Output(struct CYOutput &out) const = 0;
68 };
69
70 struct CYOutput {
71 std::ostream &out_;
72 CYOptions &options_;
73 bool pretty_;
74 unsigned indent_;
75 bool right_;
76
77 enum {
78 NoMode,
79 NoLetter,
80 NoPlus,
81 NoHyphen,
82 Terminated
83 } mode_;
84
85 CYOutput(std::ostream &out, CYOptions &options) :
86 out_(out),
87 options_(options),
88 pretty_(false),
89 indent_(0),
90 right_(false),
91 mode_(NoMode)
92 {
93 }
94
95 void Check(char value);
96 void Terminate();
97
98 CYOutput &operator <<(char rhs);
99 CYOutput &operator <<(const char *rhs);
100
101 _finline CYOutput &operator <<(const CYThing *rhs) {
102 if (rhs != NULL)
103 rhs->Output(*this);
104 return *this;
105 }
106
107 _finline CYOutput &operator <<(const CYThing &rhs) {
108 rhs.Output(*this);
109 return *this;
110 }
111 };
112
113 struct CYPropertyName {
114 virtual void PropertyName(CYOutput &out) const = 0;
115
116 virtual ~CYPropertyName() {
117 }
118 };
119
120 struct CYExpression;
121
122 enum CYNeeded {
123 CYNever = -1,
124 CYSometimes = 0,
125 CYAlways = 1,
126 };
127
128 enum CYFlags {
129 CYNoFlags = 0,
130 CYNoBrace = (1 << 0),
131 CYNoFunction = (1 << 1),
132 CYNoIn = (1 << 2),
133 CYNoCall = (1 << 3),
134 CYNoRightHand = (1 << 4),
135 CYNoDangle = (1 << 5),
136 CYNoInteger = (1 << 6),
137 CYNoBF = (CYNoBrace | CYNoFunction),
138 };
139
140 struct CYStatement :
141 CYNext<CYStatement>
142 {
143 virtual ~CYStatement() {
144 }
145
146 void Single(CYOutput &out, CYFlags flags) const;
147 void Multiple(CYOutput &out, CYFlags flags = CYNoFlags) const;
148
149 virtual CYStatement *Collapse(CYContext &context);
150 virtual CYStatement *Replace(CYContext &context) = 0;
151
152 private:
153 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
154 };
155
156 struct CYStatements {
157 CYStatement *first_;
158 CYStatement *last_;
159
160 CYStatements() :
161 first_(NULL),
162 last_(NULL)
163 {
164 }
165
166 operator CYStatement *() const {
167 return first_;
168 }
169
170 CYStatements &operator ->*(CYStatement *next) {
171 if (next != NULL)
172 if (first_ == NULL) {
173 first_ = next;
174 last_ = next;
175 } else for (;; last_ = last_->next_)
176 if (last_->next_ == NULL) {
177 last_->next_ = next;
178 last_ = next;
179 break;
180 }
181 return *this;
182 }
183 };
184
185 struct CYClassName {
186 virtual ~CYClassName() {
187 }
188
189 virtual CYExpression *ClassName(CYContext &context, bool object) = 0;
190 virtual void ClassName(CYOutput &out, bool object) const = 0;
191 };
192
193 struct CYWord :
194 CYThing,
195 CYPropertyName,
196 CYClassName
197 {
198 const char *word_;
199
200 CYWord(const char *word) :
201 word_(word)
202 {
203 }
204
205 void Set(const char *value) {
206 word_ = value;
207 }
208
209 virtual const char *Word() const;
210 virtual void Output(CYOutput &out) const;
211
212 virtual CYExpression *ClassName(CYContext &context, bool object);
213 virtual void ClassName(CYOutput &out, bool object) const;
214 virtual void PropertyName(CYOutput &out) const;
215 };
216
217 _finline std::ostream &operator <<(std::ostream &lhs, const CYWord &rhs) {
218 lhs << &rhs << '=';
219 return lhs << rhs.Word();
220 }
221
222 struct CYIdentifier :
223 CYNext<CYIdentifier>,
224 CYWord
225 {
226 CYIdentifier *replace_;
227 size_t offset_;
228 size_t usage_;
229
230 CYIdentifier(const char *word) :
231 CYWord(word),
232 replace_(NULL),
233 offset_(0),
234 usage_(0)
235 {
236 }
237
238 virtual const char *Word() const;
239 CYIdentifier *Replace(CYContext &context);
240 };
241
242 struct CYComment :
243 CYStatement
244 {
245 const char *value_;
246
247 CYComment(const char *value) :
248 value_(value)
249 {
250 }
251
252 virtual CYStatement *Replace(CYContext &context);
253 virtual void Output(CYOutput &out, CYFlags flags) const;
254 };
255
256 struct CYLabel :
257 CYStatement
258 {
259 CYIdentifier *name_;
260 CYStatement *statement_;
261
262 CYLabel(CYIdentifier *name, CYStatement *statement) :
263 name_(name),
264 statement_(statement)
265 {
266 }
267
268 virtual CYStatement *Replace(CYContext &context);
269 virtual void Output(CYOutput &out, CYFlags flags) const;
270 };
271
272 struct CYCStringLess :
273 std::binary_function<const char *, const char *, bool>
274 {
275 _finline bool operator ()(const char *lhs, const char *rhs) const {
276 return strcmp(lhs, rhs) < 0;
277 }
278 };
279
280 struct CYIdentifierValueLess :
281 std::binary_function<CYIdentifier *, CYIdentifier *, bool>
282 {
283 _finline bool operator ()(CYIdentifier *lhs, CYIdentifier *rhs) const {
284 return CYCStringLess()(lhs->Word(), rhs->Word());
285 }
286 };
287
288 enum CYIdentifierFlags {
289 CYIdentifierArgument,
290 CYIdentifierVariable,
291 CYIdentifierOther,
292 CYIdentifierMagic,
293 CYIdentifierCatch,
294 };
295
296 typedef std::set<const char *, CYCStringLess> CYCStringSet;
297 typedef std::set<CYIdentifier *, CYIdentifierValueLess> CYIdentifierValueSet;
298 typedef std::map<CYIdentifier *, CYIdentifierFlags> CYIdentifierAddressFlagsMap;
299
300 struct CYIdentifierUsage {
301 CYIdentifier *identifier_;
302 size_t usage_;
303 };
304
305 typedef std::vector<CYIdentifierUsage> CYIdentifierUsageVector;
306
307 // XXX: strategy pattern, maybe subclass
308 enum CYScopeType {
309 CYScopeCatch,
310 CYScopeFunction,
311 CYScopeProgram,
312 };
313
314 struct CYScope {
315 CYScopeType type_;
316
317 CYContext &context_;
318 CYStatement *&statements_;
319
320 CYScope *parent_;
321
322 CYIdentifierAddressFlagsMap internal_;
323 CYIdentifierValueSet identifiers_;
324
325 CYScope(CYScopeType type, CYContext &context, CYStatement *&statements);
326
327 void Close();
328
329 void Declare(CYContext &context, CYIdentifier *identifier, CYIdentifierFlags flags);
330 virtual CYIdentifier *Lookup(CYContext &context, CYIdentifier *identifier);
331 void Merge(CYContext &context, CYIdentifier *identifier);
332 void Scope(CYContext &context, CYStatement *&statements);
333 };
334
335 struct CYProgram :
336 CYThing
337 {
338 CYStatement *statements_;
339
340 CYProgram(CYStatement *statements) :
341 statements_(statements)
342 {
343 }
344
345 virtual void Replace(CYContext &context);
346 virtual void Output(CYOutput &out) const;
347 };
348
349 struct CYNonLocal;
350
351 struct CYContext {
352 CYOptions &options_;
353
354 CYScope *scope_;
355 CYIdentifierUsageVector rename_;
356
357 CYNonLocal *nonlocal_;
358 CYNonLocal *nextlocal_;
359 unsigned unique_;
360
361 CYContext(CYOptions &options) :
362 options_(options),
363 scope_(NULL),
364 nonlocal_(NULL),
365 nextlocal_(NULL),
366 unique_(0)
367 {
368 }
369
370 virtual ~CYContext() {
371 }
372
373 template <typename Type_>
374 void ReplaceAll(Type_ *&values) {
375 Type_ **last(&values);
376 CYForEach (next, values) {
377 Replace(*last);
378 last = &(*last)->next_;
379 }
380 }
381
382 template <typename Type_>
383 void Replace(Type_ *&value) {
384 for (;;) if (value == NULL)
385 break;
386 else {
387 Type_ *replace(value->Replace(*this));
388 if (replace != value)
389 value = replace;
390 else break;
391 }
392 }
393
394 void NonLocal(CYStatement *&statements);
395 CYIdentifier *Unique();
396 };
397
398 struct CYNonLocal {
399 CYIdentifier *identifier_;
400
401 CYNonLocal() :
402 identifier_(NULL)
403 {
404 }
405
406 CYIdentifier *Target(CYContext &context) {
407 if (identifier_ == NULL)
408 identifier_ = context.Unique();
409 return identifier_;
410 }
411 };
412
413 struct CYBlock :
414 CYStatement,
415 CYThing
416 {
417 CYStatement *statements_;
418
419 CYBlock(CYStatement *statements) :
420 statements_(statements)
421 {
422 }
423
424 operator CYStatement *() const {
425 return statements_;
426 }
427
428 void AddPrev(CYStatement *statement) {
429 CYStatement *last(statement);
430 while (last->next_ != NULL)
431 last = last->next_;
432 last->SetNext(statements_);
433 statements_ = statement;
434 }
435
436 virtual CYStatement *Replace(CYContext &context);
437
438 virtual void Output(CYOutput &out) const;
439 virtual void Output(CYOutput &out, CYFlags flags) const;
440 };
441
442 enum CYState {
443 CYClear,
444 CYRestricted,
445 CYNewLine
446 };
447
448 class CYDriver {
449 public:
450 CYState state_;
451 void *scanner_;
452
453 const char *data_;
454 size_t size_;
455 FILE *file_;
456
457 bool strict_;
458
459 enum Condition {
460 RegExpCondition,
461 XMLContentCondition,
462 XMLTagCondition,
463 };
464
465 std::string filename_;
466
467 struct Error {
468 bool warning_;
469 cy::location location_;
470 std::string message_;
471 };
472
473 typedef std::vector<Error> Errors;
474
475 CYProgram *program_;
476 Errors errors_;
477
478 bool auto_;
479
480 struct Context {
481 CYExpression *context_;
482
483 Context(CYExpression *context) :
484 context_(context)
485 {
486 }
487
488 typedef std::vector<CYWord *> Words;
489 Words words_;
490 };
491
492 typedef std::vector<Context> Contexts;
493 Contexts contexts_;
494
495 CYExpression *context_;
496
497 enum Mode {
498 AutoNone,
499 AutoPrimary,
500 AutoDirect,
501 AutoIndirect,
502 AutoMessage
503 } mode_;
504
505 private:
506 void ScannerInit();
507 void ScannerDestroy();
508
509 public:
510 CYDriver(const std::string &filename = "");
511 ~CYDriver();
512
513 Condition GetCondition();
514 void SetCondition(Condition condition);
515
516 void PushCondition(Condition condition);
517 void PopCondition();
518
519 void Warning(const cy::location &location, const char *message);
520 };
521
522 struct CYForInitialiser {
523 virtual ~CYForInitialiser() {
524 }
525
526 virtual void For(CYOutput &out) const = 0;
527 virtual CYExpression *Replace(CYContext &context) = 0;
528 };
529
530 struct CYForInInitialiser {
531 virtual ~CYForInInitialiser() {
532 }
533
534 virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
535 virtual const char *ForEachIn() const = 0;
536 virtual CYExpression *ForEachIn(CYContext &out) = 0;
537 virtual CYExpression *Replace(CYContext &context) = 0;
538 };
539
540 struct CYNumber;
541 struct CYString;
542
543 struct CYExpression :
544 CYNext<CYExpression>,
545 CYForInitialiser,
546 CYForInInitialiser,
547 CYClassName,
548 CYThing
549 {
550 virtual unsigned Precedence() const = 0;
551
552 virtual bool RightHand() const {
553 return true;
554 }
555
556 virtual void For(CYOutput &out) const;
557 virtual void ForIn(CYOutput &out, CYFlags flags) const;
558
559 virtual const char *ForEachIn() const;
560 virtual CYExpression *ForEachIn(CYContext &out);
561
562 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
563
564 virtual void Output(CYOutput &out) const;
565 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
566 void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
567
568 virtual CYExpression *ClassName(CYContext &context, bool object);
569 virtual void ClassName(CYOutput &out, bool object) const;
570
571 virtual CYExpression *Replace(CYContext &context) = 0;
572
573 virtual CYExpression *Primitive(CYContext &context) {
574 return this;
575 }
576
577 virtual CYNumber *Number(CYContext &context) {
578 return NULL;
579 }
580
581 virtual CYString *String(CYContext &context) {
582 return NULL;
583 }
584
585 virtual const char *Word() const {
586 return NULL;
587 }
588 };
589
590 #define CYAlphabetic(value) \
591 virtual bool Alphabetic() const { \
592 return value; \
593 }
594
595 #define CYPrecedence(value) \
596 static const unsigned Precedence_ = value; \
597 virtual unsigned Precedence() const { \
598 return Precedence_; \
599 }
600
601 #define CYRightHand(value) \
602 virtual bool RightHand() const { \
603 return value; \
604 }
605
606 struct CYCompound :
607 CYExpression
608 {
609 CYExpression *expressions_;
610
611 CYCompound(CYExpression *expressions = NULL) :
612 expressions_(expressions)
613 {
614 }
615
616 void AddPrev(CYExpression *expression) {
617 CYExpression *last(expression);
618 while (last->next_ != NULL)
619 last = last->next_;
620 last->SetNext(expressions_);
621 expressions_ = expression;
622 }
623
624 CYPrecedence(17)
625
626 virtual CYExpression *Replace(CYContext &context);
627 void Output(CYOutput &out, CYFlags flags) const;
628 };
629
630 struct CYFunctionParameter :
631 CYNext<CYFunctionParameter>,
632 CYThing
633 {
634 CYIdentifier *name_;
635
636 CYFunctionParameter(CYIdentifier *name, CYFunctionParameter *next = NULL) :
637 CYNext<CYFunctionParameter>(next),
638 name_(name)
639 {
640 }
641
642 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
643 virtual void Output(CYOutput &out) const;
644 };
645
646 struct CYOptionalFunctionParameter :
647 CYFunctionParameter
648 {
649 CYExpression *initializer_;
650
651 CYOptionalFunctionParameter(CYIdentifier *name, CYExpression *initializer, CYFunctionParameter *next = NULL) :
652 CYFunctionParameter(name, next),
653 initializer_(initializer)
654 {
655 }
656
657 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
658 virtual void Output(CYOutput &out) const;
659 };
660
661 struct CYComprehension :
662 CYNext<CYComprehension>,
663 CYThing
664 {
665 virtual const char *Name() const = 0;
666
667 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
668 CYFunctionParameter *Parameters(CYContext &context) const;
669 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
670 virtual void Output(CYOutput &out) const = 0;
671 };
672
673 struct CYForInComprehension :
674 CYComprehension
675 {
676 CYIdentifier *name_;
677 CYExpression *set_;
678
679 CYForInComprehension(CYIdentifier *name, CYExpression *set) :
680 name_(name),
681 set_(set)
682 {
683 }
684
685 virtual const char *Name() const {
686 return name_->Word();
687 }
688
689 virtual CYFunctionParameter *Parameter(CYContext &context) const;
690 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
691 virtual void Output(CYOutput &out) const;
692 };
693
694 struct CYForEachInComprehension :
695 CYComprehension
696 {
697 CYIdentifier *name_;
698 CYExpression *set_;
699
700 CYForEachInComprehension(CYIdentifier *name, CYExpression *set) :
701 name_(name),
702 set_(set)
703 {
704 }
705
706 virtual const char *Name() const {
707 return name_->Word();
708 }
709
710 virtual CYFunctionParameter *Parameter(CYContext &context) const;
711 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
712 virtual void Output(CYOutput &out) const;
713 };
714
715 struct CYIfComprehension :
716 CYComprehension
717 {
718 CYExpression *test_;
719
720 CYIfComprehension(CYExpression *test) :
721 test_(test)
722 {
723 }
724
725 virtual const char *Name() const {
726 return NULL;
727 }
728
729 virtual CYFunctionParameter *Parameter(CYContext &context) const;
730 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
731 virtual void Output(CYOutput &out) const;
732 };
733
734 struct CYArrayComprehension :
735 CYExpression
736 {
737 CYExpression *expression_;
738 CYComprehension *comprehensions_;
739
740 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
741 expression_(expression),
742 comprehensions_(comprehensions)
743 {
744 }
745
746 CYPrecedence(0)
747
748 virtual CYExpression *Replace(CYContext &context);
749 virtual void Output(CYOutput &out, CYFlags flags) const;
750 };
751
752 struct CYLiteral :
753 CYExpression
754 {
755 CYPrecedence(0)
756 CYRightHand(false)
757 };
758
759 struct CYTrivial :
760 CYLiteral
761 {
762 virtual CYExpression *Replace(CYContext &context);
763 };
764
765 struct CYMagic :
766 CYExpression
767 {
768 CYPrecedence(0)
769 CYRightHand(false)
770 };
771
772 struct CYRange {
773 uint64_t lo_;
774 uint64_t hi_;
775
776 CYRange(uint64_t lo, uint64_t hi) :
777 lo_(lo), hi_(hi)
778 {
779 }
780
781 bool operator [](uint8_t value) const {
782 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
783 }
784
785 void operator()(uint8_t value) {
786 if (value >> 7)
787 return;
788 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
789 }
790 };
791
792 extern CYRange DigitRange_;
793 extern CYRange WordStartRange_;
794 extern CYRange WordEndRange_;
795
796 struct CYString :
797 CYTrivial,
798 CYPropertyName
799 {
800 const char *value_;
801 size_t size_;
802
803 CYString() :
804 value_(NULL),
805 size_(0)
806 {
807 }
808
809 CYString(const char *value) :
810 value_(value),
811 size_(strlen(value))
812 {
813 }
814
815 CYString(const char *value, size_t size) :
816 value_(value),
817 size_(size)
818 {
819 }
820
821 CYString(const CYWord *word) :
822 value_(word->Word()),
823 size_(strlen(value_))
824 {
825 }
826
827 const char *Value() const {
828 return value_;
829 }
830
831 virtual const char *Word() const;
832
833 virtual CYNumber *Number(CYContext &context);
834 virtual CYString *String(CYContext &context);
835
836 CYString *Concat(CYContext &out, CYString *rhs) const;
837 virtual void Output(CYOutput &out, CYFlags flags) const;
838 virtual void PropertyName(CYOutput &out) const;
839 };
840
841 struct CYNumber :
842 CYTrivial,
843 CYPropertyName
844 {
845 double value_;
846
847 CYNumber(double value) :
848 value_(value)
849 {
850 }
851
852 double Value() const {
853 return value_;
854 }
855
856 virtual CYNumber *Number(CYContext &context);
857 virtual CYString *String(CYContext &context);
858
859 virtual void Output(CYOutput &out, CYFlags flags) const;
860 virtual void PropertyName(CYOutput &out) const;
861 };
862
863 struct CYRegEx :
864 CYTrivial
865 {
866 const char *value_;
867
868 CYRegEx(const char *value) :
869 value_(value)
870 {
871 }
872
873 const char *Value() const {
874 return value_;
875 }
876
877 virtual void Output(CYOutput &out, CYFlags flags) const;
878 };
879
880 struct CYNull :
881 CYWord,
882 CYTrivial
883 {
884 CYNull() :
885 CYWord("null")
886 {
887 }
888
889 virtual CYNumber *Number(CYContext &context);
890 virtual CYString *String(CYContext &context);
891
892 virtual void Output(CYOutput &out, CYFlags flags) const;
893 };
894
895 struct CYThis :
896 CYWord,
897 CYMagic
898 {
899 CYThis() :
900 CYWord("this")
901 {
902 }
903
904 virtual CYExpression *Replace(CYContext &context);
905 virtual void Output(CYOutput &out, CYFlags flags) const;
906 };
907
908 struct CYBoolean :
909 CYTrivial
910 {
911 virtual bool Value() const = 0;
912 virtual void Output(CYOutput &out, CYFlags flags) const;
913 };
914
915 struct CYFalse :
916 CYWord,
917 CYBoolean
918 {
919 CYFalse() :
920 CYWord("false")
921 {
922 }
923
924 virtual bool Value() const {
925 return false;
926 }
927
928 virtual CYNumber *Number(CYContext &context);
929 virtual CYString *String(CYContext &context);
930 };
931
932 struct CYTrue :
933 CYWord,
934 CYBoolean
935 {
936 CYTrue() :
937 CYWord("true")
938 {
939 }
940
941 virtual bool Value() const {
942 return true;
943 }
944
945 virtual CYNumber *Number(CYContext &context);
946 virtual CYString *String(CYContext &context);
947 };
948
949 struct CYVariable :
950 CYExpression
951 {
952 CYIdentifier *name_;
953
954 CYVariable(CYIdentifier *name) :
955 name_(name)
956 {
957 }
958
959 CYVariable(const char *name) :
960 name_(new($pool) CYIdentifier(name))
961 {
962 }
963
964 CYPrecedence(0)
965 CYRightHand(false)
966
967 virtual CYExpression *Replace(CYContext &context);
968 virtual void Output(CYOutput &out, CYFlags flags) const;
969 };
970
971 struct CYPrefix :
972 CYExpression
973 {
974 CYExpression *rhs_;
975
976 CYPrefix(CYExpression *rhs) :
977 rhs_(rhs)
978 {
979 }
980
981 virtual bool Alphabetic() const = 0;
982 virtual const char *Operator() const = 0;
983
984 CYPrecedence(4)
985
986 virtual CYExpression *Replace(CYContext &context);
987 virtual void Output(CYOutput &out, CYFlags flags) const;
988 };
989
990 struct CYInfix :
991 CYExpression
992 {
993 CYExpression *lhs_;
994 CYExpression *rhs_;
995
996 CYInfix(CYExpression *lhs, CYExpression *rhs) :
997 lhs_(lhs),
998 rhs_(rhs)
999 {
1000 }
1001
1002 void SetLeft(CYExpression *lhs) {
1003 lhs_ = lhs;
1004 }
1005
1006 virtual bool Alphabetic() const = 0;
1007 virtual const char *Operator() const = 0;
1008
1009 virtual CYExpression *Replace(CYContext &context);
1010 virtual void Output(CYOutput &out, CYFlags flags) const;
1011 };
1012
1013 struct CYPostfix :
1014 CYExpression
1015 {
1016 CYExpression *lhs_;
1017
1018 CYPostfix(CYExpression *lhs) :
1019 lhs_(lhs)
1020 {
1021 }
1022
1023 virtual const char *Operator() const = 0;
1024
1025 CYPrecedence(3)
1026
1027 virtual CYExpression *Replace(CYContext &context);
1028 virtual void Output(CYOutput &out, CYFlags flags) const;
1029 };
1030
1031 struct CYAssignment :
1032 CYExpression
1033 {
1034 CYExpression *lhs_;
1035 CYExpression *rhs_;
1036
1037 CYAssignment(CYExpression *lhs, CYExpression *rhs) :
1038 lhs_(lhs),
1039 rhs_(rhs)
1040 {
1041 }
1042
1043 void SetLeft(CYExpression *lhs) {
1044 lhs_ = lhs;
1045 }
1046
1047 virtual const char *Operator() const = 0;
1048
1049 CYPrecedence(16)
1050
1051 virtual CYExpression *Replace(CYContext &context);
1052 virtual void Output(CYOutput &out, CYFlags flags) const;
1053 };
1054
1055 struct CYArgument :
1056 CYNext<CYArgument>,
1057 CYThing
1058 {
1059 CYWord *name_;
1060 CYExpression *value_;
1061
1062 CYArgument(CYExpression *value, CYArgument *next = NULL) :
1063 CYNext<CYArgument>(next),
1064 name_(NULL),
1065 value_(value)
1066 {
1067 }
1068
1069 CYArgument(CYWord *name, CYExpression *value, CYArgument *next = NULL) :
1070 CYNext<CYArgument>(next),
1071 name_(name),
1072 value_(value)
1073 {
1074 }
1075
1076 void Replace(CYContext &context);
1077 void Output(CYOutput &out) const;
1078 };
1079
1080 struct CYBlank :
1081 public CYWord
1082 {
1083 CYBlank() :
1084 CYWord("")
1085 {
1086 }
1087 };
1088
1089 struct CYClause :
1090 CYThing,
1091 CYNext<CYClause>
1092 {
1093 CYExpression *case_;
1094 CYStatement *statements_;
1095
1096 CYClause(CYExpression *_case, CYStatement *statements) :
1097 case_(_case),
1098 statements_(statements)
1099 {
1100 }
1101
1102 void Replace(CYContext &context);
1103 virtual void Output(CYOutput &out) const;
1104 };
1105
1106 struct CYElement :
1107 CYNext<CYElement>,
1108 CYThing
1109 {
1110 CYExpression *value_;
1111
1112 CYElement(CYExpression *value, CYElement *next) :
1113 CYNext<CYElement>(next),
1114 value_(value)
1115 {
1116 }
1117
1118 void Replace(CYContext &context);
1119 void Output(CYOutput &out) const;
1120 };
1121
1122 struct CYArray :
1123 CYLiteral
1124 {
1125 CYElement *elements_;
1126
1127 CYArray(CYElement *elements = NULL) :
1128 elements_(elements)
1129 {
1130 }
1131
1132 virtual CYExpression *Replace(CYContext &context);
1133 virtual void Output(CYOutput &out, CYFlags flags) const;
1134 };
1135
1136 struct CYProperty :
1137 CYNext<CYProperty>,
1138 CYThing
1139 {
1140 CYPropertyName *name_;
1141 CYExpression *value_;
1142
1143 CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
1144 CYNext<CYProperty>(next),
1145 name_(name),
1146 value_(value)
1147 {
1148 }
1149
1150 void Replace(CYContext &context);
1151 virtual void Output(CYOutput &out) const;
1152 };
1153
1154 struct CYDeclaration :
1155 CYForInInitialiser
1156 {
1157 CYIdentifier *identifier_;
1158 CYExpression *initialiser_;
1159
1160 CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser = NULL) :
1161 identifier_(identifier),
1162 initialiser_(initialiser)
1163 {
1164 }
1165
1166 virtual void ForIn(CYOutput &out, CYFlags flags) const;
1167
1168 virtual const char *ForEachIn() const;
1169 virtual CYExpression *ForEachIn(CYContext &out);
1170
1171 virtual CYExpression *Replace(CYContext &context);
1172 virtual CYAssignment *Assignment(CYContext &context);
1173
1174 virtual void Output(CYOutput &out, CYFlags flags) const;
1175 };
1176
1177 struct CYDeclarations :
1178 CYNext<CYDeclarations>,
1179 CYThing,
1180 CYForInitialiser
1181 {
1182 CYDeclaration *declaration_;
1183
1184 CYDeclarations(CYDeclaration *declaration, CYDeclarations *next = NULL) :
1185 CYNext<CYDeclarations>(next),
1186 declaration_(declaration)
1187 {
1188 }
1189
1190 virtual void For(CYOutput &out) const;
1191
1192 virtual CYCompound *Replace(CYContext &context);
1193 CYProperty *Property(CYContext &context);
1194
1195 virtual void Output(CYOutput &out) const;
1196 virtual void Output(CYOutput &out, CYFlags flags) const;
1197 };
1198
1199 struct CYVar :
1200 CYStatement
1201 {
1202 CYDeclarations *declarations_;
1203
1204 CYVar(CYDeclarations *declarations) :
1205 declarations_(declarations)
1206 {
1207 }
1208
1209 virtual CYStatement *Replace(CYContext &context);
1210 virtual void Output(CYOutput &out, CYFlags flags) const;
1211 };
1212
1213 struct CYLet :
1214 CYStatement
1215 {
1216 CYDeclarations *declarations_;
1217 CYBlock code_;
1218
1219 CYLet(CYDeclarations *declarations, CYStatement *statements) :
1220 declarations_(declarations),
1221 code_(statements)
1222 {
1223 }
1224
1225 virtual CYStatement *Replace(CYContext &context);
1226 virtual void Output(CYOutput &out, CYFlags flags) const;
1227 };
1228
1229 struct CYFor :
1230 CYStatement
1231 {
1232 CYForInitialiser *initialiser_;
1233 CYExpression *test_;
1234 CYExpression *increment_;
1235 CYStatement *code_;
1236
1237 CYFor(CYForInitialiser *initialiser, CYExpression *test, CYExpression *increment, CYStatement *code) :
1238 initialiser_(initialiser),
1239 test_(test),
1240 increment_(increment),
1241 code_(code)
1242 {
1243 }
1244
1245 virtual CYStatement *Replace(CYContext &context);
1246 virtual void Output(CYOutput &out, CYFlags flags) const;
1247 };
1248
1249 struct CYForIn :
1250 CYStatement
1251 {
1252 CYForInInitialiser *initialiser_;
1253 CYExpression *set_;
1254 CYStatement *code_;
1255
1256 CYForIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1257 initialiser_(initialiser),
1258 set_(set),
1259 code_(code)
1260 {
1261 }
1262
1263 virtual CYStatement *Replace(CYContext &context);
1264 virtual void Output(CYOutput &out, CYFlags flags) const;
1265 };
1266
1267 struct CYForEachIn :
1268 CYStatement
1269 {
1270 CYForInInitialiser *initialiser_;
1271 CYExpression *set_;
1272 CYStatement *code_;
1273
1274 CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1275 initialiser_(initialiser),
1276 set_(set),
1277 code_(code)
1278 {
1279 }
1280
1281 virtual CYStatement *Replace(CYContext &context);
1282 virtual void Output(CYOutput &out, CYFlags flags) const;
1283 };
1284
1285 struct CYObject :
1286 CYLiteral
1287 {
1288 CYProperty *properties_;
1289
1290 CYObject(CYProperty *properties = NULL) :
1291 properties_(properties)
1292 {
1293 }
1294
1295 virtual CYExpression *Replace(CYContext &context);
1296 void Output(CYOutput &out, CYFlags flags) const;
1297 };
1298
1299 struct CYMember :
1300 CYExpression
1301 {
1302 CYExpression *object_;
1303 CYExpression *property_;
1304
1305 CYMember(CYExpression *object, CYExpression *property) :
1306 object_(object),
1307 property_(property)
1308 {
1309 }
1310
1311 void SetLeft(CYExpression *object) {
1312 object_ = object;
1313 }
1314
1315 void Replace_(CYContext &context);
1316 };
1317
1318 struct CYDirectMember :
1319 CYMember
1320 {
1321 CYDirectMember(CYExpression *object, CYExpression *property) :
1322 CYMember(object, property)
1323 {
1324 }
1325
1326 CYPrecedence(1)
1327 CYRightHand(false)
1328
1329 virtual CYExpression *Replace(CYContext &context);
1330 virtual void Output(CYOutput &out, CYFlags flags) const;
1331 };
1332
1333 struct CYIndirectMember :
1334 CYMember
1335 {
1336 CYIndirectMember(CYExpression *object, CYExpression *property) :
1337 CYMember(object, property)
1338 {
1339 }
1340
1341 CYPrecedence(1)
1342 CYRightHand(false)
1343
1344 virtual CYExpression *Replace(CYContext &context);
1345 virtual void Output(CYOutput &out, CYFlags flags) const;
1346 };
1347
1348 namespace cy {
1349 namespace Syntax {
1350
1351 struct New :
1352 CYExpression
1353 {
1354 CYExpression *constructor_;
1355 CYArgument *arguments_;
1356
1357 New(CYExpression *constructor, CYArgument *arguments) :
1358 constructor_(constructor),
1359 arguments_(arguments)
1360 {
1361 }
1362
1363 virtual unsigned Precedence() const {
1364 return arguments_ == NULL ? 2 : 1;
1365 }
1366
1367 CYRightHand(false)
1368
1369 virtual CYExpression *Replace(CYContext &context);
1370 virtual void Output(CYOutput &out, CYFlags flags) const;
1371
1372 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1373 };
1374
1375 } }
1376
1377 struct CYCall :
1378 CYExpression
1379 {
1380 CYExpression *function_;
1381 CYArgument *arguments_;
1382
1383 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1384 function_(function),
1385 arguments_(arguments)
1386 {
1387 }
1388
1389 CYPrecedence(1)
1390 CYRightHand(false)
1391
1392 virtual CYExpression *Replace(CYContext &context);
1393 virtual void Output(CYOutput &out, CYFlags flags) const;
1394
1395 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1396 };
1397
1398 struct CYRubyProc;
1399
1400 struct CYRubyBlock :
1401 CYExpression
1402 {
1403 CYExpression *call_;
1404 CYRubyProc *proc_;
1405
1406 CYRubyBlock(CYExpression *call, CYRubyProc *proc) :
1407 call_(call),
1408 proc_(proc)
1409 {
1410 }
1411
1412 CYPrecedence(1)
1413 CYRightHand(false)
1414
1415 virtual CYExpression *Replace(CYContext &context);
1416 virtual void Output(CYOutput &out, CYFlags flags) const;
1417 };
1418
1419 struct CYIf :
1420 CYStatement
1421 {
1422 CYExpression *test_;
1423 CYStatement *true_;
1424 CYStatement *false_;
1425
1426 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1427 test_(test),
1428 true_(_true),
1429 false_(_false)
1430 {
1431 }
1432
1433 virtual CYStatement *Replace(CYContext &context);
1434 virtual void Output(CYOutput &out, CYFlags flags) const;
1435 };
1436
1437 struct CYDoWhile :
1438 CYStatement
1439 {
1440 CYExpression *test_;
1441 CYStatement *code_;
1442
1443 CYDoWhile(CYExpression *test, CYStatement *code) :
1444 test_(test),
1445 code_(code)
1446 {
1447 }
1448
1449 virtual CYStatement *Replace(CYContext &context);
1450 virtual void Output(CYOutput &out, CYFlags flags) const;
1451 };
1452
1453 struct CYWhile :
1454 CYStatement
1455 {
1456 CYExpression *test_;
1457 CYStatement *code_;
1458
1459 CYWhile(CYExpression *test, CYStatement *code) :
1460 test_(test),
1461 code_(code)
1462 {
1463 }
1464
1465 virtual CYStatement *Replace(CYContext &context);
1466 virtual void Output(CYOutput &out, CYFlags flags) const;
1467 };
1468
1469 // XXX: this should be split up into CYAnonymousFunction and CYNamedFunction (subclass)
1470 struct CYFunction {
1471 CYIdentifier *name_;
1472 CYFunctionParameter *parameters_;
1473 CYBlock code_;
1474 CYNonLocal *nonlocal_;
1475
1476 CYFunction(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1477 name_(name),
1478 parameters_(parameters),
1479 code_(statements),
1480 nonlocal_(NULL)
1481 {
1482 }
1483
1484 virtual ~CYFunction() {
1485 }
1486
1487 void Inject(CYContext &context);
1488 virtual void Replace_(CYContext &context, bool outer);
1489 virtual void Output(CYOutput &out, CYFlags flags) const;
1490 };
1491
1492 // XXX: this should be split up into CYAnonymousFunctionExpression and CYNamedFunctionExpression
1493 struct CYFunctionExpression :
1494 CYFunction,
1495 CYExpression
1496 {
1497 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1498 CYFunction(name, parameters, statements)
1499 {
1500 }
1501
1502 CYPrecedence(0)
1503 CYRightHand(false)
1504
1505 virtual CYExpression *Replace(CYContext &context);
1506 virtual void Output(CYOutput &out, CYFlags flags) const;
1507 };
1508
1509 // XXX: this should derive from CYAnonymousFunctionExpression
1510 struct CYRubyProc :
1511 CYFunctionExpression
1512 {
1513 CYRubyProc(CYFunctionParameter *parameters, CYStatement *statements) :
1514 CYFunctionExpression(NULL, parameters, statements)
1515 {
1516 }
1517
1518 virtual CYExpression *Replace(CYContext &context);
1519 virtual void Output(CYOutput &out, CYFlags flags) const;
1520 };
1521
1522 // XXX: this should derive from CYNamedFunction
1523 struct CYFunctionStatement :
1524 CYFunction,
1525 CYStatement
1526 {
1527 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1528 CYFunction(name, parameters, statements)
1529 {
1530 }
1531
1532 virtual CYStatement *Replace(CYContext &context);
1533 virtual void Output(CYOutput &out, CYFlags flags) const;
1534 };
1535
1536 struct CYExpress :
1537 CYStatement
1538 {
1539 CYExpression *expression_;
1540
1541 CYExpress(CYExpression *expression) :
1542 expression_(expression)
1543 {
1544 if (expression == NULL)
1545 throw;
1546 }
1547
1548 virtual CYStatement *Collapse(CYContext &context);
1549 virtual CYStatement *Replace(CYContext &context);
1550 virtual void Output(CYOutput &out, CYFlags flags) const;
1551 };
1552
1553 struct CYContinue :
1554 CYStatement
1555 {
1556 CYIdentifier *label_;
1557
1558 CYContinue(CYIdentifier *label) :
1559 label_(label)
1560 {
1561 }
1562
1563 virtual CYStatement *Replace(CYContext &context);
1564 virtual void Output(CYOutput &out, CYFlags flags) const;
1565 };
1566
1567 struct CYBreak :
1568 CYStatement
1569 {
1570 CYIdentifier *label_;
1571
1572 CYBreak(CYIdentifier *label) :
1573 label_(label)
1574 {
1575 }
1576
1577 virtual CYStatement *Replace(CYContext &context);
1578 virtual void Output(CYOutput &out, CYFlags flags) const;
1579 };
1580
1581 struct CYReturn :
1582 CYStatement
1583 {
1584 CYExpression *value_;
1585
1586 CYReturn(CYExpression *value) :
1587 value_(value)
1588 {
1589 }
1590
1591 virtual CYStatement *Replace(CYContext &context);
1592 virtual void Output(CYOutput &out, CYFlags flags) const;
1593 };
1594
1595 struct CYEmpty :
1596 CYStatement
1597 {
1598 virtual CYStatement *Collapse(CYContext &context);
1599 virtual CYStatement *Replace(CYContext &context);
1600 virtual void Output(CYOutput &out, CYFlags flags) const;
1601 };
1602
1603 struct CYFinally :
1604 CYThing
1605 {
1606 CYBlock code_;
1607
1608 CYFinally(CYStatement *statements) :
1609 code_(statements)
1610 {
1611 }
1612
1613 void Replace(CYContext &context);
1614 virtual void Output(CYOutput &out) const;
1615 };
1616
1617 namespace cy {
1618 namespace Syntax {
1619
1620 struct Catch :
1621 CYThing
1622 {
1623 CYIdentifier *name_;
1624 CYBlock code_;
1625
1626 Catch(CYIdentifier *name, CYStatement *statements) :
1627 name_(name),
1628 code_(statements)
1629 {
1630 }
1631
1632 void Replace(CYContext &context);
1633 virtual void Output(CYOutput &out) const;
1634 };
1635
1636 struct Try :
1637 CYStatement
1638 {
1639 CYBlock code_;
1640 Catch *catch_;
1641 CYFinally *finally_;
1642
1643 Try(CYStatement *statements, Catch *_catch, CYFinally *finally) :
1644 code_(statements),
1645 catch_(_catch),
1646 finally_(finally)
1647 {
1648 }
1649
1650 virtual CYStatement *Replace(CYContext &context);
1651 virtual void Output(CYOutput &out, CYFlags flags) const;
1652 };
1653
1654 struct Throw :
1655 CYStatement
1656 {
1657 CYExpression *value_;
1658
1659 Throw(CYExpression *value = NULL) :
1660 value_(value)
1661 {
1662 }
1663
1664 virtual CYStatement *Replace(CYContext &context);
1665 virtual void Output(CYOutput &out, CYFlags flags) const;
1666 };
1667
1668 } }
1669
1670 struct CYWith :
1671 CYStatement
1672 {
1673 CYExpression *scope_;
1674 CYStatement *code_;
1675
1676 CYWith(CYExpression *scope, CYStatement *code) :
1677 scope_(scope),
1678 code_(code)
1679 {
1680 }
1681
1682 virtual CYStatement *Replace(CYContext &context);
1683 virtual void Output(CYOutput &out, CYFlags flags) const;
1684 };
1685
1686 struct CYSwitch :
1687 CYStatement
1688 {
1689 CYExpression *value_;
1690 CYClause *clauses_;
1691
1692 CYSwitch(CYExpression *value, CYClause *clauses) :
1693 value_(value),
1694 clauses_(clauses)
1695 {
1696 }
1697
1698 virtual CYStatement *Replace(CYContext &context);
1699 virtual void Output(CYOutput &out, CYFlags flags) const;
1700 };
1701
1702 struct CYCondition :
1703 CYExpression
1704 {
1705 CYExpression *test_;
1706 CYExpression *true_;
1707 CYExpression *false_;
1708
1709 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
1710 test_(test),
1711 true_(_true),
1712 false_(_false)
1713 {
1714 }
1715
1716 CYPrecedence(15)
1717
1718 virtual CYExpression *Replace(CYContext &context);
1719 virtual void Output(CYOutput &out, CYFlags flags) const;
1720 };
1721
1722 struct CYAddressOf :
1723 CYPrefix
1724 {
1725 CYAddressOf(CYExpression *rhs) :
1726 CYPrefix(rhs)
1727 {
1728 }
1729
1730 virtual const char *Operator() const {
1731 return "&";
1732 }
1733
1734 CYAlphabetic(false)
1735
1736 virtual CYExpression *Replace(CYContext &context);
1737 };
1738
1739 struct CYIndirect :
1740 CYPrefix
1741 {
1742 CYIndirect(CYExpression *rhs) :
1743 CYPrefix(rhs)
1744 {
1745 }
1746
1747 virtual const char *Operator() const {
1748 return "*";
1749 }
1750
1751 CYAlphabetic(false)
1752
1753 virtual CYExpression *Replace(CYContext &context);
1754 };
1755
1756 #define CYReplace \
1757 virtual CYExpression *Replace(CYContext &context);
1758
1759 #define CYPostfix_(op, name, args...) \
1760 struct CY ## name : \
1761 CYPostfix \
1762 { args \
1763 CY ## name(CYExpression *lhs) : \
1764 CYPostfix(lhs) \
1765 { \
1766 } \
1767 \
1768 virtual const char *Operator() const { \
1769 return op; \
1770 } \
1771 };
1772
1773 #define CYPrefix_(alphabetic, op, name, args...) \
1774 struct CY ## name : \
1775 CYPrefix \
1776 { args \
1777 CY ## name(CYExpression *rhs) : \
1778 CYPrefix(rhs) \
1779 { \
1780 } \
1781 \
1782 CYAlphabetic(alphabetic) \
1783 \
1784 virtual const char *Operator() const { \
1785 return op; \
1786 } \
1787 };
1788
1789 #define CYInfix_(alphabetic, precedence, op, name, args...) \
1790 struct CY ## name : \
1791 CYInfix \
1792 { args \
1793 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
1794 CYInfix(lhs, rhs) \
1795 { \
1796 } \
1797 \
1798 CYAlphabetic(alphabetic) \
1799 CYPrecedence(precedence) \
1800 \
1801 virtual const char *Operator() const { \
1802 return op; \
1803 } \
1804 };
1805
1806 #define CYAssignment_(op, name, args...) \
1807 struct CY ## name ## Assign : \
1808 CYAssignment \
1809 { args \
1810 CY ## name ## Assign(CYExpression *lhs, CYExpression *rhs) : \
1811 CYAssignment(lhs, rhs) \
1812 { \
1813 } \
1814 \
1815 virtual const char *Operator() const { \
1816 return op; \
1817 } \
1818 };
1819
1820 CYPostfix_("++", PostIncrement)
1821 CYPostfix_("--", PostDecrement)
1822
1823 CYPrefix_(true, "delete", Delete)
1824 CYPrefix_(true, "void", Void)
1825 CYPrefix_(true, "typeof", TypeOf)
1826 CYPrefix_(false, "++", PreIncrement)
1827 CYPrefix_(false, "--", PreDecrement)
1828 CYPrefix_(false, "+", Affirm)
1829 CYPrefix_(false, "-", Negate)
1830 CYPrefix_(false, "~", BitwiseNot)
1831 CYPrefix_(false, "!", LogicalNot)
1832
1833 CYInfix_(false, 5, "*", Multiply)
1834 CYInfix_(false, 5, "/", Divide)
1835 CYInfix_(false, 5, "%", Modulus)
1836 CYInfix_(false, 6, "+", Add, CYReplace)
1837 CYInfix_(false, 6, "-", Subtract)
1838 CYInfix_(false, 7, "<<", ShiftLeft)
1839 CYInfix_(false, 7, ">>", ShiftRightSigned)
1840 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
1841 CYInfix_(false, 8, "<", Less)
1842 CYInfix_(false, 8, ">", Greater)
1843 CYInfix_(false, 8, "<=", LessOrEqual)
1844 CYInfix_(false, 8, ">=", GreaterOrEqual)
1845 CYInfix_(true, 8, "instanceof", InstanceOf)
1846 CYInfix_(true, 8, "in", In)
1847 CYInfix_(false, 9, "==", Equal)
1848 CYInfix_(false, 9, "!=", NotEqual)
1849 CYInfix_(false, 9, "===", Identical)
1850 CYInfix_(false, 9, "!==", NotIdentical)
1851 CYInfix_(false, 10, "&", BitwiseAnd)
1852 CYInfix_(false, 11, "^", BitwiseXOr)
1853 CYInfix_(false, 12, "|", BitwiseOr)
1854 CYInfix_(false, 13, "&&", LogicalAnd)
1855 CYInfix_(false, 14, "||", LogicalOr)
1856
1857 CYAssignment_("=", )
1858 CYAssignment_("*=", Multiply)
1859 CYAssignment_("/=", Divide)
1860 CYAssignment_("%=", Modulus)
1861 CYAssignment_("+=", Add)
1862 CYAssignment_("-=", Subtract)
1863 CYAssignment_("<<=", ShiftLeft)
1864 CYAssignment_(">>=", ShiftRightSigned)
1865 CYAssignment_(">>>=", ShiftRightUnsigned)
1866 CYAssignment_("&=", BitwiseAnd)
1867 CYAssignment_("^=", BitwiseXOr)
1868 CYAssignment_("|=", BitwiseOr)
1869
1870 #endif/*CYPARSER_HPP*/