]> git.saurik.com Git - cycript.git/blob - Parser.hpp
Implemented initial support for Ruby Blocks.
[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 CYContext {
361 apr_pool_t *pool_;
362 CYOptions &options_;
363 CYScope *scope_;
364 CYIdentifierUsageVector rename_;
365
366 CYContext(apr_pool_t *pool, CYOptions &options) :
367 pool_(pool),
368 options_(options),
369 scope_(NULL)
370 {
371 }
372
373 virtual ~CYContext() {
374 }
375
376 template <typename Type_>
377 void Replace(Type_ *&value) {
378 for (;;) if (value == NULL)
379 break;
380 else {
381 Type_ *replace(value->Replace(*this));
382 if (replace != value)
383 value = replace;
384 else break;
385 }
386 }
387 };
388
389 struct CYBlock :
390 CYStatement,
391 CYThing
392 {
393 CYStatement *statements_;
394
395 CYBlock(CYStatement *statements) :
396 statements_(statements)
397 {
398 }
399
400 operator CYStatement *() const {
401 return statements_;
402 }
403
404 void AddPrev(CYStatement *statement) {
405 CYStatement *last(statement);
406 while (last->next_ != NULL)
407 last = last->next_;
408 last->SetNext(statements_);
409 statements_ = statement;
410 }
411
412 virtual CYStatement *Replace(CYContext &context);
413
414 virtual void Output(CYOutput &out) const;
415 virtual void Output(CYOutput &out, CYFlags flags) const;
416 };
417
418 enum CYState {
419 CYClear,
420 CYRestricted,
421 CYNewLine
422 };
423
424 class CYDriver {
425 public:
426 CYPool pool_;
427
428 CYState state_;
429 void *scanner_;
430
431 const char *data_;
432 size_t size_;
433 FILE *file_;
434
435 bool strict_;
436
437 enum Condition {
438 RegExpCondition,
439 XMLContentCondition,
440 XMLTagCondition,
441 };
442
443 std::string filename_;
444
445 struct Error {
446 bool warning_;
447 cy::location location_;
448 std::string message_;
449 };
450
451 typedef std::vector<Error> Errors;
452
453 CYProgram *program_;
454 Errors errors_;
455
456 bool auto_;
457
458 struct Context {
459 CYExpression *context_;
460
461 Context(CYExpression *context) :
462 context_(context)
463 {
464 }
465
466 typedef std::vector<CYWord *> Words;
467 Words words_;
468 };
469
470 typedef std::vector<Context> Contexts;
471 Contexts contexts_;
472
473 CYExpression *context_;
474
475 enum Mode {
476 AutoNone,
477 AutoPrimary,
478 AutoDirect,
479 AutoIndirect,
480 AutoMessage
481 } mode_;
482
483 private:
484 void ScannerInit();
485 void ScannerDestroy();
486
487 public:
488 CYDriver(apr_pool_t *pool = NULL, const std::string &filename = "");
489 ~CYDriver();
490
491 Condition GetCondition();
492 void SetCondition(Condition condition);
493
494 void PushCondition(Condition condition);
495 void PopCondition();
496
497 void Warning(const cy::location &location, const char *message);
498 };
499
500 struct CYForInitialiser {
501 virtual ~CYForInitialiser() {
502 }
503
504 virtual void For(CYOutput &out) const = 0;
505 virtual CYExpression *Replace(CYContext &context) = 0;
506 };
507
508 struct CYForInInitialiser {
509 virtual ~CYForInInitialiser() {
510 }
511
512 virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
513 virtual const char *ForEachIn() const = 0;
514 virtual CYExpression *ForEachIn(CYContext &out) = 0;
515 virtual CYExpression *Replace(CYContext &context) = 0;
516 };
517
518 struct CYNumber;
519 struct CYString;
520
521 struct CYExpression :
522 CYNext<CYExpression>,
523 CYForInitialiser,
524 CYForInInitialiser,
525 CYClassName,
526 CYThing
527 {
528 virtual unsigned Precedence() const = 0;
529
530 virtual bool RightHand() const {
531 return true;
532 }
533
534 virtual void For(CYOutput &out) const;
535 virtual void ForIn(CYOutput &out, CYFlags flags) const;
536
537 virtual const char *ForEachIn() const;
538 virtual CYExpression *ForEachIn(CYContext &out);
539
540 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
541
542 virtual void Output(CYOutput &out) const;
543 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
544 void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
545
546 virtual CYExpression *ClassName(CYContext &context, bool object);
547 virtual void ClassName(CYOutput &out, bool object) const;
548
549 CYExpression *ReplaceAll(CYContext &context);
550
551 virtual CYExpression *Replace(CYContext &context) = 0;
552
553 virtual CYExpression *Primitive(CYContext &context) {
554 return this;
555 }
556
557 virtual CYNumber *Number(CYContext &context) {
558 return NULL;
559 }
560
561 virtual CYString *String(CYContext &context) {
562 return NULL;
563 }
564
565 virtual const char *Word() const {
566 return NULL;
567 }
568 };
569
570 #define CYAlphabetic(value) \
571 virtual bool Alphabetic() const { \
572 return value; \
573 }
574
575 #define CYPrecedence(value) \
576 virtual unsigned Precedence() const { \
577 return value; \
578 }
579
580 #define CYRightHand(value) \
581 virtual bool RightHand() const { \
582 return value; \
583 }
584
585 struct CYCompound :
586 CYExpression
587 {
588 CYExpression *expressions_;
589
590 CYCompound(CYExpression *expressions = NULL) :
591 expressions_(expressions)
592 {
593 }
594
595 void AddPrev(CYExpression *expression) {
596 CYExpression *last(expression);
597 while (last->next_ != NULL)
598 last = last->next_;
599 last->SetNext(expressions_);
600 expressions_ = expression;
601 }
602
603 CYPrecedence(17)
604
605 virtual CYExpression *Replace(CYContext &context);
606 void Output(CYOutput &out, CYFlags flags) const;
607 };
608
609 struct CYFunctionParameter :
610 CYNext<CYFunctionParameter>,
611 CYThing
612 {
613 CYIdentifier *name_;
614
615 CYFunctionParameter(CYIdentifier *name, CYFunctionParameter *next = NULL) :
616 CYNext<CYFunctionParameter>(next),
617 name_(name)
618 {
619 }
620
621 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
622 virtual void Output(CYOutput &out) const;
623 };
624
625 struct CYOptionalFunctionParameter :
626 CYFunctionParameter
627 {
628 CYExpression *initializer_;
629
630 CYOptionalFunctionParameter(CYIdentifier *name, CYExpression *initializer, CYFunctionParameter *next = NULL) :
631 CYFunctionParameter(name, next),
632 initializer_(initializer)
633 {
634 }
635
636 virtual CYFunctionParameter *Replace(CYContext &context, CYBlock &code);
637 virtual void Output(CYOutput &out) const;
638 };
639
640 struct CYComprehension :
641 CYNext<CYComprehension>,
642 CYThing
643 {
644 virtual const char *Name() const = 0;
645
646 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
647 CYFunctionParameter *Parameters(CYContext &context) const;
648 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
649 virtual void Output(CYOutput &out) const = 0;
650 };
651
652 struct CYForInComprehension :
653 CYComprehension
654 {
655 CYIdentifier *name_;
656 CYExpression *set_;
657
658 CYForInComprehension(CYIdentifier *name, CYExpression *set) :
659 name_(name),
660 set_(set)
661 {
662 }
663
664 virtual const char *Name() const {
665 return name_->Word();
666 }
667
668 virtual CYFunctionParameter *Parameter(CYContext &context) const;
669 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
670 virtual void Output(CYOutput &out) const;
671 };
672
673 struct CYForEachInComprehension :
674 CYComprehension
675 {
676 CYIdentifier *name_;
677 CYExpression *set_;
678
679 CYForEachInComprehension(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 CYIfComprehension :
695 CYComprehension
696 {
697 CYExpression *test_;
698
699 CYIfComprehension(CYExpression *test) :
700 test_(test)
701 {
702 }
703
704 virtual const char *Name() const {
705 return NULL;
706 }
707
708 virtual CYFunctionParameter *Parameter(CYContext &context) const;
709 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
710 virtual void Output(CYOutput &out) const;
711 };
712
713 struct CYArrayComprehension :
714 CYExpression
715 {
716 CYExpression *expression_;
717 CYComprehension *comprehensions_;
718
719 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
720 expression_(expression),
721 comprehensions_(comprehensions)
722 {
723 }
724
725 CYPrecedence(0)
726
727 virtual CYExpression *Replace(CYContext &context);
728 virtual void Output(CYOutput &out, CYFlags flags) const;
729 };
730
731 struct CYLiteral :
732 CYExpression
733 {
734 CYPrecedence(0)
735 CYRightHand(false)
736 };
737
738 struct CYTrivial :
739 CYLiteral
740 {
741 virtual CYExpression *Replace(CYContext &context);
742 };
743
744 struct CYMagic :
745 CYExpression
746 {
747 CYPrecedence(0)
748 CYRightHand(false)
749 };
750
751 struct CYRange {
752 uint64_t lo_;
753 uint64_t hi_;
754
755 CYRange(uint64_t lo, uint64_t hi) :
756 lo_(lo), hi_(hi)
757 {
758 }
759
760 bool operator [](uint8_t value) const {
761 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
762 }
763
764 void operator()(uint8_t value) {
765 if (value >> 7)
766 return;
767 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
768 }
769 };
770
771 extern CYRange DigitRange_;
772 extern CYRange WordStartRange_;
773 extern CYRange WordEndRange_;
774
775 struct CYString :
776 CYTrivial,
777 CYPropertyName
778 {
779 const char *value_;
780 size_t size_;
781
782 CYString() :
783 value_(NULL),
784 size_(0)
785 {
786 }
787
788 CYString(const char *value) :
789 value_(value),
790 size_(strlen(value))
791 {
792 }
793
794 CYString(const char *value, size_t size) :
795 value_(value),
796 size_(size)
797 {
798 }
799
800 CYString(const CYWord *word) :
801 value_(word->Word()),
802 size_(strlen(value_))
803 {
804 }
805
806 const char *Value() const {
807 return value_;
808 }
809
810 virtual const char *Word() const;
811
812 virtual CYNumber *Number(CYContext &context);
813 virtual CYString *String(CYContext &context);
814
815 CYString *Concat(CYContext &out, CYString *rhs) const;
816 virtual void Output(CYOutput &out, CYFlags flags) const;
817 virtual void PropertyName(CYOutput &out) const;
818 };
819
820 struct CYNumber :
821 CYTrivial,
822 CYPropertyName
823 {
824 double value_;
825
826 CYNumber(double value) :
827 value_(value)
828 {
829 }
830
831 double Value() const {
832 return value_;
833 }
834
835 virtual CYNumber *Number(CYContext &context);
836 virtual CYString *String(CYContext &context);
837
838 virtual void Output(CYOutput &out, CYFlags flags) const;
839 virtual void PropertyName(CYOutput &out) const;
840 };
841
842 struct CYRegEx :
843 CYTrivial
844 {
845 const char *value_;
846
847 CYRegEx(const char *value) :
848 value_(value)
849 {
850 }
851
852 const char *Value() const {
853 return value_;
854 }
855
856 virtual void Output(CYOutput &out, CYFlags flags) const;
857 };
858
859 struct CYNull :
860 CYWord,
861 CYTrivial
862 {
863 CYNull() :
864 CYWord("null")
865 {
866 }
867
868 virtual CYNumber *Number(CYContext &context);
869 virtual CYString *String(CYContext &context);
870
871 virtual void Output(CYOutput &out, CYFlags flags) const;
872 };
873
874 struct CYThis :
875 CYWord,
876 CYMagic
877 {
878 CYThis() :
879 CYWord("this")
880 {
881 }
882
883 virtual CYExpression *Replace(CYContext &context);
884 virtual void Output(CYOutput &out, CYFlags flags) const;
885 };
886
887 struct CYBoolean :
888 CYTrivial
889 {
890 virtual bool Value() const = 0;
891 virtual void Output(CYOutput &out, CYFlags flags) const;
892 };
893
894 struct CYFalse :
895 CYWord,
896 CYBoolean
897 {
898 CYFalse() :
899 CYWord("false")
900 {
901 }
902
903 virtual bool Value() const {
904 return false;
905 }
906
907 virtual CYNumber *Number(CYContext &context);
908 virtual CYString *String(CYContext &context);
909 };
910
911 struct CYTrue :
912 CYWord,
913 CYBoolean
914 {
915 CYTrue() :
916 CYWord("true")
917 {
918 }
919
920 virtual bool Value() const {
921 return true;
922 }
923
924 virtual CYNumber *Number(CYContext &context);
925 virtual CYString *String(CYContext &context);
926 };
927
928 struct CYVariable :
929 CYExpression
930 {
931 CYIdentifier *name_;
932
933 CYVariable(CYIdentifier *name) :
934 name_(name)
935 {
936 }
937
938 CYPrecedence(0)
939 CYRightHand(false)
940
941 virtual CYExpression *Replace(CYContext &context);
942 virtual void Output(CYOutput &out, CYFlags flags) const;
943 };
944
945 struct CYPrefix :
946 CYExpression
947 {
948 CYExpression *rhs_;
949
950 CYPrefix(CYExpression *rhs) :
951 rhs_(rhs)
952 {
953 }
954
955 virtual bool Alphabetic() const = 0;
956 virtual const char *Operator() const = 0;
957
958 CYPrecedence(4)
959
960 virtual CYExpression *Replace(CYContext &context);
961 virtual void Output(CYOutput &out, CYFlags flags) const;
962 };
963
964 struct CYInfix :
965 CYExpression
966 {
967 CYExpression *lhs_;
968 CYExpression *rhs_;
969
970 CYInfix(CYExpression *lhs, CYExpression *rhs) :
971 lhs_(lhs),
972 rhs_(rhs)
973 {
974 }
975
976 void SetLeft(CYExpression *lhs) {
977 lhs_ = lhs;
978 }
979
980 virtual bool Alphabetic() const = 0;
981 virtual const char *Operator() const = 0;
982
983 virtual CYExpression *Replace(CYContext &context);
984 virtual void Output(CYOutput &out, CYFlags flags) const;
985 };
986
987 struct CYPostfix :
988 CYExpression
989 {
990 CYExpression *lhs_;
991
992 CYPostfix(CYExpression *lhs) :
993 lhs_(lhs)
994 {
995 }
996
997 virtual const char *Operator() const = 0;
998
999 CYPrecedence(3)
1000
1001 virtual CYExpression *Replace(CYContext &context);
1002 virtual void Output(CYOutput &out, CYFlags flags) const;
1003 };
1004
1005 struct CYAssignment :
1006 CYExpression
1007 {
1008 CYExpression *lhs_;
1009 CYExpression *rhs_;
1010
1011 CYAssignment(CYExpression *lhs, CYExpression *rhs) :
1012 lhs_(lhs),
1013 rhs_(rhs)
1014 {
1015 }
1016
1017 void SetLeft(CYExpression *lhs) {
1018 lhs_ = lhs;
1019 }
1020
1021 virtual const char *Operator() const = 0;
1022
1023 CYPrecedence(16)
1024
1025 virtual CYExpression *Replace(CYContext &context);
1026 virtual void Output(CYOutput &out, CYFlags flags) const;
1027 };
1028
1029 struct CYArgument :
1030 CYNext<CYArgument>,
1031 CYThing
1032 {
1033 CYWord *name_;
1034 CYExpression *value_;
1035
1036 CYArgument(CYExpression *value, CYArgument *next = NULL) :
1037 CYNext<CYArgument>(next),
1038 name_(NULL),
1039 value_(value)
1040 {
1041 }
1042
1043 CYArgument(CYWord *name, CYExpression *value, CYArgument *next = NULL) :
1044 CYNext<CYArgument>(next),
1045 name_(name),
1046 value_(value)
1047 {
1048 }
1049
1050 void Replace(CYContext &context);
1051 void Output(CYOutput &out) const;
1052 };
1053
1054 struct CYBlank :
1055 public CYWord
1056 {
1057 CYBlank() :
1058 CYWord("")
1059 {
1060 }
1061 };
1062
1063 struct CYClause :
1064 CYThing,
1065 CYNext<CYClause>
1066 {
1067 CYExpression *case_;
1068 CYStatement *statements_;
1069
1070 CYClause(CYExpression *_case, CYStatement *statements) :
1071 case_(_case),
1072 statements_(statements)
1073 {
1074 }
1075
1076 void Replace(CYContext &context);
1077 virtual void Output(CYOutput &out) const;
1078 };
1079
1080 struct CYElement :
1081 CYNext<CYElement>,
1082 CYThing
1083 {
1084 CYExpression *value_;
1085
1086 CYElement(CYExpression *value, CYElement *next) :
1087 CYNext<CYElement>(next),
1088 value_(value)
1089 {
1090 }
1091
1092 void Replace(CYContext &context);
1093 void Output(CYOutput &out) const;
1094 };
1095
1096 struct CYArray :
1097 CYLiteral
1098 {
1099 CYElement *elements_;
1100
1101 CYArray(CYElement *elements = NULL) :
1102 elements_(elements)
1103 {
1104 }
1105
1106 virtual CYExpression *Replace(CYContext &context);
1107 virtual void Output(CYOutput &out, CYFlags flags) const;
1108 };
1109
1110 struct CYProperty :
1111 CYNext<CYProperty>,
1112 CYThing
1113 {
1114 CYPropertyName *name_;
1115 CYExpression *value_;
1116
1117 CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
1118 CYNext<CYProperty>(next),
1119 name_(name),
1120 value_(value)
1121 {
1122 }
1123
1124 void Replace(CYContext &context);
1125 virtual void Output(CYOutput &out) const;
1126 };
1127
1128 struct CYDeclaration :
1129 CYForInInitialiser
1130 {
1131 CYIdentifier *identifier_;
1132 CYExpression *initialiser_;
1133
1134 CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser = NULL) :
1135 identifier_(identifier),
1136 initialiser_(initialiser)
1137 {
1138 }
1139
1140 virtual void ForIn(CYOutput &out, CYFlags flags) const;
1141
1142 virtual const char *ForEachIn() const;
1143 virtual CYExpression *ForEachIn(CYContext &out);
1144
1145 virtual CYExpression *Replace(CYContext &context);
1146 virtual CYAssignment *Assignment(CYContext &context);
1147
1148 virtual void Output(CYOutput &out, CYFlags flags) const;
1149 };
1150
1151 struct CYDeclarations :
1152 CYNext<CYDeclarations>,
1153 CYThing,
1154 CYForInitialiser
1155 {
1156 CYDeclaration *declaration_;
1157
1158 CYDeclarations(CYDeclaration *declaration, CYDeclarations *next = NULL) :
1159 CYNext<CYDeclarations>(next),
1160 declaration_(declaration)
1161 {
1162 }
1163
1164 virtual void For(CYOutput &out) const;
1165
1166 virtual CYCompound *Replace(CYContext &context);
1167 CYProperty *Property(CYContext &context);
1168
1169 virtual void Output(CYOutput &out) const;
1170 virtual void Output(CYOutput &out, CYFlags flags) const;
1171 };
1172
1173 struct CYVar :
1174 CYStatement
1175 {
1176 CYDeclarations *declarations_;
1177
1178 CYVar(CYDeclarations *declarations) :
1179 declarations_(declarations)
1180 {
1181 }
1182
1183 virtual CYStatement *Replace(CYContext &context);
1184 virtual void Output(CYOutput &out, CYFlags flags) const;
1185 };
1186
1187 struct CYLet :
1188 CYStatement
1189 {
1190 CYDeclarations *declarations_;
1191 CYBlock code_;
1192
1193 CYLet(CYDeclarations *declarations, CYStatement *statements) :
1194 declarations_(declarations),
1195 code_(statements)
1196 {
1197 }
1198
1199 virtual CYStatement *Replace(CYContext &context);
1200 virtual void Output(CYOutput &out, CYFlags flags) const;
1201 };
1202
1203 struct CYFor :
1204 CYStatement
1205 {
1206 CYForInitialiser *initialiser_;
1207 CYExpression *test_;
1208 CYExpression *increment_;
1209 CYStatement *code_;
1210
1211 CYFor(CYForInitialiser *initialiser, CYExpression *test, CYExpression *increment, CYStatement *code) :
1212 initialiser_(initialiser),
1213 test_(test),
1214 increment_(increment),
1215 code_(code)
1216 {
1217 }
1218
1219 virtual CYStatement *Replace(CYContext &context);
1220 virtual void Output(CYOutput &out, CYFlags flags) const;
1221 };
1222
1223 struct CYForIn :
1224 CYStatement
1225 {
1226 CYForInInitialiser *initialiser_;
1227 CYExpression *set_;
1228 CYStatement *code_;
1229
1230 CYForIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1231 initialiser_(initialiser),
1232 set_(set),
1233 code_(code)
1234 {
1235 }
1236
1237 virtual CYStatement *Replace(CYContext &context);
1238 virtual void Output(CYOutput &out, CYFlags flags) const;
1239 };
1240
1241 struct CYForEachIn :
1242 CYStatement
1243 {
1244 CYForInInitialiser *initialiser_;
1245 CYExpression *set_;
1246 CYStatement *code_;
1247
1248 CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
1249 initialiser_(initialiser),
1250 set_(set),
1251 code_(code)
1252 {
1253 }
1254
1255 virtual CYStatement *Replace(CYContext &context);
1256 virtual void Output(CYOutput &out, CYFlags flags) const;
1257 };
1258
1259 struct CYObject :
1260 CYLiteral
1261 {
1262 CYProperty *properties_;
1263
1264 CYObject(CYProperty *properties) :
1265 properties_(properties)
1266 {
1267 }
1268
1269 virtual CYExpression *Replace(CYContext &context);
1270 void Output(CYOutput &out, CYFlags flags) const;
1271 };
1272
1273 struct CYMember :
1274 CYExpression
1275 {
1276 CYExpression *object_;
1277 CYExpression *property_;
1278
1279 CYMember(CYExpression *object, CYExpression *property) :
1280 object_(object),
1281 property_(property)
1282 {
1283 }
1284
1285 void SetLeft(CYExpression *object) {
1286 object_ = object;
1287 }
1288
1289 void Replace_(CYContext &context);
1290 };
1291
1292 struct CYDirectMember :
1293 CYMember
1294 {
1295 CYDirectMember(CYExpression *object, CYExpression *property) :
1296 CYMember(object, property)
1297 {
1298 }
1299
1300 CYPrecedence(1)
1301 CYRightHand(false)
1302
1303 virtual CYExpression *Replace(CYContext &context);
1304 virtual void Output(CYOutput &out, CYFlags flags) const;
1305 };
1306
1307 struct CYIndirectMember :
1308 CYMember
1309 {
1310 CYIndirectMember(CYExpression *object, CYExpression *property) :
1311 CYMember(object, property)
1312 {
1313 }
1314
1315 CYPrecedence(1)
1316 CYRightHand(false)
1317
1318 virtual CYExpression *Replace(CYContext &context);
1319 virtual void Output(CYOutput &out, CYFlags flags) const;
1320 };
1321
1322 struct CYNew :
1323 CYExpression
1324 {
1325 CYExpression *constructor_;
1326 CYArgument *arguments_;
1327
1328 CYNew(CYExpression *constructor, CYArgument *arguments) :
1329 constructor_(constructor),
1330 arguments_(arguments)
1331 {
1332 }
1333
1334 virtual unsigned Precedence() const {
1335 return arguments_ == NULL ? 2 : 1;
1336 }
1337
1338 CYRightHand(false)
1339
1340 virtual CYExpression *Replace(CYContext &context);
1341 virtual void Output(CYOutput &out, CYFlags flags) const;
1342
1343 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1344 };
1345
1346 struct CYCall :
1347 CYExpression
1348 {
1349 CYExpression *function_;
1350 CYArgument *arguments_;
1351
1352 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1353 function_(function),
1354 arguments_(arguments)
1355 {
1356 }
1357
1358 CYPrecedence(1)
1359 CYRightHand(false)
1360
1361 virtual CYExpression *Replace(CYContext &context);
1362 virtual void Output(CYOutput &out, CYFlags flags) const;
1363
1364 virtual CYExpression *AddArgument(CYContext &context, CYExpression *value);
1365 };
1366
1367 struct CYRubyProc;
1368
1369 struct CYRubyBlock :
1370 CYExpression
1371 {
1372 CYExpression *call_;
1373 CYRubyProc *proc_;
1374
1375 CYRubyBlock(CYExpression *call, CYRubyProc *proc) :
1376 call_(call),
1377 proc_(proc)
1378 {
1379 }
1380
1381 CYPrecedence(1)
1382 CYRightHand(false)
1383
1384 virtual CYExpression *Replace(CYContext &context);
1385 virtual void Output(CYOutput &out, CYFlags flags) const;
1386 };
1387
1388 struct CYIf :
1389 CYStatement
1390 {
1391 CYExpression *test_;
1392 CYStatement *true_;
1393 CYStatement *false_;
1394
1395 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1396 test_(test),
1397 true_(_true),
1398 false_(_false)
1399 {
1400 }
1401
1402 virtual CYStatement *Replace(CYContext &context);
1403 virtual void Output(CYOutput &out, CYFlags flags) const;
1404 };
1405
1406 struct CYDoWhile :
1407 CYStatement
1408 {
1409 CYExpression *test_;
1410 CYStatement *code_;
1411
1412 CYDoWhile(CYExpression *test, CYStatement *code) :
1413 test_(test),
1414 code_(code)
1415 {
1416 }
1417
1418 virtual CYStatement *Replace(CYContext &context);
1419 virtual void Output(CYOutput &out, CYFlags flags) const;
1420 };
1421
1422 struct CYWhile :
1423 CYStatement
1424 {
1425 CYExpression *test_;
1426 CYStatement *code_;
1427
1428 CYWhile(CYExpression *test, CYStatement *code) :
1429 test_(test),
1430 code_(code)
1431 {
1432 }
1433
1434 virtual CYStatement *Replace(CYContext &context);
1435 virtual void Output(CYOutput &out, CYFlags flags) const;
1436 };
1437
1438 // XXX: this should be split up into CYAnonymousFunction and CYNamedFunction (subclass)
1439 struct CYFunction {
1440 CYIdentifier *name_;
1441 CYFunctionParameter *parameters_;
1442 CYBlock code_;
1443
1444 CYFunction(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1445 name_(name),
1446 parameters_(parameters),
1447 code_(statements)
1448 {
1449 }
1450
1451 virtual ~CYFunction() {
1452 }
1453
1454 void Inject(CYContext &context);
1455 virtual void Replace_(CYContext &context, bool outer);
1456 virtual void Output(CYOutput &out, CYFlags flags) const;
1457 };
1458
1459 // XXX: this should be split up into CYAnonymousFunctionExpression and CYNamedFunctionExpression
1460 struct CYFunctionExpression :
1461 CYFunction,
1462 CYExpression
1463 {
1464 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1465 CYFunction(name, parameters, statements)
1466 {
1467 }
1468
1469 CYPrecedence(0)
1470 CYRightHand(false)
1471
1472 virtual CYExpression *Replace(CYContext &context);
1473 virtual void Output(CYOutput &out, CYFlags flags) const;
1474 };
1475
1476 // XXX: this should derive from CYAnonymousFunctionExpression
1477 struct CYRubyProc :
1478 CYFunctionExpression
1479 {
1480 CYRubyProc(CYFunctionParameter *parameters, CYStatement *statements) :
1481 CYFunctionExpression(NULL, parameters, statements)
1482 {
1483 }
1484
1485 virtual CYExpression *Replace(CYContext &context);
1486 virtual void Output(CYOutput &out, CYFlags flags) const;
1487 };
1488
1489 // XXX: this should derive from CYNamedFunction
1490 struct CYFunctionStatement :
1491 CYFunction,
1492 CYStatement
1493 {
1494 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) :
1495 CYFunction(name, parameters, statements)
1496 {
1497 }
1498
1499 virtual CYStatement *Replace(CYContext &context);
1500 virtual void Output(CYOutput &out, CYFlags flags) const;
1501 };
1502
1503 struct CYExpress :
1504 CYStatement
1505 {
1506 CYExpression *expression_;
1507
1508 CYExpress(CYExpression *expression) :
1509 expression_(expression)
1510 {
1511 if (expression == NULL)
1512 throw;
1513 }
1514
1515 virtual CYStatement *Collapse(CYContext &context);
1516 virtual CYStatement *Replace(CYContext &context);
1517 virtual void Output(CYOutput &out, CYFlags flags) const;
1518 };
1519
1520 struct CYContinue :
1521 CYStatement
1522 {
1523 CYIdentifier *label_;
1524
1525 CYContinue(CYIdentifier *label) :
1526 label_(label)
1527 {
1528 }
1529
1530 virtual CYStatement *Replace(CYContext &context);
1531 virtual void Output(CYOutput &out, CYFlags flags) const;
1532 };
1533
1534 struct CYBreak :
1535 CYStatement
1536 {
1537 CYIdentifier *label_;
1538
1539 CYBreak(CYIdentifier *label) :
1540 label_(label)
1541 {
1542 }
1543
1544 virtual CYStatement *Replace(CYContext &context);
1545 virtual void Output(CYOutput &out, CYFlags flags) const;
1546 };
1547
1548 struct CYReturn :
1549 CYStatement
1550 {
1551 CYExpression *value_;
1552
1553 CYReturn(CYExpression *value) :
1554 value_(value)
1555 {
1556 }
1557
1558 virtual CYStatement *Replace(CYContext &context);
1559 virtual void Output(CYOutput &out, CYFlags flags) const;
1560 };
1561
1562 struct CYEmpty :
1563 CYStatement
1564 {
1565 virtual CYStatement *Collapse(CYContext &context);
1566 virtual CYStatement *Replace(CYContext &context);
1567 virtual void Output(CYOutput &out, CYFlags flags) const;
1568 };
1569
1570 struct CYFinally :
1571 CYThing
1572 {
1573 CYBlock code_;
1574
1575 CYFinally(CYStatement *statements) :
1576 code_(statements)
1577 {
1578 }
1579
1580 void Replace(CYContext &context);
1581 virtual void Output(CYOutput &out) const;
1582 };
1583
1584 namespace cy {
1585 namespace Syntax {
1586
1587 struct Catch :
1588 CYThing
1589 {
1590 CYIdentifier *name_;
1591 CYBlock code_;
1592
1593 Catch(CYIdentifier *name, CYStatement *statements) :
1594 name_(name),
1595 code_(statements)
1596 {
1597 }
1598
1599 void Replace(CYContext &context);
1600 virtual void Output(CYOutput &out) const;
1601 };
1602
1603 struct Try :
1604 CYStatement
1605 {
1606 CYBlock code_;
1607 Catch *catch_;
1608 CYFinally *finally_;
1609
1610 Try(CYStatement *statements, Catch *_catch, CYFinally *finally) :
1611 code_(statements),
1612 catch_(_catch),
1613 finally_(finally)
1614 {
1615 }
1616
1617 virtual CYStatement *Replace(CYContext &context);
1618 virtual void Output(CYOutput &out, CYFlags flags) const;
1619 };
1620
1621 struct Throw :
1622 CYStatement
1623 {
1624 CYExpression *value_;
1625
1626 Throw(CYExpression *value) :
1627 value_(value)
1628 {
1629 }
1630
1631 virtual CYStatement *Replace(CYContext &context);
1632 virtual void Output(CYOutput &out, CYFlags flags) const;
1633 };
1634
1635 } }
1636
1637 struct CYWith :
1638 CYStatement
1639 {
1640 CYExpression *scope_;
1641 CYStatement *code_;
1642
1643 CYWith(CYExpression *scope, CYStatement *code) :
1644 scope_(scope),
1645 code_(code)
1646 {
1647 }
1648
1649 virtual CYStatement *Replace(CYContext &context);
1650 virtual void Output(CYOutput &out, CYFlags flags) const;
1651 };
1652
1653 struct CYSwitch :
1654 CYStatement
1655 {
1656 CYExpression *value_;
1657 CYClause *clauses_;
1658
1659 CYSwitch(CYExpression *value, CYClause *clauses) :
1660 value_(value),
1661 clauses_(clauses)
1662 {
1663 }
1664
1665 virtual CYStatement *Replace(CYContext &context);
1666 virtual void Output(CYOutput &out, CYFlags flags) const;
1667 };
1668
1669 struct CYCondition :
1670 CYExpression
1671 {
1672 CYExpression *test_;
1673 CYExpression *true_;
1674 CYExpression *false_;
1675
1676 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
1677 test_(test),
1678 true_(_true),
1679 false_(_false)
1680 {
1681 }
1682
1683 CYPrecedence(15)
1684
1685 virtual CYExpression *Replace(CYContext &context);
1686 virtual void Output(CYOutput &out, CYFlags flags) const;
1687 };
1688
1689 struct CYAddressOf :
1690 CYPrefix
1691 {
1692 CYAddressOf(CYExpression *rhs) :
1693 CYPrefix(rhs)
1694 {
1695 }
1696
1697 virtual const char *Operator() const {
1698 return "&";
1699 }
1700
1701 CYAlphabetic(false)
1702
1703 virtual CYExpression *Replace(CYContext &context);
1704 };
1705
1706 struct CYIndirect :
1707 CYPrefix
1708 {
1709 CYIndirect(CYExpression *rhs) :
1710 CYPrefix(rhs)
1711 {
1712 }
1713
1714 virtual const char *Operator() const {
1715 return "*";
1716 }
1717
1718 CYAlphabetic(false)
1719
1720 virtual CYExpression *Replace(CYContext &context);
1721 };
1722
1723 #define CYReplace \
1724 virtual CYExpression *Replace(CYContext &context);
1725
1726 #define CYPostfix_(op, name, args...) \
1727 struct CY ## name : \
1728 CYPostfix \
1729 { args \
1730 CY ## name(CYExpression *lhs) : \
1731 CYPostfix(lhs) \
1732 { \
1733 } \
1734 \
1735 virtual const char *Operator() const { \
1736 return op; \
1737 } \
1738 };
1739
1740 #define CYPrefix_(alphabetic, op, name, args...) \
1741 struct CY ## name : \
1742 CYPrefix \
1743 { args \
1744 CY ## name(CYExpression *rhs) : \
1745 CYPrefix(rhs) \
1746 { \
1747 } \
1748 \
1749 CYAlphabetic(alphabetic) \
1750 \
1751 virtual const char *Operator() const { \
1752 return op; \
1753 } \
1754 };
1755
1756 #define CYInfix_(alphabetic, precedence, op, name, args...) \
1757 struct CY ## name : \
1758 CYInfix \
1759 { args \
1760 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
1761 CYInfix(lhs, rhs) \
1762 { \
1763 } \
1764 \
1765 CYAlphabetic(alphabetic) \
1766 CYPrecedence(precedence) \
1767 \
1768 virtual const char *Operator() const { \
1769 return op; \
1770 } \
1771 };
1772
1773 #define CYAssignment_(op, name, args...) \
1774 struct CY ## name ## Assign : \
1775 CYAssignment \
1776 { args \
1777 CY ## name ## Assign(CYExpression *lhs, CYExpression *rhs) : \
1778 CYAssignment(lhs, rhs) \
1779 { \
1780 } \
1781 \
1782 virtual const char *Operator() const { \
1783 return op; \
1784 } \
1785 };
1786
1787 CYPostfix_("++", PostIncrement)
1788 CYPostfix_("--", PostDecrement)
1789
1790 CYPrefix_(true, "delete", Delete)
1791 CYPrefix_(true, "void", Void)
1792 CYPrefix_(true, "typeof", TypeOf)
1793 CYPrefix_(false, "++", PreIncrement)
1794 CYPrefix_(false, "--", PreDecrement)
1795 CYPrefix_(false, "+", Affirm)
1796 CYPrefix_(false, "-", Negate)
1797 CYPrefix_(false, "~", BitwiseNot)
1798 CYPrefix_(false, "!", LogicalNot)
1799
1800 CYInfix_(false, 5, "*", Multiply)
1801 CYInfix_(false, 5, "/", Divide)
1802 CYInfix_(false, 5, "%", Modulus)
1803 CYInfix_(false, 6, "+", Add, CYReplace)
1804 CYInfix_(false, 6, "-", Subtract)
1805 CYInfix_(false, 7, "<<", ShiftLeft)
1806 CYInfix_(false, 7, ">>", ShiftRightSigned)
1807 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
1808 CYInfix_(false, 8, "<", Less)
1809 CYInfix_(false, 8, ">", Greater)
1810 CYInfix_(false, 8, "<=", LessOrEqual)
1811 CYInfix_(false, 8, ">=", GreaterOrEqual)
1812 CYInfix_(true, 8, "instanceof", InstanceOf)
1813 CYInfix_(true, 8, "in", In)
1814 CYInfix_(false, 9, "==", Equal)
1815 CYInfix_(false, 9, "!=", NotEqual)
1816 CYInfix_(false, 9, "===", Identical)
1817 CYInfix_(false, 9, "!==", NotIdentical)
1818 CYInfix_(false, 10, "&", BitwiseAnd)
1819 CYInfix_(false, 11, "^", BitwiseXOr)
1820 CYInfix_(false, 12, "|", BitwiseOr)
1821 CYInfix_(false, 13, "&&", LogicalAnd)
1822 CYInfix_(false, 14, "||", LogicalOr)
1823
1824 CYAssignment_("=", )
1825 CYAssignment_("*=", Multiply)
1826 CYAssignment_("/=", Divide)
1827 CYAssignment_("%=", Modulus)
1828 CYAssignment_("+=", Add)
1829 CYAssignment_("-=", Subtract)
1830 CYAssignment_("<<=", ShiftLeft)
1831 CYAssignment_(">>=", ShiftRightSigned)
1832 CYAssignment_(">>>=", ShiftRightUnsigned)
1833 CYAssignment_("&=", BitwiseAnd)
1834 CYAssignment_("^=", BitwiseXOr)
1835 CYAssignment_("|=", BitwiseOr)
1836
1837 #endif/*CYPARSER_HPP*/