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