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