]> git.saurik.com Git - cycript.git/blob - Syntax.hpp
Avoid clang_tokenize and just get the source file.
[cycript.git] / Syntax.hpp
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
3 */
4
5 /* GNU Affero General Public License, Version 3 {{{ */
6 /*
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20 /* }}} */
21
22 #ifndef CYCRIPT_SYNTAX_HPP
23 #define CYCRIPT_SYNTAX_HPP
24
25 #include <cstdio>
26 #include <cstdlib>
27
28 #include <streambuf>
29 #include <string>
30 #include <vector>
31
32 #include "List.hpp"
33 #include "Location.hpp"
34 #include "Options.hpp"
35 #include "Pooling.hpp"
36 #include "String.hpp"
37
38 double CYCastDouble(const char *value, size_t size);
39 double CYCastDouble(const char *value);
40 double CYCastDouble(CYUTF8String value);
41
42 void CYNumerify(std::ostringstream &str, double value);
43 void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c = false);
44
45 // XXX: this really should not be here ... :/
46 void *CYPoolFile(CYPool &pool, const char *path, size_t *psize);
47 CYUTF8String CYPoolFileUTF8String(CYPool &pool, const char *path);
48
49 struct CYContext;
50
51 struct CYThing {
52 virtual void Output(struct CYOutput &out) const = 0;
53 };
54
55 struct CYOutput {
56 std::streambuf &out_;
57 CYPosition position_;
58
59 CYOptions &options_;
60 bool pretty_;
61 unsigned indent_;
62 unsigned recent_;
63 bool right_;
64
65 enum {
66 NoMode,
67 NoLetter,
68 NoPlus,
69 NoHyphen,
70 Terminated
71 } mode_;
72
73 CYOutput(std::streambuf &out, CYOptions &options) :
74 out_(out),
75 options_(options),
76 pretty_(false),
77 indent_(0),
78 recent_(0),
79 right_(false),
80 mode_(NoMode)
81 {
82 }
83
84 void Check(char value);
85 void Terminate();
86
87 _finline void operator ()(char value) {
88 _assert(out_.sputc(value) != EOF);
89 recent_ = indent_;
90 if (value == '\n')
91 position_.Lines(1);
92 else
93 position_.Columns(1);
94 }
95
96 _finline void operator ()(const char *data, std::streamsize size) {
97 _assert(out_.sputn(data, size) == size);
98 recent_ = indent_;
99 position_.Columns(size);
100 }
101
102 _finline void operator ()(const char *data) {
103 return operator ()(data, strlen(data));
104 }
105
106 CYOutput &operator <<(char rhs);
107 CYOutput &operator <<(const char *rhs);
108
109 _finline CYOutput &operator <<(const CYThing *rhs) {
110 if (rhs != NULL)
111 rhs->Output(*this);
112 return *this;
113 }
114
115 _finline CYOutput &operator <<(const CYThing &rhs) {
116 rhs.Output(*this);
117 return *this;
118 }
119 };
120
121 struct CYExpression;
122 struct CYAssignment;
123
124 struct CYPropertyName {
125 virtual bool Computed() const {
126 return false;
127 }
128
129 virtual bool Constructor() const {
130 return false;
131 }
132
133 virtual CYExpression *PropertyName(CYContext &context) = 0;
134 virtual void PropertyName(CYOutput &out) const = 0;
135 };
136
137 enum CYNeeded {
138 CYNever = -1,
139 CYSometimes = 0,
140 CYAlways = 1,
141 };
142
143 enum CYFlags {
144 CYNoFlags = 0,
145 CYNoBrace = (1 << 0),
146 CYNoFunction = (1 << 1),
147 CYNoClass = (1 << 2),
148 CYNoIn = (1 << 3),
149 CYNoCall = (1 << 4),
150 CYNoRightHand = (1 << 5),
151 CYNoDangle = (1 << 6),
152 CYNoInteger = (1 << 7),
153 CYNoBFC = (CYNoBrace | CYNoFunction | CYNoClass),
154 };
155
156 _finline CYFlags operator ~(CYFlags rhs) {
157 return static_cast<CYFlags>(~static_cast<unsigned>(rhs));
158 }
159
160 _finline CYFlags operator &(CYFlags lhs, CYFlags rhs) {
161 return static_cast<CYFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs));
162 }
163
164 _finline CYFlags operator |(CYFlags lhs, CYFlags rhs) {
165 return static_cast<CYFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
166 }
167
168 _finline CYFlags &operator |=(CYFlags &lhs, CYFlags rhs) {
169 return lhs = lhs | rhs;
170 }
171
172 _finline CYFlags CYLeft(CYFlags flags) {
173 return flags & ~(CYNoDangle | CYNoInteger);
174 }
175
176 _finline CYFlags CYRight(CYFlags flags) {
177 return flags & ~CYNoBFC;
178 }
179
180 _finline CYFlags CYCenter(CYFlags flags) {
181 return CYLeft(CYRight(flags));
182 }
183
184 enum CYCompactType {
185 CYCompactNone,
186 CYCompactLong,
187 CYCompactShort,
188 };
189
190 #define CYCompact(type) \
191 virtual CYCompactType Compact() const { \
192 return CYCompact ## type; \
193 }
194
195 struct CYStatement :
196 CYNext<CYStatement>,
197 CYThing
198 {
199 void Single(CYOutput &out, CYFlags flags, CYCompactType request) const;
200 void Multiple(CYOutput &out, CYFlags flags = CYNoFlags) const;
201 virtual void Output(CYOutput &out) const;
202
203 virtual CYStatement *Replace(CYContext &context) = 0;
204
205 virtual CYCompactType Compact() const = 0;
206 virtual CYStatement *Return();
207
208 private:
209 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
210 };
211
212 typedef CYList<CYStatement> CYStatements;
213
214 struct CYForInitializer :
215 CYStatement
216 {
217 virtual CYForInitializer *Replace(CYContext &context) = 0;
218 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
219 };
220
221 struct CYWord :
222 CYThing,
223 CYPropertyName
224 {
225 const char *word_;
226
227 CYWord(const char *word) :
228 word_(word)
229 {
230 }
231
232 virtual bool Constructor() const {
233 return strcmp(word_, "constructor") == 0;
234 }
235
236 virtual const char *Word() const;
237 virtual void Output(CYOutput &out) const;
238
239 virtual CYExpression *PropertyName(CYContext &context);
240 virtual void PropertyName(CYOutput &out) const;
241 };
242
243 _finline std::ostream &operator <<(std::ostream &lhs, const CYWord &rhs) {
244 lhs << &rhs << '=';
245 return lhs << rhs.Word();
246 }
247
248 enum CYIdentifierKind {
249 CYIdentifierArgument,
250 CYIdentifierCatch,
251 CYIdentifierGlobal,
252 CYIdentifierLexical,
253 CYIdentifierMagic,
254 CYIdentifierOther,
255 CYIdentifierVariable,
256 };
257
258 struct CYIdentifier :
259 CYNext<CYIdentifier>,
260 CYWord
261 {
262 CYLocation location_;
263 size_t offset_;
264 size_t usage_;
265
266 CYIdentifier(const char *word) :
267 CYWord(word),
268 offset_(0),
269 usage_(0)
270 {
271 }
272
273 virtual const char *Word() const;
274 CYIdentifier *Replace(CYContext &context, CYIdentifierKind);
275 };
276
277 struct CYLabel :
278 CYStatement
279 {
280 CYIdentifier *name_;
281 CYStatement *statement_;
282
283 CYLabel(CYIdentifier *name, CYStatement *statement) :
284 name_(name),
285 statement_(statement)
286 {
287 }
288
289 CYCompact(Short)
290
291 virtual CYStatement *Replace(CYContext &context);
292 virtual void Output(CYOutput &out, CYFlags flags) const;
293 };
294
295 struct CYCStringLess :
296 std::binary_function<const char *, const char *, bool>
297 {
298 _finline bool operator ()(const char *lhs, const char *rhs) const {
299 return strcmp(lhs, rhs) < 0;
300 }
301 };
302
303 struct CYIdentifierValueLess :
304 std::binary_function<CYIdentifier *, CYIdentifier *, bool>
305 {
306 _finline bool operator ()(CYIdentifier *lhs, CYIdentifier *rhs) const {
307 return CYCStringLess()(lhs->Word(), rhs->Word());
308 }
309 };
310
311 struct CYIdentifierFlags :
312 CYNext<CYIdentifierFlags>
313 {
314 CYIdentifier *identifier_;
315 CYIdentifierKind kind_;
316 unsigned count_;
317 unsigned offset_;
318
319 CYIdentifierFlags(CYIdentifier *identifier, CYIdentifierKind kind, CYIdentifierFlags *next = NULL) :
320 CYNext<CYIdentifierFlags>(next),
321 identifier_(identifier),
322 kind_(kind),
323 count_(0),
324 offset_(0)
325 {
326 }
327 };
328
329 struct CYScope {
330 bool transparent_;
331 CYScope *parent_;
332 bool damaged_;
333 CYIdentifierFlags *shadow_;
334
335 CYIdentifierFlags *internal_;
336
337 CYScope(bool transparent, CYContext &context);
338
339 CYIdentifierFlags *Lookup(CYContext &context, const char *word);
340 CYIdentifierFlags *Lookup(CYContext &context, CYIdentifier *identifier);
341
342 CYIdentifierFlags *Declare(CYContext &context, CYIdentifier *identifier, CYIdentifierKind kind);
343 void Merge(CYContext &context, const CYIdentifierFlags *flags);
344
345 void Close(CYContext &context, CYStatement *&statements);
346 void Close(CYContext &context);
347 void Damage();
348 };
349
350 struct CYScript :
351 CYThing
352 {
353 CYStatement *code_;
354
355 CYScript(CYStatement *code) :
356 code_(code)
357 {
358 }
359
360 virtual void Replace(CYContext &context);
361 virtual void Output(CYOutput &out) const;
362 };
363
364 struct CYNonLocal;
365 struct CYThisScope;
366
367 struct CYContext {
368 CYOptions &options_;
369
370 CYScope *scope_;
371 CYThisScope *this_;
372 CYIdentifier *super_;
373
374 CYNonLocal *nonlocal_;
375 CYNonLocal *nextlocal_;
376 unsigned unique_;
377
378 std::vector<CYIdentifier *> replace_;
379
380 CYContext(CYOptions &options) :
381 options_(options),
382 scope_(NULL),
383 this_(NULL),
384 super_(NULL),
385 nonlocal_(NULL),
386 nextlocal_(NULL),
387 unique_(0)
388 {
389 }
390
391 void ReplaceAll(CYStatement *&statement) {
392 if (statement == NULL)
393 return;
394 CYStatement *next(statement->next_);
395
396 Replace(statement);
397 ReplaceAll(next);
398
399 if (statement == NULL)
400 statement = next;
401 else
402 statement->SetNext(next);
403 }
404
405 template <typename Type_>
406 void Replace(Type_ *&value) {
407 for (;;) if (value == NULL)
408 break;
409 else {
410 Type_ *replace(value->Replace(*this));
411 if (replace != value)
412 value = replace;
413 else break;
414 }
415 }
416
417 void NonLocal(CYStatement *&statements);
418 CYIdentifier *Unique();
419 };
420
421 struct CYNonLocal {
422 CYIdentifier *identifier_;
423
424 CYNonLocal() :
425 identifier_(NULL)
426 {
427 }
428
429 CYIdentifier *Target(CYContext &context) {
430 if (identifier_ == NULL)
431 identifier_ = context.Unique();
432 return identifier_;
433 }
434 };
435
436 struct CYThisScope :
437 CYNext<CYThisScope>
438 {
439 CYIdentifier *identifier_;
440
441 CYThisScope() :
442 identifier_(NULL)
443 {
444 }
445
446 CYIdentifier *Identifier(CYContext &context) {
447 if (next_ != NULL)
448 return next_->Identifier(context);
449 if (identifier_ == NULL)
450 identifier_ = context.Unique();
451 return identifier_;
452 }
453 };
454
455 struct CYBlock :
456 CYStatement
457 {
458 CYStatement *code_;
459
460 CYBlock(CYStatement *code) :
461 code_(code)
462 {
463 }
464
465 CYCompact(Short)
466
467 virtual CYStatement *Replace(CYContext &context);
468
469 virtual void Output(CYOutput &out, CYFlags flags) const;
470
471 virtual CYStatement *Return();
472 };
473
474 struct CYTarget;
475 struct CYVar;
476
477 struct CYForInInitializer {
478 virtual CYStatement *Initialize(CYContext &context, CYExpression *value) = 0;
479
480 virtual CYTarget *Replace(CYContext &context) = 0;
481 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
482 };
483
484 struct CYFunctionParameter;
485
486 struct CYNumber;
487 struct CYString;
488
489 struct CYExpression :
490 CYThing
491 {
492 virtual int Precedence() const = 0;
493
494 virtual bool RightHand() const {
495 return true;
496 }
497
498 virtual bool Eval() const {
499 return false;
500 }
501
502 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
503
504 virtual void Output(CYOutput &out) const;
505 virtual void Output(CYOutput &out, CYFlags flags) const = 0;
506 void Output(CYOutput &out, int precedence, CYFlags flags) const;
507
508 virtual CYExpression *Replace(CYContext &context) = 0;
509
510 virtual CYExpression *Primitive(CYContext &context) {
511 return NULL;
512 }
513
514 virtual CYFunctionParameter *Parameter() const;
515
516 virtual CYNumber *Number(CYContext &context) {
517 return NULL;
518 }
519
520 virtual CYString *String(CYContext &context) {
521 return NULL;
522 }
523
524 virtual const char *Word() const {
525 return NULL;
526 }
527 };
528
529 struct CYTarget :
530 CYExpression,
531 CYForInInitializer
532 {
533 virtual bool RightHand() const {
534 return false;
535 }
536
537 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
538
539 virtual CYTarget *Replace(CYContext &context) = 0;
540 using CYExpression::Output;
541 };
542
543 #define CYAlphabetic(value) \
544 virtual bool Alphabetic() const { \
545 return value; \
546 }
547
548 #define CYPrecedence(value) \
549 static const int Precedence_ = value; \
550 virtual int Precedence() const { \
551 return Precedence_; \
552 }
553
554 struct CYCompound :
555 CYExpression
556 {
557 CYExpression *expression_;
558 CYExpression *next_;
559
560 CYCompound(CYExpression *expression, CYExpression *next) :
561 expression_(expression),
562 next_(next)
563 {
564 _assert(expression_ != NULL);
565 _assert(next != NULL);
566 }
567
568 CYPrecedence(17)
569
570 virtual CYExpression *Replace(CYContext &context);
571 void Output(CYOutput &out, CYFlags flags) const;
572
573 virtual CYFunctionParameter *Parameter() const;
574 };
575
576 struct CYParenthetical :
577 CYTarget
578 {
579 CYExpression *expression_;
580
581 CYParenthetical(CYExpression *expression) :
582 expression_(expression)
583 {
584 }
585
586 CYPrecedence(0)
587
588 virtual CYTarget *Replace(CYContext &context);
589 void Output(CYOutput &out, CYFlags flags) const;
590 };
591
592 struct CYBinding;
593
594 struct CYFunctionParameter :
595 CYNext<CYFunctionParameter>,
596 CYThing
597 {
598 CYBinding *binding_;
599
600 CYFunctionParameter(CYBinding *binding, CYFunctionParameter *next = NULL) :
601 CYNext<CYFunctionParameter>(next),
602 binding_(binding)
603 {
604 }
605
606 void Replace(CYContext &context, CYStatement *&statements);
607 void Output(CYOutput &out) const;
608 };
609
610 struct CYComprehension :
611 CYNext<CYComprehension>,
612 CYThing
613 {
614 CYComprehension(CYComprehension *next = NULL) :
615 CYNext<CYComprehension>(next)
616 {
617 }
618
619 virtual CYFunctionParameter *Parameter(CYContext &context) const = 0;
620 CYFunctionParameter *Parameters(CYContext &context) const;
621 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
622 virtual void Output(CYOutput &out) const = 0;
623 };
624
625 struct CYForInComprehension :
626 CYComprehension
627 {
628 CYBinding *binding_;
629 CYExpression *iterable_;
630
631 CYForInComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) :
632 CYComprehension(next),
633 binding_(binding),
634 iterable_(iterable)
635 {
636 }
637
638 virtual CYFunctionParameter *Parameter(CYContext &context) const;
639 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
640 virtual void Output(CYOutput &out) const;
641 };
642
643 struct CYForOfComprehension :
644 CYComprehension
645 {
646 CYBinding *binding_;
647 CYExpression *iterable_;
648
649 CYForOfComprehension(CYBinding *binding, CYExpression *iterable, CYComprehension *next = NULL) :
650 CYComprehension(next),
651 binding_(binding),
652 iterable_(iterable)
653 {
654 }
655
656 virtual CYFunctionParameter *Parameter(CYContext &context) const;
657 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
658 virtual void Output(CYOutput &out) const;
659 };
660
661 struct CYIfComprehension :
662 CYComprehension
663 {
664 CYExpression *test_;
665
666 CYIfComprehension(CYExpression *test, CYComprehension *next = NULL) :
667 CYComprehension(next),
668 test_(test)
669 {
670 }
671
672 virtual CYFunctionParameter *Parameter(CYContext &context) const;
673 virtual CYStatement *Replace(CYContext &context, CYStatement *statement) const;
674 virtual void Output(CYOutput &out) const;
675 };
676
677 struct CYArrayComprehension :
678 CYTarget
679 {
680 CYExpression *expression_;
681 CYComprehension *comprehensions_;
682
683 CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
684 expression_(expression),
685 comprehensions_(comprehensions)
686 {
687 }
688
689 CYPrecedence(0)
690
691 virtual CYTarget *Replace(CYContext &context);
692 virtual void Output(CYOutput &out, CYFlags flags) const;
693 };
694
695 struct CYLiteral :
696 CYTarget
697 {
698 CYLocation location_;
699
700 CYPrecedence(0)
701
702 virtual CYExpression *Primitive(CYContext &context) {
703 return this;
704 }
705 };
706
707 struct CYTrivial :
708 CYLiteral
709 {
710 virtual CYTarget *Replace(CYContext &context);
711 };
712
713 struct CYMagic :
714 CYTarget
715 {
716 CYPrecedence(0)
717 };
718
719 struct CYRange {
720 uint64_t lo_;
721 uint64_t hi_;
722
723 CYRange(uint64_t lo, uint64_t hi) :
724 lo_(lo), hi_(hi)
725 {
726 }
727
728 bool operator [](uint8_t value) const {
729 return !(value >> 7) && (value >> 6 ? hi_ : lo_) >> (value & 0x3f) & 0x1;
730 }
731
732 void operator()(uint8_t value) {
733 if (value >> 7)
734 return;
735 (value >> 6 ? hi_ : lo_) |= uint64_t(0x1) << (value & 0x3f);
736 }
737 };
738
739 extern CYRange DigitRange_;
740 extern CYRange WordStartRange_;
741 extern CYRange WordEndRange_;
742
743 struct CYString :
744 CYTrivial,
745 CYPropertyName
746 {
747 const char *value_;
748 size_t size_;
749
750 CYString() :
751 value_(NULL),
752 size_(0)
753 {
754 }
755
756 CYString(const char *value) :
757 value_(value),
758 size_(strlen(value))
759 {
760 }
761
762 CYString(const char *value, size_t size) :
763 value_(value),
764 size_(size)
765 {
766 }
767
768 CYString(const CYWord *word) :
769 value_(word->Word()),
770 size_(strlen(value_))
771 {
772 }
773
774 const char *Value() const {
775 return value_;
776 }
777
778 virtual const char *Word() const;
779
780 virtual CYNumber *Number(CYContext &context);
781 virtual CYString *String(CYContext &context);
782
783 CYString *Concat(CYContext &out, CYString *rhs) const;
784 virtual void Output(CYOutput &out, CYFlags flags) const;
785
786 virtual CYExpression *PropertyName(CYContext &context);
787 virtual void PropertyName(CYOutput &out) const;
788 };
789
790 struct CYElementValue;
791
792 struct CYSpan :
793 CYNext<CYSpan>
794 {
795 CYExpression *expression_;
796 CYString *string_;
797
798 CYSpan(CYExpression *expression, CYString *string, CYSpan *next) :
799 CYNext<CYSpan>(next),
800 expression_(expression),
801 string_(string)
802 {
803 }
804
805 CYElementValue *Replace(CYContext &context);
806 };
807
808 struct CYTemplate :
809 CYTarget
810 {
811 CYString *string_;
812 CYSpan *spans_;
813
814 CYTemplate(CYString *string, CYSpan *spans) :
815 string_(string),
816 spans_(spans)
817 {
818 }
819
820 CYPrecedence(0)
821
822 virtual CYTarget *Replace(CYContext &context);
823 virtual void Output(CYOutput &out, CYFlags flags) const;
824 };
825
826 struct CYNumber :
827 CYTrivial,
828 CYPropertyName
829 {
830 double value_;
831
832 CYNumber(double value) :
833 value_(value)
834 {
835 }
836
837 double Value() const {
838 return value_;
839 }
840
841 virtual CYNumber *Number(CYContext &context);
842 virtual CYString *String(CYContext &context);
843
844 virtual void Output(CYOutput &out, CYFlags flags) const;
845
846 virtual CYExpression *PropertyName(CYContext &context);
847 virtual void PropertyName(CYOutput &out) const;
848 };
849
850 struct CYComputed :
851 CYPropertyName
852 {
853 CYExpression *expression_;
854
855 CYComputed(CYExpression *expression) :
856 expression_(expression)
857 {
858 }
859
860 virtual bool Computed() const {
861 return true;
862 }
863
864 virtual CYExpression *PropertyName(CYContext &context);
865 virtual void PropertyName(CYOutput &out) const;
866 };
867
868 struct CYRegEx :
869 CYTrivial
870 {
871 const char *value_;
872 size_t size_;
873
874 CYRegEx(const char *value, size_t size) :
875 value_(value),
876 size_(size)
877 {
878 }
879
880 const char *Value() const {
881 return value_;
882 }
883
884 virtual void Output(CYOutput &out, CYFlags flags) const;
885 };
886
887 struct CYNull :
888 CYTrivial
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 CYMagic
898 {
899 virtual CYTarget *Replace(CYContext &context);
900 virtual void Output(CYOutput &out, CYFlags flags) const;
901 };
902
903 struct CYBoolean :
904 CYTrivial
905 {
906 CYPrecedence(4)
907
908 virtual bool RightHand() const {
909 return true;
910 }
911
912 virtual bool Value() const = 0;
913 virtual void Output(CYOutput &out, CYFlags flags) const;
914 };
915
916 struct CYFalse :
917 CYBoolean
918 {
919 virtual bool Value() const {
920 return false;
921 }
922
923 virtual CYNumber *Number(CYContext &context);
924 virtual CYString *String(CYContext &context);
925 };
926
927 struct CYTrue :
928 CYBoolean
929 {
930 virtual bool Value() const {
931 return true;
932 }
933
934 virtual CYNumber *Number(CYContext &context);
935 virtual CYString *String(CYContext &context);
936 };
937
938 struct CYVariable :
939 CYTarget
940 {
941 CYIdentifier *name_;
942
943 CYVariable(CYIdentifier *name) :
944 name_(name)
945 {
946 }
947
948 CYVariable(const char *name) :
949 name_(new($pool) CYIdentifier(name))
950 {
951 }
952
953 CYPrecedence(0)
954
955 virtual bool Eval() const {
956 return strcmp(name_->Word(), "eval") == 0;
957 }
958
959 virtual CYTarget *Replace(CYContext &context);
960 virtual void Output(CYOutput &out, CYFlags flags) const;
961
962 virtual CYFunctionParameter *Parameter() const;
963 };
964
965 struct CYPrefix :
966 CYExpression
967 {
968 CYExpression *rhs_;
969
970 CYPrefix(CYExpression *rhs) :
971 rhs_(rhs)
972 {
973 }
974
975 virtual bool Alphabetic() const = 0;
976 virtual const char *Operator() const = 0;
977
978 CYPrecedence(4)
979
980 virtual CYExpression *Replace(CYContext &context);
981 virtual void Output(CYOutput &out, CYFlags flags) const;
982 };
983
984 struct CYInfix :
985 CYExpression
986 {
987 CYExpression *lhs_;
988 CYExpression *rhs_;
989
990 CYInfix(CYExpression *lhs, CYExpression *rhs) :
991 lhs_(lhs),
992 rhs_(rhs)
993 {
994 }
995
996 void SetLeft(CYExpression *lhs) {
997 lhs_ = lhs;
998 }
999
1000 virtual bool Alphabetic() const = 0;
1001 virtual const char *Operator() const = 0;
1002
1003 virtual CYExpression *Replace(CYContext &context);
1004 virtual void Output(CYOutput &out, CYFlags flags) const;
1005 };
1006
1007 struct CYPostfix :
1008 CYExpression
1009 {
1010 CYExpression *lhs_;
1011
1012 CYPostfix(CYExpression *lhs) :
1013 lhs_(lhs)
1014 {
1015 }
1016
1017 virtual const char *Operator() const = 0;
1018
1019 CYPrecedence(3)
1020
1021 virtual CYExpression *Replace(CYContext &context);
1022 virtual void Output(CYOutput &out, CYFlags flags) const;
1023 };
1024
1025 struct CYAssignment :
1026 CYExpression
1027 {
1028 CYTarget *lhs_;
1029 CYExpression *rhs_;
1030
1031 CYAssignment(CYTarget *lhs, CYExpression *rhs) :
1032 lhs_(lhs),
1033 rhs_(rhs)
1034 {
1035 }
1036
1037 void SetRight(CYExpression *rhs) {
1038 rhs_ = rhs;
1039 }
1040
1041 virtual const char *Operator() const = 0;
1042
1043 CYPrecedence(16)
1044
1045 virtual CYExpression *Replace(CYContext &context);
1046 virtual void Output(CYOutput &out, CYFlags flags) const;
1047 };
1048
1049 struct CYArgument :
1050 CYNext<CYArgument>,
1051 CYThing
1052 {
1053 CYWord *name_;
1054 CYExpression *value_;
1055
1056 CYArgument(CYExpression *value, CYArgument *next = NULL) :
1057 CYNext<CYArgument>(next),
1058 name_(NULL),
1059 value_(value)
1060 {
1061 }
1062
1063 CYArgument(CYWord *name, CYExpression *value, CYArgument *next = NULL) :
1064 CYNext<CYArgument>(next),
1065 name_(name),
1066 value_(value)
1067 {
1068 }
1069
1070 CYArgument *Replace(CYContext &context);
1071 void Output(CYOutput &out) const;
1072 };
1073
1074 struct CYClause :
1075 CYThing,
1076 CYNext<CYClause>
1077 {
1078 CYExpression *value_;
1079 CYStatement *code_;
1080
1081 CYClause(CYExpression *value, CYStatement *code) :
1082 value_(value),
1083 code_(code)
1084 {
1085 }
1086
1087 void Replace(CYContext &context);
1088 virtual void Output(CYOutput &out) const;
1089 };
1090
1091 struct CYElement :
1092 CYThing
1093 {
1094 virtual bool Elision() const = 0;
1095
1096 virtual void Replace(CYContext &context) = 0;
1097 };
1098
1099 struct CYElementValue :
1100 CYNext<CYElement>,
1101 CYElement
1102 {
1103 CYExpression *value_;
1104
1105 CYElementValue(CYExpression *value, CYElement *next = NULL) :
1106 CYNext<CYElement>(next),
1107 value_(value)
1108 {
1109 }
1110
1111 virtual bool Elision() const {
1112 return value_ == NULL;
1113 }
1114
1115 virtual void Replace(CYContext &context);
1116 virtual void Output(CYOutput &out) const;
1117 };
1118
1119 struct CYElementSpread :
1120 CYElement
1121 {
1122 CYExpression *value_;
1123
1124 CYElementSpread(CYExpression *value) :
1125 value_(value)
1126 {
1127 }
1128
1129 virtual bool Elision() const {
1130 return false;
1131 }
1132
1133 virtual void Replace(CYContext &context);
1134 virtual void Output(CYOutput &out) const;
1135 };
1136
1137 struct CYArray :
1138 CYLiteral
1139 {
1140 CYElement *elements_;
1141
1142 CYArray(CYElement *elements = NULL) :
1143 elements_(elements)
1144 {
1145 }
1146
1147 virtual CYTarget *Replace(CYContext &context);
1148 virtual void Output(CYOutput &out, CYFlags flags) const;
1149 };
1150
1151 struct CYBinding {
1152 CYIdentifier *identifier_;
1153 CYExpression *initializer_;
1154
1155 CYBinding(CYIdentifier *identifier, CYExpression *initializer = NULL) :
1156 identifier_(identifier),
1157 initializer_(initializer)
1158 {
1159 }
1160
1161 CYTarget *Target(CYContext &context);
1162
1163 virtual CYAssignment *Replace(CYContext &context, CYIdentifierKind kind);
1164 virtual void Output(CYOutput &out, CYFlags flags) const;
1165 };
1166
1167 struct CYForLexical :
1168 CYForInInitializer
1169 {
1170 bool constant_;
1171 CYBinding *binding_;
1172
1173 CYForLexical(bool constant, CYBinding *binding) :
1174 constant_(constant),
1175 binding_(binding)
1176 {
1177 }
1178
1179 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
1180
1181 virtual CYTarget *Replace(CYContext &context);
1182 virtual void Output(CYOutput &out, CYFlags flags) const;
1183 };
1184
1185 struct CYForVariable :
1186 CYForInInitializer
1187 {
1188 CYBinding *binding_;
1189
1190 CYForVariable(CYBinding *binding) :
1191 binding_(binding)
1192 {
1193 }
1194
1195 virtual CYStatement *Initialize(CYContext &context, CYExpression *value);
1196
1197 virtual CYTarget *Replace(CYContext &context);
1198 virtual void Output(CYOutput &out, CYFlags flags) const;
1199 };
1200
1201 struct CYBindings :
1202 CYNext<CYBindings>,
1203 CYThing
1204 {
1205 CYBinding *binding_;
1206
1207 CYBindings(CYBinding *binding, CYBindings *next = NULL) :
1208 CYNext<CYBindings>(next),
1209 binding_(binding)
1210 {
1211 }
1212
1213 CYExpression *Replace(CYContext &context, CYIdentifierKind kind);
1214
1215 CYArgument *Argument(CYContext &context);
1216 CYFunctionParameter *Parameter(CYContext &context);
1217
1218 virtual void Output(CYOutput &out) const;
1219 virtual void Output(CYOutput &out, CYFlags flags) const;
1220 };
1221
1222 struct CYVar :
1223 CYForInitializer
1224 {
1225 CYBindings *bindings_;
1226
1227 CYVar(CYBindings *bindings) :
1228 bindings_(bindings)
1229 {
1230 }
1231
1232 CYCompact(None)
1233
1234 virtual CYForInitializer *Replace(CYContext &context);
1235 virtual void Output(CYOutput &out, CYFlags flags) const;
1236 };
1237
1238 struct CYLexical :
1239 CYForInitializer
1240 {
1241 bool constant_;
1242 CYBindings *bindings_;
1243
1244 CYLexical(bool constant, CYBindings *bindings) :
1245 constant_(constant),
1246 bindings_(bindings)
1247 {
1248 }
1249
1250 CYCompact(None)
1251
1252 virtual CYForInitializer *Replace(CYContext &context);
1253 virtual void Output(CYOutput &out, CYFlags flags) const;
1254 };
1255
1256 struct CYBuilder {
1257 CYList<CYBindings> bindings_;
1258 CYList<CYStatement> statements_;
1259
1260 operator bool() const {
1261 return statements_ != NULL;
1262 }
1263 };
1264
1265 struct CYProperty :
1266 CYNext<CYProperty>,
1267 CYThing
1268 {
1269 CYPropertyName *name_;
1270
1271 CYProperty(CYPropertyName *name, CYProperty *next = NULL) :
1272 CYNext<CYProperty>(next),
1273 name_(name)
1274 {
1275 }
1276
1277 virtual bool Update() const;
1278
1279 CYProperty *ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update);
1280 void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, bool protect);
1281
1282 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect) = 0;
1283
1284 virtual void Replace(CYContext &context) = 0;
1285 virtual void Output(CYOutput &out) const;
1286 };
1287
1288 struct CYPropertyValue :
1289 CYProperty
1290 {
1291 CYExpression *value_;
1292
1293 CYPropertyValue(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
1294 CYProperty(name, next),
1295 value_(value)
1296 {
1297 }
1298
1299 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1300 virtual void Replace(CYContext &context);
1301 virtual void Output(CYOutput &out) const;
1302 };
1303
1304 struct CYFor :
1305 CYStatement
1306 {
1307 CYForInitializer *initializer_;
1308 CYExpression *test_;
1309 CYExpression *increment_;
1310 CYStatement *code_;
1311
1312 CYFor(CYForInitializer *initializer, CYExpression *test, CYExpression *increment, CYStatement *code) :
1313 initializer_(initializer),
1314 test_(test),
1315 increment_(increment),
1316 code_(code)
1317 {
1318 }
1319
1320 CYCompact(Long)
1321
1322 virtual CYStatement *Replace(CYContext &context);
1323 virtual void Output(CYOutput &out, CYFlags flags) const;
1324 };
1325
1326 struct CYForIn :
1327 CYStatement
1328 {
1329 CYForInInitializer *initializer_;
1330 CYExpression *iterable_;
1331 CYStatement *code_;
1332
1333 CYForIn(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) :
1334 initializer_(initializer),
1335 iterable_(iterable),
1336 code_(code)
1337 {
1338 }
1339
1340 CYCompact(Long)
1341
1342 virtual CYStatement *Replace(CYContext &context);
1343 virtual void Output(CYOutput &out, CYFlags flags) const;
1344 };
1345
1346 struct CYForInitialized :
1347 CYStatement
1348 {
1349 CYBinding *binding_;
1350 CYExpression *iterable_;
1351 CYStatement *code_;
1352
1353 CYForInitialized(CYBinding *binding, CYExpression *iterable, CYStatement *code) :
1354 binding_(binding),
1355 iterable_(iterable),
1356 code_(code)
1357 {
1358 }
1359
1360 CYCompact(Long)
1361
1362 virtual CYStatement *Replace(CYContext &context);
1363 virtual void Output(CYOutput &out, CYFlags flags) const;
1364 };
1365
1366 struct CYForOf :
1367 CYStatement
1368 {
1369 CYForInInitializer *initializer_;
1370 CYExpression *iterable_;
1371 CYStatement *code_;
1372
1373 CYForOf(CYForInInitializer *initializer, CYExpression *iterable, CYStatement *code) :
1374 initializer_(initializer),
1375 iterable_(iterable),
1376 code_(code)
1377 {
1378 }
1379
1380 CYCompact(Long)
1381
1382 virtual CYStatement *Replace(CYContext &context);
1383 virtual void Output(CYOutput &out, CYFlags flags) const;
1384 };
1385
1386 struct CYObject :
1387 CYLiteral
1388 {
1389 CYProperty *properties_;
1390
1391 CYObject(CYProperty *properties = NULL) :
1392 properties_(properties)
1393 {
1394 }
1395
1396 virtual CYTarget *Replace(CYContext &context);
1397 void Output(CYOutput &out, CYFlags flags) const;
1398 };
1399
1400 struct CYMember :
1401 CYTarget
1402 {
1403 CYExpression *object_;
1404 CYExpression *property_;
1405
1406 CYMember(CYExpression *object, CYExpression *property) :
1407 object_(object),
1408 property_(property)
1409 {
1410 }
1411
1412 void SetLeft(CYExpression *object) {
1413 object_ = object;
1414 }
1415 };
1416
1417 struct CYDirectMember :
1418 CYMember
1419 {
1420 CYDirectMember(CYExpression *object, CYExpression *property) :
1421 CYMember(object, property)
1422 {
1423 }
1424
1425 CYPrecedence(1)
1426
1427 virtual CYTarget *Replace(CYContext &context);
1428 virtual void Output(CYOutput &out, CYFlags flags) const;
1429 };
1430
1431 struct CYIndirectMember :
1432 CYMember
1433 {
1434 CYIndirectMember(CYExpression *object, CYExpression *property) :
1435 CYMember(object, property)
1436 {
1437 }
1438
1439 CYPrecedence(1)
1440
1441 virtual CYTarget *Replace(CYContext &context);
1442 virtual void Output(CYOutput &out, CYFlags flags) const;
1443 };
1444
1445 namespace cy {
1446 namespace Syntax {
1447
1448 struct New :
1449 CYTarget
1450 {
1451 CYExpression *constructor_;
1452 CYArgument *arguments_;
1453
1454 New(CYExpression *constructor, CYArgument *arguments = NULL) :
1455 constructor_(constructor),
1456 arguments_(arguments)
1457 {
1458 }
1459
1460 virtual int Precedence() const {
1461 return arguments_ == NULL ? 2 : 1;
1462 }
1463
1464
1465 virtual CYTarget *Replace(CYContext &context);
1466 virtual void Output(CYOutput &out, CYFlags flags) const;
1467
1468 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1469 };
1470
1471 } }
1472
1473 struct CYApply :
1474 CYTarget
1475 {
1476 CYArgument *arguments_;
1477
1478 CYApply(CYArgument *arguments = NULL) :
1479 arguments_(arguments)
1480 {
1481 }
1482
1483 CYPrecedence(1)
1484
1485 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1486 };
1487
1488 struct CYCall :
1489 CYApply
1490 {
1491 CYExpression *function_;
1492
1493 CYCall(CYExpression *function, CYArgument *arguments = NULL) :
1494 CYApply(arguments),
1495 function_(function)
1496 {
1497 }
1498
1499 virtual void Output(CYOutput &out, CYFlags flags) const;
1500 virtual CYTarget *Replace(CYContext &context);
1501 };
1502
1503 struct CYEval :
1504 CYApply
1505 {
1506 CYEval(CYArgument *arguments) :
1507 CYApply(arguments)
1508 {
1509 }
1510
1511 virtual void Output(CYOutput &out, CYFlags flags) const;
1512 virtual CYTarget *Replace(CYContext &context);
1513 };
1514
1515 struct CYRubyProc;
1516
1517 struct CYRubyBlock :
1518 CYTarget
1519 {
1520 CYExpression *call_;
1521 CYRubyProc *proc_;
1522
1523 CYRubyBlock(CYExpression *call, CYRubyProc *proc) :
1524 call_(call),
1525 proc_(proc)
1526 {
1527 }
1528
1529 CYPrecedence(1)
1530
1531 virtual CYTarget *Replace(CYContext &context);
1532 virtual void Output(CYOutput &out, CYFlags flags) const;
1533
1534 virtual CYTarget *AddArgument(CYContext &context, CYExpression *value);
1535 };
1536
1537 struct CYIf :
1538 CYStatement
1539 {
1540 CYExpression *test_;
1541 CYStatement *true_;
1542 CYStatement *false_;
1543
1544 CYIf(CYExpression *test, CYStatement *_true, CYStatement *_false = NULL) :
1545 test_(test),
1546 true_(_true),
1547 false_(_false)
1548 {
1549 }
1550
1551 CYCompact(Long)
1552
1553 virtual CYStatement *Replace(CYContext &context);
1554 virtual void Output(CYOutput &out, CYFlags flags) const;
1555
1556 virtual CYStatement *Return();
1557 };
1558
1559 struct CYDoWhile :
1560 CYStatement
1561 {
1562 CYExpression *test_;
1563 CYStatement *code_;
1564
1565 CYDoWhile(CYExpression *test, CYStatement *code) :
1566 test_(test),
1567 code_(code)
1568 {
1569 }
1570
1571 CYCompact(None)
1572
1573 virtual CYStatement *Replace(CYContext &context);
1574 virtual void Output(CYOutput &out, CYFlags flags) const;
1575 };
1576
1577 struct CYWhile :
1578 CYStatement
1579 {
1580 CYExpression *test_;
1581 CYStatement *code_;
1582
1583 CYWhile(CYExpression *test, CYStatement *code) :
1584 test_(test),
1585 code_(code)
1586 {
1587 }
1588
1589 CYCompact(Long)
1590
1591 virtual CYStatement *Replace(CYContext &context);
1592 virtual void Output(CYOutput &out, CYFlags flags) const;
1593 };
1594
1595 struct CYFunction {
1596 CYFunctionParameter *parameters_;
1597 CYStatement *code_;
1598
1599 CYNonLocal *nonlocal_;
1600 bool implicit_;
1601 CYThisScope this_;
1602 CYIdentifier *super_;
1603
1604 CYFunction(CYFunctionParameter *parameters, CYStatement *code) :
1605 parameters_(parameters),
1606 code_(code),
1607 nonlocal_(NULL),
1608 implicit_(false),
1609 super_(NULL)
1610 {
1611 }
1612
1613 void Replace(CYContext &context);
1614 void Output(CYOutput &out) const;
1615 };
1616
1617 struct CYFunctionExpression :
1618 CYFunction,
1619 CYTarget
1620 {
1621 CYIdentifier *name_;
1622
1623 CYFunctionExpression(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *code) :
1624 CYFunction(parameters, code),
1625 name_(name)
1626 {
1627 }
1628
1629 CYPrecedence(0)
1630
1631 CYTarget *Replace(CYContext &context) override;
1632 virtual void Output(CYOutput &out, CYFlags flags) const;
1633 };
1634
1635 struct CYFatArrow :
1636 CYFunction,
1637 CYExpression
1638 {
1639 CYFatArrow(CYFunctionParameter *parameters, CYStatement *code) :
1640 CYFunction(parameters, code)
1641 {
1642 }
1643
1644 CYPrecedence(0)
1645
1646 CYExpression *Replace(CYContext &context) override;
1647 virtual void Output(CYOutput &out, CYFlags flags) const;
1648 };
1649
1650 struct CYRubyProc :
1651 CYFunction,
1652 CYTarget
1653 {
1654 CYRubyProc(CYFunctionParameter *parameters, CYStatement *code) :
1655 CYFunction(parameters, code)
1656 {
1657 }
1658
1659 CYPrecedence(0)
1660
1661 CYTarget *Replace(CYContext &context) override;
1662 virtual void Output(CYOutput &out, CYFlags flags) const;
1663 };
1664
1665 struct CYFunctionStatement :
1666 CYFunction,
1667 CYStatement
1668 {
1669 CYIdentifier *name_;
1670
1671 CYFunctionStatement(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *code) :
1672 CYFunction(parameters, code),
1673 name_(name)
1674 {
1675 }
1676
1677 CYCompact(None)
1678
1679 CYStatement *Replace(CYContext &context) override;
1680 virtual void Output(CYOutput &out, CYFlags flags) const;
1681 };
1682
1683 struct CYPropertyMethod;
1684
1685 struct CYMethod :
1686 CYFunction,
1687 CYProperty
1688 {
1689 CYMethod(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1690 CYFunction(parameters, code),
1691 CYProperty(name, next)
1692 {
1693 }
1694
1695 virtual CYFunctionExpression *Constructor();
1696
1697 using CYProperty::Replace;
1698 virtual void Replace(CYContext &context);
1699 };
1700
1701 struct CYPropertyGetter :
1702 CYMethod
1703 {
1704 CYPropertyGetter(CYPropertyName *name, CYStatement *code, CYProperty *next = NULL) :
1705 CYMethod(name, NULL, code, next)
1706 {
1707 }
1708
1709 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1710 virtual void Output(CYOutput &out) const;
1711 };
1712
1713 struct CYPropertySetter :
1714 CYMethod
1715 {
1716 CYPropertySetter(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1717 CYMethod(name, parameters, code, next)
1718 {
1719 }
1720
1721 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1722 virtual void Output(CYOutput &out) const;
1723 };
1724
1725 struct CYPropertyMethod :
1726 CYMethod
1727 {
1728 CYPropertyMethod(CYPropertyName *name, CYFunctionParameter *parameters, CYStatement *code, CYProperty *next = NULL) :
1729 CYMethod(name, parameters, code, next)
1730 {
1731 }
1732
1733 bool Update() const override;
1734
1735 virtual CYFunctionExpression *Constructor();
1736
1737 virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
1738 virtual void Output(CYOutput &out) const;
1739 };
1740
1741 struct CYClassTail :
1742 CYThing
1743 {
1744 CYExpression *extends_;
1745
1746 CYFunctionExpression *constructor_;
1747 CYList<CYProperty> instance_;
1748 CYList<CYProperty> static_;
1749
1750 CYClassTail(CYExpression *extends) :
1751 extends_(extends),
1752 constructor_(NULL)
1753 {
1754 }
1755
1756 void Output(CYOutput &out) const;
1757 };
1758
1759 struct CYClassExpression :
1760 CYTarget
1761 {
1762 CYIdentifier *name_;
1763 CYClassTail *tail_;
1764
1765 CYClassExpression(CYIdentifier *name, CYClassTail *tail) :
1766 name_(name),
1767 tail_(tail)
1768 {
1769 }
1770
1771 CYPrecedence(0)
1772
1773 CYTarget *Replace(CYContext &context) override;
1774 virtual void Output(CYOutput &out, CYFlags flags) const;
1775 };
1776
1777 struct CYClassStatement :
1778 CYStatement
1779 {
1780 CYIdentifier *name_;
1781 CYClassTail *tail_;
1782
1783 CYClassStatement(CYIdentifier *name, CYClassTail *tail) :
1784 name_(name),
1785 tail_(tail)
1786 {
1787 }
1788
1789 CYCompact(Long)
1790
1791 CYStatement *Replace(CYContext &context) override;
1792 virtual void Output(CYOutput &out, CYFlags flags) const;
1793 };
1794
1795 struct CYSuperCall :
1796 CYTarget
1797 {
1798 CYArgument *arguments_;
1799
1800 CYSuperCall(CYArgument *arguments) :
1801 arguments_(arguments)
1802 {
1803 }
1804
1805 CYPrecedence(2)
1806
1807 CYTarget *Replace(CYContext &context) override;
1808 virtual void Output(CYOutput &out, CYFlags flags) const;
1809 };
1810
1811 struct CYSuperAccess :
1812 CYTarget
1813 {
1814 CYExpression *property_;
1815
1816 CYSuperAccess(CYExpression *property) :
1817 property_(property)
1818 {
1819 }
1820
1821 CYPrecedence(1)
1822
1823 CYTarget *Replace(CYContext &context) override;
1824 virtual void Output(CYOutput &out, CYFlags flags) const;
1825 };
1826
1827 struct CYExpress :
1828 CYForInitializer
1829 {
1830 CYExpression *expression_;
1831
1832 CYExpress(CYExpression *expression) :
1833 expression_(expression)
1834 {
1835 if (expression_ == NULL)
1836 throw;
1837 }
1838
1839 CYCompact(None)
1840
1841 CYForInitializer *Replace(CYContext &context) override;
1842 virtual void Output(CYOutput &out, CYFlags flags) const;
1843
1844 virtual CYStatement *Return();
1845 };
1846
1847 struct CYContinue :
1848 CYStatement
1849 {
1850 CYIdentifier *label_;
1851
1852 CYContinue(CYIdentifier *label) :
1853 label_(label)
1854 {
1855 }
1856
1857 CYCompact(Short)
1858
1859 CYStatement *Replace(CYContext &context) override;
1860 virtual void Output(CYOutput &out, CYFlags flags) const;
1861 };
1862
1863 struct CYBreak :
1864 CYStatement
1865 {
1866 CYIdentifier *label_;
1867
1868 CYBreak(CYIdentifier *label) :
1869 label_(label)
1870 {
1871 }
1872
1873 CYCompact(Short)
1874
1875 CYStatement *Replace(CYContext &context) override;
1876 virtual void Output(CYOutput &out, CYFlags flags) const;
1877 };
1878
1879 struct CYReturn :
1880 CYStatement
1881 {
1882 CYExpression *value_;
1883
1884 CYReturn(CYExpression *value) :
1885 value_(value)
1886 {
1887 }
1888
1889 CYCompact(None)
1890
1891 CYStatement *Replace(CYContext &context) override;
1892 virtual void Output(CYOutput &out, CYFlags flags) const;
1893 };
1894
1895 struct CYYieldGenerator :
1896 CYExpression
1897 {
1898 CYExpression *value_;
1899
1900 CYYieldGenerator(CYExpression *value) :
1901 value_(value)
1902 {
1903 }
1904
1905 CYPrecedence(0)
1906
1907 CYExpression *Replace(CYContext &context) override;
1908 virtual void Output(CYOutput &out, CYFlags flags) const;
1909 };
1910
1911 struct CYYieldValue :
1912 CYExpression
1913 {
1914 CYExpression *value_;
1915
1916 CYYieldValue(CYExpression *value) :
1917 value_(value)
1918 {
1919 }
1920
1921 CYPrecedence(0)
1922
1923 virtual CYExpression *Replace(CYContext &context);
1924 virtual void Output(CYOutput &out, CYFlags flags) const;
1925 };
1926
1927 struct CYEmpty :
1928 CYForInitializer
1929 {
1930 CYCompact(Short)
1931
1932 virtual CYForInitializer *Replace(CYContext &context);
1933 virtual void Output(CYOutput &out, CYFlags flags) const;
1934 };
1935
1936 struct CYFinally :
1937 CYThing
1938 {
1939 CYStatement *code_;
1940
1941 CYFinally(CYStatement *code) :
1942 code_(code)
1943 {
1944 }
1945
1946 void Replace(CYContext &context);
1947 virtual void Output(CYOutput &out) const;
1948 };
1949
1950 struct CYTypeSpecifier :
1951 CYThing
1952 {
1953 virtual CYTarget *Replace(CYContext &context) = 0;
1954 };
1955
1956 struct CYTypeError :
1957 CYTypeSpecifier
1958 {
1959 CYTypeError() {
1960 }
1961
1962 virtual CYTarget *Replace(CYContext &context);
1963 virtual void Output(CYOutput &out) const;
1964 };
1965
1966 struct CYTypeVoid :
1967 CYTypeSpecifier
1968 {
1969 CYTypeVoid() {
1970 }
1971
1972 virtual CYTarget *Replace(CYContext &context);
1973 virtual void Output(CYOutput &out) const;
1974 };
1975
1976 struct CYTypeReference :
1977 CYTypeSpecifier
1978 {
1979 CYIdentifier *name_;
1980
1981 CYTypeReference(CYIdentifier *name) :
1982 name_(name)
1983 {
1984 }
1985
1986 virtual CYTarget *Replace(CYContext &context);
1987 virtual void Output(CYOutput &out) const;
1988 };
1989
1990 struct CYTypeVariable :
1991 CYTypeSpecifier
1992 {
1993 CYIdentifier *name_;
1994
1995 CYTypeVariable(CYIdentifier *name) :
1996 name_(name)
1997 {
1998 }
1999
2000 CYTypeVariable(const char *name) :
2001 name_(new($pool) CYIdentifier(name))
2002 {
2003 }
2004
2005 virtual CYTarget *Replace(CYContext &context);
2006 virtual void Output(CYOutput &out) const;
2007 };
2008
2009 struct CYTypeUnsigned :
2010 CYTypeSpecifier
2011 {
2012 CYTypeSpecifier *specifier_;
2013
2014 CYTypeUnsigned(CYTypeSpecifier *specifier) :
2015 specifier_(specifier)
2016 {
2017 }
2018
2019 virtual CYTarget *Replace(CYContext &context);
2020 virtual void Output(CYOutput &out) const;
2021 };
2022
2023 struct CYTypeSigned :
2024 CYTypeSpecifier
2025 {
2026 CYTypeSpecifier *specifier_;
2027
2028 CYTypeSigned(CYTypeSpecifier *specifier) :
2029 specifier_(specifier)
2030 {
2031 }
2032
2033 virtual CYTarget *Replace(CYContext &context);
2034 virtual void Output(CYOutput &out) const;
2035 };
2036
2037 struct CYTypeLong :
2038 CYTypeSpecifier
2039 {
2040 CYTypeSpecifier *specifier_;
2041
2042 CYTypeLong(CYTypeSpecifier *specifier) :
2043 specifier_(specifier)
2044 {
2045 }
2046
2047 virtual CYTarget *Replace(CYContext &context);
2048 virtual void Output(CYOutput &out) const;
2049 };
2050
2051 struct CYTypeShort :
2052 CYTypeSpecifier
2053 {
2054 CYTypeSpecifier *specifier_;
2055
2056 CYTypeShort(CYTypeSpecifier *specifier) :
2057 specifier_(specifier)
2058 {
2059 }
2060
2061 virtual CYTarget *Replace(CYContext &context);
2062 virtual void Output(CYOutput &out) const;
2063 };
2064
2065 struct CYTypeFunctionWith;
2066
2067 struct CYTypeModifier :
2068 CYNext<CYTypeModifier>
2069 {
2070 CYTypeModifier(CYTypeModifier *next) :
2071 CYNext<CYTypeModifier>(next)
2072 {
2073 }
2074
2075 virtual int Precedence() const = 0;
2076
2077 virtual CYTarget *Replace_(CYContext &context, CYTarget *type) = 0;
2078 CYTarget *Replace(CYContext &context, CYTarget *type);
2079
2080 virtual void Output(CYOutput &out, CYIdentifier *identifier) const = 0;
2081 void Output(CYOutput &out, int precedence, CYIdentifier *identifier) const;
2082
2083 virtual CYTypeFunctionWith *Function() { return NULL; }
2084 };
2085
2086 struct CYTypeArrayOf :
2087 CYTypeModifier
2088 {
2089 CYExpression *size_;
2090
2091 CYTypeArrayOf(CYExpression *size, CYTypeModifier *next = NULL) :
2092 CYTypeModifier(next),
2093 size_(size)
2094 {
2095 }
2096
2097 CYPrecedence(1)
2098
2099 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2100 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2101 };
2102
2103 struct CYTypeConstant :
2104 CYTypeModifier
2105 {
2106 CYTypeConstant(CYTypeModifier *next = NULL) :
2107 CYTypeModifier(next)
2108 {
2109 }
2110
2111 CYPrecedence(0)
2112
2113 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2114 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2115 };
2116
2117 struct CYTypePointerTo :
2118 CYTypeModifier
2119 {
2120 CYTypePointerTo(CYTypeModifier *next = NULL) :
2121 CYTypeModifier(next)
2122 {
2123 }
2124
2125 CYPrecedence(0)
2126
2127 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2128 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2129 };
2130
2131 struct CYTypeVolatile :
2132 CYTypeModifier
2133 {
2134 CYTypeVolatile(CYTypeModifier *next = NULL) :
2135 CYTypeModifier(next)
2136 {
2137 }
2138
2139 CYPrecedence(0)
2140
2141 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2142 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2143 };
2144
2145 struct CYTypedIdentifier :
2146 CYNext<CYTypedIdentifier>,
2147 CYThing
2148 {
2149 CYLocation location_;
2150 CYIdentifier *identifier_;
2151 CYTypeSpecifier *specifier_;
2152 CYTypeModifier *modifier_;
2153
2154 CYTypedIdentifier(const CYLocation &location, CYIdentifier *identifier = NULL) :
2155 location_(location),
2156 identifier_(identifier),
2157 specifier_(NULL),
2158 modifier_(NULL)
2159 {
2160 }
2161
2162 CYTypedIdentifier(CYTypeSpecifier *specifier, CYTypeModifier *modifier = NULL) :
2163 identifier_(NULL),
2164 specifier_(specifier),
2165 modifier_(modifier)
2166 {
2167 }
2168
2169 inline CYTypedIdentifier *Modify(CYTypeModifier *modifier) {
2170 CYSetLast(modifier_) = modifier;
2171 return this;
2172 }
2173
2174 virtual CYTarget *Replace(CYContext &context);
2175 virtual void Output(CYOutput &out) const;
2176
2177 CYTypeFunctionWith *Function();
2178 };
2179
2180 struct CYEncodedType :
2181 CYTarget
2182 {
2183 CYTypedIdentifier *typed_;
2184
2185 CYEncodedType(CYTypedIdentifier *typed) :
2186 typed_(typed)
2187 {
2188 }
2189
2190 CYPrecedence(1)
2191
2192 virtual CYTarget *Replace(CYContext &context);
2193 virtual void Output(CYOutput &out, CYFlags flags) const;
2194 };
2195
2196 struct CYTypedParameter :
2197 CYNext<CYTypedParameter>,
2198 CYThing
2199 {
2200 CYTypedIdentifier *typed_;
2201
2202 CYTypedParameter(CYTypedIdentifier *typed, CYTypedParameter *next) :
2203 CYNext<CYTypedParameter>(next),
2204 typed_(typed)
2205 {
2206 }
2207
2208 CYArgument *Argument(CYContext &context);
2209 CYFunctionParameter *Parameters(CYContext &context);
2210 CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
2211
2212 virtual void Output(CYOutput &out) const;
2213 };
2214
2215 struct CYLambda :
2216 CYTarget
2217 {
2218 CYTypedIdentifier *typed_;
2219 CYTypedParameter *parameters_;
2220 CYStatement *code_;
2221
2222 CYLambda(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *code) :
2223 typed_(typed),
2224 parameters_(parameters),
2225 code_(code)
2226 {
2227 }
2228
2229 CYPrecedence(1)
2230
2231 virtual CYTarget *Replace(CYContext &context);
2232 virtual void Output(CYOutput &out, CYFlags flags) const;
2233 };
2234
2235 struct CYModule :
2236 CYNext<CYModule>,
2237 CYThing
2238 {
2239 CYWord *part_;
2240
2241 CYModule(CYWord *part, CYModule *next = NULL) :
2242 CYNext<CYModule>(next),
2243 part_(part)
2244 {
2245 }
2246
2247 CYString *Replace(CYContext &context, const char *separator) const;
2248 void Output(CYOutput &out) const;
2249 };
2250
2251 struct CYImport :
2252 CYStatement
2253 {
2254 CYModule *module_;
2255
2256 CYImport(CYModule *module) :
2257 module_(module)
2258 {
2259 }
2260
2261 CYCompact(None)
2262
2263 virtual CYStatement *Replace(CYContext &context);
2264 virtual void Output(CYOutput &out, CYFlags flags) const;
2265 };
2266
2267 struct CYImportSpecifier :
2268 CYNext<CYImportSpecifier>
2269 {
2270 CYWord *name_;
2271 CYIdentifier *binding_;
2272
2273 CYImportSpecifier(CYWord *name, CYIdentifier *binding) :
2274 name_(name),
2275 binding_(binding)
2276 {
2277 }
2278
2279 CYStatement *Replace(CYContext &context, CYIdentifier *module);
2280 };
2281
2282 struct CYImportDeclaration :
2283 CYStatement
2284 {
2285 CYImportSpecifier *specifiers_;
2286 CYString *module_;
2287
2288 CYImportDeclaration(CYImportSpecifier *specifiers, CYString *module) :
2289 specifiers_(specifiers),
2290 module_(module)
2291 {
2292 }
2293
2294 CYCompact(None)
2295
2296 virtual CYStatement *Replace(CYContext &context);
2297 virtual void Output(CYOutput &out, CYFlags flags) const;
2298 };
2299
2300 struct CYExternal :
2301 CYStatement
2302 {
2303 CYString *abi_;
2304 CYTypedIdentifier *typed_;
2305
2306 CYExternal(CYString *abi, CYTypedIdentifier *typed) :
2307 abi_(abi),
2308 typed_(typed)
2309 {
2310 }
2311
2312 CYCompact(None)
2313
2314 virtual CYStatement *Replace(CYContext &context);
2315 virtual void Output(CYOutput &out, CYFlags flags) const;
2316 };
2317
2318 struct CYTypeExpression :
2319 CYTarget
2320 {
2321 CYTypedIdentifier *typed_;
2322
2323 CYTypeExpression(CYTypedIdentifier *typed) :
2324 typed_(typed)
2325 {
2326 }
2327
2328 CYPrecedence(0)
2329
2330 virtual CYTarget *Replace(CYContext &context);
2331 virtual void Output(CYOutput &out, CYFlags flags) const;
2332 };
2333
2334 struct CYTypeDefinition :
2335 CYStatement
2336 {
2337 CYTypedIdentifier *typed_;
2338
2339 CYTypeDefinition(CYTypedIdentifier *typed) :
2340 typed_(typed)
2341 {
2342 }
2343
2344 CYCompact(None)
2345
2346 virtual CYStatement *Replace(CYContext &context);
2347 virtual void Output(CYOutput &out, CYFlags flags) const;
2348 };
2349
2350 struct CYTypeBlockWith :
2351 CYTypeModifier
2352 {
2353 CYTypedParameter *parameters_;
2354
2355 CYTypeBlockWith(CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
2356 CYTypeModifier(next),
2357 parameters_(parameters)
2358 {
2359 }
2360
2361 CYPrecedence(0)
2362
2363 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2364 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2365 };
2366
2367 struct CYTypeFunctionWith :
2368 CYTypeModifier
2369 {
2370 CYTypedParameter *parameters_;
2371
2372 CYTypeFunctionWith(CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
2373 CYTypeModifier(next),
2374 parameters_(parameters)
2375 {
2376 }
2377
2378 CYPrecedence(1)
2379
2380 virtual CYTarget *Replace_(CYContext &context, CYTarget *type);
2381 virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
2382
2383 virtual CYTypeFunctionWith *Function() { return this; }
2384 };
2385
2386 struct CYTypeStructField :
2387 CYNext<CYTypeStructField>
2388 {
2389 CYTypedIdentifier *typed_;
2390
2391 CYTypeStructField(CYTypedIdentifier *typed, CYTypeStructField *next = NULL) :
2392 CYNext<CYTypeStructField>(next),
2393 typed_(typed)
2394 {
2395 }
2396 };
2397
2398 struct CYStructTail :
2399 CYThing
2400 {
2401 CYTypeStructField *fields_;
2402
2403 CYStructTail(CYTypeStructField *fields) :
2404 fields_(fields)
2405 {
2406 }
2407
2408 CYTarget *Replace(CYContext &context);
2409 virtual void Output(CYOutput &out) const;
2410 };
2411
2412 struct CYTypeStruct :
2413 CYTypeSpecifier
2414 {
2415 CYIdentifier *name_;
2416 CYStructTail *tail_;
2417
2418 CYTypeStruct(CYIdentifier *name, CYStructTail *tail) :
2419 name_(name),
2420 tail_(tail)
2421 {
2422 }
2423
2424 virtual CYTarget *Replace(CYContext &context);
2425 virtual void Output(CYOutput &out) const;
2426 };
2427
2428 struct CYStructDefinition :
2429 CYStatement
2430 {
2431 CYIdentifier *name_;
2432 CYStructTail *tail_;
2433
2434 CYStructDefinition(CYIdentifier *name, CYStructTail *tail) :
2435 name_(name),
2436 tail_(tail)
2437 {
2438 }
2439
2440 CYCompact(None)
2441
2442 virtual CYStatement *Replace(CYContext &context);
2443 virtual void Output(CYOutput &out, CYFlags flags) const;
2444 };
2445
2446 namespace cy {
2447 namespace Syntax {
2448
2449 struct Catch :
2450 CYThing
2451 {
2452 CYIdentifier *name_;
2453 CYStatement *code_;
2454
2455 Catch(CYIdentifier *name, CYStatement *code) :
2456 name_(name),
2457 code_(code)
2458 {
2459 }
2460
2461 void Replace(CYContext &context);
2462 virtual void Output(CYOutput &out) const;
2463 };
2464
2465 struct Try :
2466 CYStatement
2467 {
2468 CYStatement *code_;
2469 Catch *catch_;
2470 CYFinally *finally_;
2471
2472 Try(CYStatement *code, Catch *_catch, CYFinally *finally) :
2473 code_(code),
2474 catch_(_catch),
2475 finally_(finally)
2476 {
2477 }
2478
2479 CYCompact(Short)
2480
2481 virtual CYStatement *Replace(CYContext &context);
2482 virtual void Output(CYOutput &out, CYFlags flags) const;
2483 };
2484
2485 struct Throw :
2486 CYStatement
2487 {
2488 CYExpression *value_;
2489
2490 Throw(CYExpression *value = NULL) :
2491 value_(value)
2492 {
2493 }
2494
2495 CYCompact(None)
2496
2497 virtual CYStatement *Replace(CYContext &context);
2498 virtual void Output(CYOutput &out, CYFlags flags) const;
2499 };
2500
2501 } }
2502
2503 struct CYWith :
2504 CYStatement
2505 {
2506 CYExpression *scope_;
2507 CYStatement *code_;
2508
2509 CYWith(CYExpression *scope, CYStatement *code) :
2510 scope_(scope),
2511 code_(code)
2512 {
2513 }
2514
2515 CYCompact(Long)
2516
2517 virtual CYStatement *Replace(CYContext &context);
2518 virtual void Output(CYOutput &out, CYFlags flags) const;
2519 };
2520
2521 struct CYSwitch :
2522 CYStatement
2523 {
2524 CYExpression *value_;
2525 CYClause *clauses_;
2526
2527 CYSwitch(CYExpression *value, CYClause *clauses) :
2528 value_(value),
2529 clauses_(clauses)
2530 {
2531 }
2532
2533 CYCompact(Long)
2534
2535 virtual CYStatement *Replace(CYContext &context);
2536 virtual void Output(CYOutput &out, CYFlags flags) const;
2537 };
2538
2539 struct CYDebugger :
2540 CYStatement
2541 {
2542 CYDebugger()
2543 {
2544 }
2545
2546 CYCompact(None)
2547
2548 virtual CYStatement *Replace(CYContext &context);
2549 virtual void Output(CYOutput &out, CYFlags flags) const;
2550 };
2551
2552 struct CYCondition :
2553 CYExpression
2554 {
2555 CYExpression *test_;
2556 CYExpression *true_;
2557 CYExpression *false_;
2558
2559 CYCondition(CYExpression *test, CYExpression *_true, CYExpression *_false) :
2560 test_(test),
2561 true_(_true),
2562 false_(_false)
2563 {
2564 }
2565
2566 CYPrecedence(15)
2567
2568 virtual CYExpression *Replace(CYContext &context);
2569 virtual void Output(CYOutput &out, CYFlags flags) const;
2570 };
2571
2572 struct CYAddressOf :
2573 CYPrefix
2574 {
2575 CYAddressOf(CYExpression *rhs) :
2576 CYPrefix(rhs)
2577 {
2578 }
2579
2580 virtual const char *Operator() const {
2581 return "&";
2582 }
2583
2584 CYAlphabetic(false)
2585
2586 virtual CYExpression *Replace(CYContext &context);
2587 };
2588
2589 struct CYIndirect :
2590 CYTarget
2591 {
2592 CYExpression *rhs_;
2593
2594 CYIndirect(CYExpression *rhs) :
2595 rhs_(rhs)
2596 {
2597 }
2598
2599 // XXX: this should be checked
2600 CYPrecedence(2)
2601
2602 virtual CYTarget *Replace(CYContext &context);
2603 virtual void Output(CYOutput &out, CYFlags flags) const;
2604 };
2605
2606 #define CYReplace \
2607 virtual CYExpression *Replace(CYContext &context);
2608
2609 #define CYPostfix_(op, name, args...) \
2610 struct CY ## name : \
2611 CYPostfix \
2612 { args \
2613 CY ## name(CYExpression *lhs) : \
2614 CYPostfix(lhs) \
2615 { \
2616 } \
2617 \
2618 virtual const char *Operator() const { \
2619 return op; \
2620 } \
2621 };
2622
2623 #define CYPrefix_(alphabetic, op, name, args...) \
2624 struct CY ## name : \
2625 CYPrefix \
2626 { args \
2627 CY ## name(CYExpression *rhs) : \
2628 CYPrefix(rhs) \
2629 { \
2630 } \
2631 \
2632 CYAlphabetic(alphabetic) \
2633 \
2634 virtual const char *Operator() const { \
2635 return op; \
2636 } \
2637 };
2638
2639 #define CYInfix_(alphabetic, precedence, op, name, args...) \
2640 struct CY ## name : \
2641 CYInfix \
2642 { args \
2643 CY ## name(CYExpression *lhs, CYExpression *rhs) : \
2644 CYInfix(lhs, rhs) \
2645 { \
2646 } \
2647 \
2648 CYAlphabetic(alphabetic) \
2649 CYPrecedence(precedence) \
2650 \
2651 virtual const char *Operator() const { \
2652 return op; \
2653 } \
2654 };
2655
2656 #define CYAssignment_(op, name, args...) \
2657 struct CY ## name ## Assign : \
2658 CYAssignment \
2659 { args \
2660 CY ## name ## Assign(CYTarget *lhs, CYExpression *rhs) : \
2661 CYAssignment(lhs, rhs) \
2662 { \
2663 } \
2664 \
2665 virtual const char *Operator() const { \
2666 return op; \
2667 } \
2668 };
2669
2670 CYPostfix_("++", PostIncrement)
2671 CYPostfix_("--", PostDecrement)
2672
2673 CYPrefix_(true, "delete", Delete)
2674 CYPrefix_(true, "void", Void)
2675 CYPrefix_(true, "typeof", TypeOf)
2676 CYPrefix_(false, "++", PreIncrement)
2677 CYPrefix_(false, "--", PreDecrement)
2678 CYPrefix_(false, "+", Affirm)
2679 CYPrefix_(false, "-", Negate)
2680 CYPrefix_(false, "~", BitwiseNot)
2681 CYPrefix_(false, "!", LogicalNot)
2682
2683 CYInfix_(false, 5, "*", Multiply, CYReplace)
2684 CYInfix_(false, 5, "/", Divide)
2685 CYInfix_(false, 5, "%", Modulus)
2686 CYInfix_(false, 6, "+", Add, CYReplace)
2687 CYInfix_(false, 6, "-", Subtract)
2688 CYInfix_(false, 7, "<<", ShiftLeft)
2689 CYInfix_(false, 7, ">>", ShiftRightSigned)
2690 CYInfix_(false, 7, ">>>", ShiftRightUnsigned)
2691 CYInfix_(false, 8, "<", Less)
2692 CYInfix_(false, 8, ">", Greater)
2693 CYInfix_(false, 8, "<=", LessOrEqual)
2694 CYInfix_(false, 8, ">=", GreaterOrEqual)
2695 CYInfix_(true, 8, "instanceof", InstanceOf)
2696 CYInfix_(true, 8, "in", In)
2697 CYInfix_(false, 9, "==", Equal)
2698 CYInfix_(false, 9, "!=", NotEqual)
2699 CYInfix_(false, 9, "===", Identical)
2700 CYInfix_(false, 9, "!==", NotIdentical)
2701 CYInfix_(false, 10, "&", BitwiseAnd)
2702 CYInfix_(false, 11, "^", BitwiseXOr)
2703 CYInfix_(false, 12, "|", BitwiseOr)
2704 CYInfix_(false, 13, "&&", LogicalAnd)
2705 CYInfix_(false, 14, "||", LogicalOr)
2706
2707 CYAssignment_("=", )
2708 CYAssignment_("*=", Multiply)
2709 CYAssignment_("/=", Divide)
2710 CYAssignment_("%=", Modulus)
2711 CYAssignment_("+=", Add)
2712 CYAssignment_("-=", Subtract)
2713 CYAssignment_("<<=", ShiftLeft)
2714 CYAssignment_(">>=", ShiftRightSigned)
2715 CYAssignment_(">>>=", ShiftRightUnsigned)
2716 CYAssignment_("&=", BitwiseAnd)
2717 CYAssignment_("^=", BitwiseXOr)
2718 CYAssignment_("|=", BitwiseOr)
2719
2720 #endif/*CYCRIPT_PARSER_HPP*/