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