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