]> git.saurik.com Git - cycript.git/blob - Parser.hpp
2d3a59f4b1417fc53e6e5035832b51fec01ab932
[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 unsigned unique_;
371
372 CYContext(apr_pool_t *pool, CYOptions &options) :
373 pool_(pool),
374 options_(options),
375 scope_(NULL),
376 nonlocal_(NULL),
377 unique_(0)
378 {
379 }
380
381 virtual ~CYContext() {
382 }
383
384 template <typename Type_>
385 void Replace(Type_ *&value) {
386 for (;;) if (value == NULL)
387 break;
388 else {
389 Type_ *replace(value->Replace(*this));
390 if (replace != value)
391 value = replace;
392 else break;
393 }
394 }
395
396 void NonLocal(CYStatement *&statements);
397 CYIdentifier *Unique();
398 };
399
400 struct CYNonLocal {
401 CYIdentifier *identifier_;
402
403 CYNonLocal() :
404 identifier_(NULL)
405 {
406 }
407
408 CYIdentifier *Target(CYContext &context) {
409 if (identifier_ == NULL)
410 identifier_ = context.Unique();
411 return identifier_;
412 }
413 };
414
415 struct CYBlock :
416 CYStatement,
417 CYThing
418 {
419 CYStatement *statements_;
420
421 CYBlock(CYStatement *statements) :
422 statements_(statements)
423 {
424 }
425
426 operator CYStatement *() const {
427 return statements_;
428 }
429
430 void AddPrev(CYStatement *statement) {
431 CYStatement *last(statement);
432 while (last->next_ != NULL)
433 last = last->next_;
434 last->SetNext(statements_);
435 statements_ = statement;
436 }
437
438 virtual CYStatement *Replace(CYContext &context);
439
440 virtual void Output(CYOutput &out) const;
441 virtual void Output(CYOutput &out, CYFlags flags) const;
442 };
443
444 enum CYState {
445 CYClear,
446 CYRestricted,
447 CYNewLine
448 };
449
450 class CYDriver {
451 public:
452 CYPool pool_;
453
454 CYState state_;
455 void *scanner_;
456
457 const char *data_;
458 size_t size_;
459 FILE *file_;
460
461 bool strict_;
462
463 enum Condition {
464 RegExpCondition,
465 XMLContentCondition,
466 XMLTagCondition,
467 };
468
469 std::string filename_;
470
471 struct Error {
472 bool warning_;
473 cy::location location_;
474 std::string message_;
475 };
476
477 typedef std::vector<Error> Errors;
478
479 CYProgram *program_;
480 Errors errors_;
481
482 bool auto_;
483
484 struct Context {
485 CYExpression *context_;
486
487 Context(CYExpression *context) :
488 context_(context)
489 {
490 }
491
492 typedef std::vector<CYWord *> Words;
493 Words words_;
494 };
495
496 typedef std::vector<Context> Contexts;
497 Contexts contexts_;
498
499 CYExpression *context_;
500
501 enum Mode {
502 AutoNone,
503 AutoPrimary,
504 AutoDirect,
505 AutoIndirect,
506 AutoMessage
507 } mode_;
508
509 private:
510 void ScannerInit();
511 void ScannerDestroy();
512
513 public:
514 CYDriver(apr_pool_t *pool = NULL, const std::string &filename = "");
515 ~CYDriver();
516
517 Condition GetCondition();
518 void SetCondition(Condition condition);
519
520 void PushCondition(Condition condition);
521 void PopCondition();
522
523 void Warning(const cy::location &location, const char *message);
524 };
525
526 struct CYForInitialiser {
527 virtual ~CYForInitialiser() {
528 }
529
530 virtual void For(CYOutput &out) const = 0;
531 virtual CYExpression *Replace(CYContext &context) = 0;
532 };
533
534 struct CYForInInitialiser {
535 virtual ~CYForInInitialiser() {
536 }
537
538 virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
539 virtual const char *ForEachIn() const = 0;
540 virtual CYExpression *ForEachIn(CYContext &out) = 0;
541 virtual CYExpression *Replace(CYContext &context) = 0;
542 };
543
544 struct CYNumber;
545 struct CYString;
546
547 struct CYExpression :
548 CYNext<CYExpression>,
549 CYForInitialiser,
550 CYForInInitialiser,
551 CYClassName,
552 CYThing
553 {
554 virtual unsigned Precedence() const = 0;
555
556 virtual bool RightHand() const {
557 return true;
558 }
559
560 virtual void For(CYOutput &out) const;
561 virtual void ForIn(CYOutput &out, CYFlags flags) const;
562
563 virtual const char *ForEachIn() const;
564 virtual CYExpression *ForEachIn(CYContext &out);
565
566 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
567
568 virtual void Output(CYOutput &out) const;
569 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
570 void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
571
572 virtual CYExpression *ClassName(CYContext &context, bool object);
573 virtual void ClassName(CYOutput &out, bool object) const;
574
575 CYExpression *ReplaceAll(CYContext &context);
576
577 virtual CYExpression *Replace(CYContext &context) = 0;
578
579 virtual CYExpression *Primitive(CYContext &context) {
580 return this;
581 }
582
583 virtual CYNumber *Number(CYContext &context) {
584 return NULL;
585 }
586
587 virtual CYString *String(CYContext &context) {
588 return NULL;
589 }
590
591 virtual const char *Word() const {
592 return NULL;
593 }
594 };
595
596 #define CYAlphabetic(value) \
597 virtual bool Alphabetic() const { \
598 return value; \
599 }
600
601 #define CYPrecedence(value) \
602 virtual unsigned Precedence() const { \
603 return value; \
604 }
605
606 #define CYRightHand(value) \
607 virtual bool RightHand() const { \
608 return value; \
609 }
610
611 struct CYCompound :
612 CYExpression
613 {
614 CYExpression *expressions_;
615
616 CYCompound(CYExpression *expressions = NULL) :
617 expressions_(expressions)
618 {
619 }
620
621 void AddPrev(CYExpression *expression) {
622 CYExpression *last(expression);
623 while (last->next_ != NULL)
624 last = last->next_;
625 last->SetNext(expressions_);
626 expressions_ = expression;
627 }
628
629 CYPrecedence(17)
630
631 virtual CYExpression *Replace(CYContext &context);
632 void Output(CYOutput &out, CYFlags flags) const;
633 };
634
635 struct CYFunctionParameter :
636 CYNext<CYFunctionParameter>,
637 CYThing
638 {
639 CYIdentifier *name_;
640
641 CYFunctionParameter(CYIdentifier *name, CYFunctionParameter *next = NULL) :
642 CYNext<CYFunctionParameter>(next),
643 name_(name)
644 {
645 }
646
647 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
648 virtual void Output(CYOutput &out) const;
649 };
650
651 struct CYOptionalFunctionParameter :
652 CYFunctionParameter
653 {
654 CYExpression *initializer_;
655
656 CYOptionalFunctionParameter(CYIdentifier *name, CYExpression *initializer, CYFunctionParameter *next = NULL) :
657 CYFunctionParameter(name, next),
658 initializer_(initializer)
659 {
660 }
661
662 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
663 virtual void Output(CYOutput &out) const;
664 };
665
666 struct CYComprehension :
667 CYNext<CYComprehension>,
668 CYThing
669 {
670 virtual const char *Name() const = 0;
671
672 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
673 CYFunctionParameter *Parameters(CYContext &context) const;
674 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
675 virtual void Output(CYOutput &out) const = 0;
676 };
677
678 struct CYForInComprehension :
679 CYComprehension
680 {
681 CYIdentifier *name_;
682 CYExpression *set_;
683
684 CYForInComprehension(CYIdentifier *name, CYExpression *set) :
685 name_(name),
686 set_(set)
687 {
688 }
689
690 virtual const char *Name() const {
691 return name_->Word();
692 }
693
694 virtual CYFunctionParameter *Parameter(CYContext &context) const;
695 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
696 virtual void Output(CYOutput &out) const;
697 };
698
699 struct CYForEachInComprehension :
700 CYComprehension
701 {
702 CYIdentifier *name_;
703 CYExpression *set_;
704
705 CYForEachInComprehension(CYIdentifier *name, CYExpression *set) :
706 name_(name),
707 set_(set)
708 {
709 }
710
711 virtual const char *Name() const {
712 return name_->Word();
713 }
714
715 virtual CYFunctionParameter *Parameter(CYContext &context) const;
716 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
717 virtual void Output(CYOutput &out) const;
718 };
719
720 struct CYIfComprehension :
721 CYComprehension
722 {
723 CYExpression *test_;
724
725 CYIfComprehension(CYExpression *test) :
726 test_(test)
727 {
728 }
729
730 virtual const char *Name() const {
731 return NULL;
732 }
733
734 virtual CYFunctionParameter *Parameter(CYContext &context) const;
735 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
736 virtual void Output(CYOutput &out) const;
737 };
738
739 struct CYArrayComprehension :
740 CYExpression
741 {
742 CYExpression *expression_;
743 CYComprehension *comprehensions_;
744
745 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
746 expression_(expression),
747 comprehensions_(comprehensions)
748 {
749 }
750
751 CYPrecedence(0)
752
753 virtual CYExpression *Replace(CYContext &context);
754 virtual void Output(CYOutput &out, CYFlags flags) const;
755 };
756
757 struct CYLiteral :
758 CYExpression
759 {
760 CYPrecedence(0)
761 CYRightHand(false)
762 };
763
764 struct CYTrivial :
765 CYLiteral
766 {
767 virtual CYExpression *Replace(CYContext &context);
768 };
769
770 struct CYMagic :
771 CYExpression
772 {
773 CYPrecedence(0)
774 CYRightHand(false)
775 };
776
777 struct CYRange {
778 uint64_t lo_;
779 uint64_t hi_;
780
781 CYRange(uint64_t lo, uint64_t hi) :
782 lo_(lo), hi_(hi)
783 {
784 }
785
786 bool operator [](uint8_t value) const {
787 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
788 }
789
790 void operator()(uint8_t value) {
791 if (value >> 7)
792 return;
793 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
794 }
795 };
796
797 extern CYRange DigitRange_;
798 extern CYRange WordStartRange_;
799 extern CYRange WordEndRange_;
800
801 struct CYString :
802 CYTrivial,
803 CYPropertyName
804 {
805 const char *value_;
806 size_t size_;
807
808 CYString() :
809 value_(NULL),
810 size_(0)
811 {
812 }
813
814 CYString(const char *value) :
815 value_(value),
816 size_(strlen(value))
817 {
818 }
819
820 CYString(const char *value, size_t size) :
821 value_(value),
822 size_(size)
823 {
824 }
825
826 CYString(const CYWord *word) :
827 value_(word->Word()),
828 size_(strlen(value_))
829 {
830 }
831
832 const char *Value() const {
833 return value_;
834 }
835
836 virtual const char *Word() const;
837
838 virtual CYNumber *Number(CYContext &context);
839 virtual CYString *String(CYContext &context);
840
841 CYString *Concat(CYContext &out, CYString *rhs) const;
842 virtual void Output(CYOutput &out, CYFlags flags) const;
843 virtual void PropertyName(CYOutput &out) const;
844 };
845
846 struct CYNumber :
847 CYTrivial,
848 CYPropertyName
849 {
850 double value_;
851
852 CYNumber(double value) :
853 value_(value)
854 {
855 }
856
857 double Value() const {
858 return value_;
859 }
860
861 virtual CYNumber *Number(CYContext &context);
862 virtual CYString *String(CYContext &context);
863
864 virtual void Output(CYOutput &out, CYFlags flags) const;
865 virtual void PropertyName(CYOutput &out) const;
866 };
867
868 struct CYRegEx :
869 CYTrivial
870 {
871 const char *value_;
872
873 CYRegEx(const char *value) :
874 value_(value)
875 {
876 }
877
878 const char *Value() const {
879 return value_;
880 }
881
882 virtual void Output(CYOutput &out, CYFlags flags) const;
883 };
884
885 struct CYNull :
886 CYWord,
887 CYTrivial
888 {
889 CYNull() :
890 CYWord("null")
891 {
892 }
893
894 virtual CYNumber *Number(CYContext &context);
895 virtual CYString *String(CYContext &context);
896
897 virtual void Output(CYOutput &out, CYFlags flags) const;
898 };
899
900 struct CYThis :
901 CYWord,
902 CYMagic
903 {
904 CYThis() :
905 CYWord("this")
906 {
907 }
908
909 virtual CYExpression *Replace(CYContext &context);
910 virtual void Output(CYOutput &out, CYFlags flags) const;
911 };
912
913 struct CYBoolean :
914 CYTrivial
915 {
916 virtual bool Value() const = 0;
917 virtual void Output(CYOutput &out, CYFlags flags) const;
918 };
919
920 struct CYFalse :
921 CYWord,
922 CYBoolean
923 {
924 CYFalse() :
925 CYWord("false")
926 {
927 }
928
929 virtual bool Value() const {
930 return false;
931 }
932
933 virtual CYNumber *Number(CYContext &context);
934 virtual CYString *String(CYContext &context);
935 };
936
937 struct CYTrue :
938 CYWord,
939 CYBoolean
940 {
941 CYTrue() :
942 CYWord("true")
943 {
944 }
945
946 virtual bool Value() const {
947 return true;
948 }
949
950 virtual CYNumber *Number(CYContext &context);
951 virtual CYString *String(CYContext &context);
952 };
953
954 struct CYVariable :
955 CYExpression
956 {
957 CYIdentifier *name_;
958
959 CYVariable(CYIdentifier *name) :
960 name_(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 struct CYNew :
1349 CYExpression
1350 {
1351 CYExpression *constructor_;
1352 CYArgument *arguments_;
1353
1354 CYNew(CYExpression *constructor, CYArgument *arguments) :
1355 constructor_(constructor),
1356 arguments_(arguments)
1357 {
1358 }
1359
1360 virtual unsigned Precedence() const {
1361 return arguments_ == NULL ? 2 : 1;
1362 }
1363
1364 CYRightHand(false)
1365
1366 virtual CYExpression *Replace(CYContext &context);
1367 virtual void Output(CYOutput &out, CYFlags flags) const;
1368
1369 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1370 };
1371
1372 struct CYCall :
1373 CYExpression
1374 {
1375 CYExpression *function_;
1376 CYArgument *arguments_;
1377
1378 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1379 function_(function),
1380 arguments_(arguments)
1381 {
1382 }
1383
1384 CYPrecedence(1)
1385 CYRightHand(false)
1386
1387 virtual CYExpression *Replace(CYContext &context);
1388 virtual void Output(CYOutput &out, CYFlags flags) const;
1389
1390 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1391 };
1392
1393 struct CYRubyProc;
1394
1395 struct CYRubyBlock :
1396 CYExpression
1397 {
1398 CYExpression *call_;
1399 CYRubyProc *proc_;
1400
1401 CYRubyBlock(CYExpression *call, CYRubyProc *proc) :
1402 call_(call),
1403 proc_(proc)
1404 {
1405 }
1406
1407 CYPrecedence(1)
1408 CYRightHand(false)
1409
1410 virtual CYExpression *Replace(CYContext &context);
1411 virtual void Output(CYOutput &out, CYFlags flags) const;
1412 };
1413
1414 struct CYIf :
1415 CYStatement
1416 {
1417 CYExpression *test_;
1418 CYStatement *true_;
1419 CYStatement *false_;
1420
1421 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1422 test_(test),
1423 true_(_true),
1424 false_(_false)
1425 {
1426 }
1427
1428 virtual CYStatement *Replace(CYContext &context);
1429 virtual void Output(CYOutput &out, CYFlags flags) const;
1430 };
1431
1432 struct CYDoWhile :
1433 CYStatement
1434 {
1435 CYExpression *test_;
1436 CYStatement *code_;
1437
1438 CYDoWhile(CYExpression *test, CYStatement *code) :
1439 test_(test),
1440 code_(code)
1441 {
1442 }
1443
1444 virtual CYStatement *Replace(CYContext &context);
1445 virtual void Output(CYOutput &out, CYFlags flags) const;
1446 };
1447
1448 struct CYWhile :
1449 CYStatement
1450 {
1451 CYExpression *test_;
1452 CYStatement *code_;
1453
1454 CYWhile(CYExpression *test, CYStatement *code) :
1455 test_(test),
1456 code_(code)
1457 {
1458 }
1459
1460 virtual CYStatement *Replace(CYContext &context);
1461 virtual void Output(CYOutput &out, CYFlags flags) const;
1462 };
1463
1464 // XXX: this should be split up into CYAnonymousFunction and CYNamedFunction (subclass)
1465 struct CYFunction {
1466 CYIdentifier *name_;
1467 CYFunctionParameter *parameters_;
1468 CYBlock code_;
1469 CYNonLocal *nonlocal_;
1470
1471 CYFunction(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1472 name_(name),
1473 parameters_(parameters),
1474 code_(statements),
1475 nonlocal_(NULL)
1476 {
1477 }
1478
1479 virtual ~CYFunction() {
1480 }
1481
1482 void Inject(CYContext &context);
1483 virtual void Replace_(CYContext &context, bool outer);
1484 virtual void Output(CYOutput &out, CYFlags flags) const;
1485 };
1486
1487 // XXX: this should be split up into CYAnonymousFunctionExpression and CYNamedFunctionExpression
1488 struct CYFunctionExpression :
1489 CYFunction,
1490 CYExpression
1491 {
1492 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1493 CYFunction(name, parameters, statements)
1494 {
1495 }
1496
1497 CYPrecedence(0)
1498 CYRightHand(false)
1499
1500 virtual CYExpression *Replace(CYContext &context);
1501 virtual void Output(CYOutput &out, CYFlags flags) const;
1502 };
1503
1504 // XXX: this should derive from CYAnonymousFunctionExpression
1505 struct CYRubyProc :
1506 CYFunctionExpression
1507 {
1508 CYRubyProc(CYFunctionParameter *parameters, CYStatement *statements) :
1509 CYFunctionExpression(NULL, parameters, statements)
1510 {
1511 }
1512
1513 virtual CYExpression *Replace(CYContext &context);
1514 virtual void Output(CYOutput &out, CYFlags flags) const;
1515 };
1516
1517 // XXX: this should derive from CYNamedFunction
1518 struct CYFunctionStatement :
1519 CYFunction,
1520 CYStatement
1521 {
1522 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1523 CYFunction(name, parameters, statements)
1524 {
1525 }
1526
1527 virtual CYStatement *Replace(CYContext &context);
1528 virtual void Output(CYOutput &out, CYFlags flags) const;
1529 };
1530
1531 struct CYExpress :
1532 CYStatement
1533 {
1534 CYExpression *expression_;
1535
1536 CYExpress(CYExpression *expression) :
1537 expression_(expression)
1538 {
1539 if (expression == NULL)
1540 throw;
1541 }
1542
1543 virtual CYStatement *Collapse(CYContext &context);
1544 virtual CYStatement *Replace(CYContext &context);
1545 virtual void Output(CYOutput &out, CYFlags flags) const;
1546 };
1547
1548 struct CYContinue :
1549 CYStatement
1550 {
1551 CYIdentifier *label_;
1552
1553 CYContinue(CYIdentifier *label) :
1554 label_(label)
1555 {
1556 }
1557
1558 virtual CYStatement *Replace(CYContext &context);
1559 virtual void Output(CYOutput &out, CYFlags flags) const;
1560 };
1561
1562 struct CYBreak :
1563 CYStatement
1564 {
1565 CYIdentifier *label_;
1566
1567 CYBreak(CYIdentifier *label) :
1568 label_(label)
1569 {
1570 }
1571
1572 virtual CYStatement *Replace(CYContext &context);
1573 virtual void Output(CYOutput &out, CYFlags flags) const;
1574 };
1575
1576 struct CYReturn :
1577 CYStatement
1578 {
1579 CYExpression *value_;
1580
1581 CYReturn(CYExpression *value) :
1582 value_(value)
1583 {
1584 }
1585
1586 virtual CYStatement *Replace(CYContext &context);
1587 virtual void Output(CYOutput &out, CYFlags flags) const;
1588 };
1589
1590 struct CYEmpty :
1591 CYStatement
1592 {
1593 virtual CYStatement *Collapse(CYContext &context);
1594 virtual CYStatement *Replace(CYContext &context);
1595 virtual void Output(CYOutput &out, CYFlags flags) const;
1596 };
1597
1598 struct CYFinally :
1599 CYThing
1600 {
1601 CYBlock code_;
1602
1603 CYFinally(CYStatement *statements) :
1604 code_(statements)
1605 {
1606 }
1607
1608 void Replace(CYContext &context);
1609 virtual void Output(CYOutput &out) const;
1610 };
1611
1612 namespace cy {
1613 namespace Syntax {
1614
1615 struct Catch :
1616 CYThing
1617 {
1618 CYIdentifier *name_;
1619 CYBlock code_;
1620
1621 Catch(CYIdentifier *name, CYStatement *statements) :
1622 name_(name),
1623 code_(statements)
1624 {
1625 }
1626
1627 void Replace(CYContext &context);
1628 virtual void Output(CYOutput &out) const;
1629 };
1630
1631 struct Try :
1632 CYStatement
1633 {
1634 CYBlock code_;
1635 Catch *catch_;
1636 CYFinally *finally_;
1637
1638 Try(CYStatement *statements, Catch *_catch, CYFinally *finally) :
1639 code_(statements),
1640 catch_(_catch),
1641 finally_(finally)
1642 {
1643 }
1644
1645 virtual CYStatement *Replace(CYContext &context);
1646 virtual void Output(CYOutput &out, CYFlags flags) const;
1647 };
1648
1649 struct Throw :
1650 CYStatement
1651 {
1652 CYExpression *value_;
1653
1654 Throw(CYExpression *value = NULL) :
1655 value_(value)
1656 {
1657 }
1658
1659 virtual CYStatement *Replace(CYContext &context);
1660 virtual void Output(CYOutput &out, CYFlags flags) const;
1661 };
1662
1663 } }
1664
1665 struct CYWith :
1666 CYStatement
1667 {
1668 CYExpression *scope_;
1669 CYStatement *code_;
1670
1671 CYWith(CYExpression *scope, CYStatement *code) :
1672 scope_(scope),
1673 code_(code)
1674 {
1675 }
1676
1677 virtual CYStatement *Replace(CYContext &context);
1678 virtual void Output(CYOutput &out, CYFlags flags) const;
1679 };
1680
1681 struct CYSwitch :
1682 CYStatement
1683 {
1684 CYExpression *value_;
1685 CYClause *clauses_;
1686
1687 CYSwitch(CYExpression *value, CYClause *clauses) :
1688 value_(value),
1689 clauses_(clauses)
1690 {
1691 }
1692
1693 virtual CYStatement *Replace(CYContext &context);
1694 virtual void Output(CYOutput &out, CYFlags flags) const;
1695 };
1696
1697 struct CYCondition :
1698 CYExpression
1699 {
1700 CYExpression *test_;
1701 CYExpression *true_;
1702 CYExpression *false_;
1703
1704 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
1705 test_(test),
1706 true_(_true),
1707 false_(_false)
1708 {
1709 }
1710
1711 CYPrecedence(15)
1712
1713 virtual CYExpression *Replace(CYContext &context);
1714 virtual void Output(CYOutput &out, CYFlags flags) const;
1715 };
1716
1717 struct CYAddressOf :
1718 CYPrefix
1719 {
1720 CYAddressOf(CYExpression *rhs) :
1721 CYPrefix(rhs)
1722 {
1723 }
1724
1725 virtual const char *Operator() const {
1726 return "&";
1727 }
1728
1729 CYAlphabetic(false)
1730
1731 virtual CYExpression *Replace(CYContext &context);
1732 };
1733
1734 struct CYIndirect :
1735 CYPrefix
1736 {
1737 CYIndirect(CYExpression *rhs) :
1738 CYPrefix(rhs)
1739 {
1740 }
1741
1742 virtual const char *Operator() const {
1743 return "*";
1744 }
1745
1746 CYAlphabetic(false)
1747
1748 virtual CYExpression *Replace(CYContext &context);
1749 };
1750
1751 #define CYReplace \
1752 virtual CYExpression *Replace(CYContext &context);
1753
1754 #define CYPostfix_(op, name, args...) \
1755 struct CY ## name : \
1756 CYPostfix \
1757 { args \
1758 CY ## name(CYExpression *lhs) : \
1759 CYPostfix(lhs) \
1760 { \
1761 } \
1762 \
1763 virtual const char *Operator() const { \
1764 return op; \
1765 } \
1766 };
1767
1768 #define CYPrefix_(alphabetic, op, name, args...) \
1769 struct CY ## name : \
1770 CYPrefix \
1771 { args \
1772 CY ## name(CYExpression *rhs) : \
1773 CYPrefix(rhs) \
1774 { \
1775 } \
1776 \
1777 CYAlphabetic(alphabetic) \
1778 \
1779 virtual const char *Operator() const { \
1780 return op; \
1781 } \
1782 };
1783
1784 #define CYInfix_(alphabetic, precedence, op, name, args...) \
1785 struct CY ## name : \
1786 CYInfix \
1787 { args \
1788 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
1789 CYInfix(lhs, rhs) \
1790 { \
1791 } \
1792 \
1793 CYAlphabetic(alphabetic) \
1794 CYPrecedence(precedence) \
1795 \
1796 virtual const char *Operator() const { \
1797 return op; \
1798 } \
1799 };
1800
1801 #define CYAssignment_(op, name, args...) \
1802 struct CY ## name ## Assign : \
1803 CYAssignment \
1804 { args \
1805 CY ## name ## Assign(CYExpression *lhs, CYExpression *rhs) : \
1806 CYAssignment(lhs, rhs) \
1807 { \
1808 } \
1809 \
1810 virtual const char *Operator() const { \
1811 return op; \
1812 } \
1813 };
1814
1815 CYPostfix_("++", PostIncrement)
1816 CYPostfix_("--", PostDecrement)
1817
1818 CYPrefix_(true, "delete", Delete)
1819 CYPrefix_(true, "void", Void)
1820 CYPrefix_(true, "typeof", TypeOf)
1821 CYPrefix_(false, "++", PreIncrement)
1822 CYPrefix_(false, "--", PreDecrement)
1823 CYPrefix_(false, "+", Affirm)
1824 CYPrefix_(false, "-", Negate)
1825 CYPrefix_(false, "~", BitwiseNot)
1826 CYPrefix_(false, "!", LogicalNot)
1827
1828 CYInfix_(false, 5, "*", Multiply)
1829 CYInfix_(false, 5, "/", Divide)
1830 CYInfix_(false, 5, "%", Modulus)
1831 CYInfix_(false, 6, "+", Add, CYReplace)
1832 CYInfix_(false, 6, "-", Subtract)
1833 CYInfix_(false, 7, "<<", ShiftLeft)
1834 CYInfix_(false, 7, ">>", ShiftRightSigned)
1835 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
1836 CYInfix_(false, 8, "<", Less)
1837 CYInfix_(false, 8, ">", Greater)
1838 CYInfix_(false, 8, "<=", LessOrEqual)
1839 CYInfix_(false, 8, ">=", GreaterOrEqual)
1840 CYInfix_(true, 8, "instanceof", InstanceOf)
1841 CYInfix_(true, 8, "in", In)
1842 CYInfix_(false, 9, "==", Equal)
1843 CYInfix_(false, 9, "!=", NotEqual)
1844 CYInfix_(false, 9, "===", Identical)
1845 CYInfix_(false, 9, "!==", NotIdentical)
1846 CYInfix_(false, 10, "&", BitwiseAnd)
1847 CYInfix_(false, 11, "^", BitwiseXOr)
1848 CYInfix_(false, 12, "|", BitwiseOr)
1849 CYInfix_(false, 13, "&&", LogicalAnd)
1850 CYInfix_(false, 14, "||", LogicalOr)
1851
1852 CYAssignment_("=", )
1853 CYAssignment_("*=", Multiply)
1854 CYAssignment_("/=", Divide)
1855 CYAssignment_("%=", Modulus)
1856 CYAssignment_("+=", Add)
1857 CYAssignment_("-=", Subtract)
1858 CYAssignment_("<<=", ShiftLeft)
1859 CYAssignment_(">>=", ShiftRightSigned)
1860 CYAssignment_(">>>=", ShiftRightUnsigned)
1861 CYAssignment_("&=", BitwiseAnd)
1862 CYAssignment_("^=", BitwiseXOr)
1863 CYAssignment_("|=", BitwiseOr)
1864
1865 #endif/*CYPARSER_HPP*/