X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/a7d8b4130acfb550e437d8cf1f6d3d81cb0cf6ee..63db22e50caddb75792b67534547cb3ac7ccff61:/Parser.hpp diff --git a/Parser.hpp b/Parser.hpp index 2d78a47..02b08eb 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -272,22 +272,6 @@ struct CYIdentifier : CYIdentifier *Replace(CYContext &context); }; -struct CYComment : - CYStatement -{ - const char *value_; - - CYComment(const char *value) : - value_(value) - { - } - - CYCompact(None) - - virtual CYStatement *Replace(CYContext &context); - virtual void Output(CYOutput &out, CYFlags flags) const; -}; - struct CYLabel : CYStatement { @@ -813,6 +797,43 @@ struct CYString : virtual void PropertyName(CYOutput &out) const; }; +struct CYElementValue; + +struct CYSpan : + CYNext +{ + CYExpression *expression_; + CYString *string_; + + CYSpan(CYExpression *expression, CYString *string, CYSpan *next) : + CYNext(next), + expression_(expression), + string_(string) + { + } + + CYElementValue *Replace(CYContext &context); +}; + +struct CYTemplate : + CYExpression +{ + CYString *string_; + CYSpan *spans_; + + CYTemplate(CYString *string, CYSpan *spans) : + string_(string), + spans_(spans) + { + } + + CYPrecedence(0) + CYRightHand(false) + + virtual CYExpression *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + struct CYNumber : CYTrivial, CYPropertyName @@ -839,9 +860,11 @@ struct CYRegEx : CYTrivial { const char *value_; + size_t size_; - CYRegEx(const char *value) : - value_(value) + CYRegEx(const char *value, size_t size) : + value_(value), + size_(size) { } @@ -1048,19 +1071,49 @@ struct CYClause : }; struct CYElement : - CYNext, CYThing +{ + virtual bool Elision() const = 0; + + virtual void Replace(CYContext &context) = 0; +}; + +struct CYElementValue : + CYNext, + CYElement { CYExpression *value_; - CYElement(CYExpression *value, CYElement *next) : + CYElementValue(CYExpression *value, CYElement *next) : CYNext(next), value_(value) { } - void Replace(CYContext &context); - void Output(CYOutput &out) const; + virtual bool Elision() const { + return value_ == NULL; + } + + virtual void Replace(CYContext &context); + virtual void Output(CYOutput &out) const; +}; + +struct CYElementSpread : + CYElement +{ + CYExpression *value_; + + CYElementSpread(CYExpression *value) : + value_(value) + { + } + + virtual bool Elision() const { + return false; + } + + virtual void Replace(CYContext &context); + virtual void Output(CYOutput &out) const; }; struct CYArray : @@ -1596,6 +1649,38 @@ struct CYReturn : virtual void Output(CYOutput &out, CYFlags flags) const; }; +struct CYYieldGenerator : + CYExpression +{ + CYExpression *value_; + + CYYieldGenerator(CYExpression *value) : + value_(value) + { + } + + CYPrecedence(0) + + virtual CYExpression *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + +struct CYYieldValue : + CYExpression +{ + CYExpression *value_; + + CYYieldValue(CYExpression *value) : + value_(value) + { + } + + CYPrecedence(0) + + virtual CYExpression *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + struct CYEmpty : CYStatement {