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