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