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