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