CYForInitialiser,
CYForInInitialiser
{
+ virtual unsigned Precedence() const = 0;
virtual void Part(std::ostream &out) const;
virtual void Output(std::ostream &out) const = 0;
- void Output(std::ostream &out, bool raw) const;
+ void Output(std::ostream &out, unsigned precedence) const;
};
-_finline std::ostream &operator <<(std::ostream &out, const CYExpression &rhs) {
- rhs.Output(out, false);
- return out;
-}
+#define CYPrecedence(value) \
+ virtual unsigned Precedence() const { \
+ return value; \
+ }
+
+struct CYCompound :
+ CYExpression
+{
+ CYExpression *expressions_;
+
+ CYCompound(CYExpression *expressions) :
+ expressions_(expressions)
+ {
+ }
+
+ void AddPrev(CYExpression *expression) {
+ CYExpression *last(expression);
+ while (last->next_ != NULL)
+ last = last->next_;
+ last->SetNext(expressions_);
+ expressions_ = expression;
+ }
+
+ CYPrecedence(17)
+
+ void Output(std::ostream &out) const;
+};
struct CYLiteral :
CYExpression
{
+ CYPrecedence(0)
};
struct CYSelectorPart :
{
}
+ CYPrecedence(0)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(0)
+
virtual void Output(std::ostream &out) const;
};
};
struct CYAssignment :
- CYInfix
+ CYExpression
{
+ CYExpression *lhs_;
+ CYExpression *rhs_;
+
CYAssignment(CYExpression *lhs, CYExpression *rhs) :
- CYInfix(lhs, rhs)
+ lhs_(lhs),
+ rhs_(rhs)
{
}
virtual const char *Operator() const = 0;
+
+ virtual void Output(std::ostream &out) const;
};
struct CYArgument :
{
}
- void Output(std::ostream &out, bool send) const;
+ void Output(std::ostream &out) const;
};
struct CYBlank :
{
}
+ CYPrecedence(0)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(1)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(1)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(2)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(0)
+
virtual void Output(std::ostream &out) const;
};
{
}
+ CYPrecedence(15)
+
virtual void Output(std::ostream &out) const;
};
return "&";
}
+ CYPrecedence(2)
+
virtual void Output(std::ostream &out) const;
};
return "*";
}
+ CYPrecedence(1)
+
virtual void Output(std::ostream &out) const;
};
CYPostfix(lhs) \
{ \
} \
+ \
+ CYPrecedence(3) \
\
virtual const char *Operator() const { \
return op; \
CYPrefix(rhs) \
{ \
} \
+ \
+ CYPrecedence(4) \
\
virtual const char *Operator() const { \
return op; \
} \
};
-#define CYInfix_(op, name) \
+#define CYInfix_(precedence, op, name) \
struct CY ## name : \
CYInfix \
{ \
CYInfix(lhs, rhs) \
{ \
} \
+ \
+ CYPrecedence(precedence) \
\
virtual const char *Operator() const { \
return op; \
CYAssignment(lhs, rhs) \
{ \
} \
+ \
+ CYPrecedence(16) \
\
virtual const char *Operator() const { \
return op; \
CYPrefix_("~", BitwiseNot)
CYPrefix_("!", LogicalNot)
-CYInfix_("*", Multiply)
-CYInfix_("/", Divide)
-CYInfix_("%", Modulus)
-CYInfix_("+", Add)
-CYInfix_("-", Subtract)
-CYInfix_("<<", ShiftLeft)
-CYInfix_(">>", ShiftRightSigned)
-CYInfix_(">>>", ShiftRightUnsigned)
-CYInfix_("<", Less)
-CYInfix_(">", Greater)
-CYInfix_("<=", LessOrEqual)
-CYInfix_(">=", GreaterOrEqual)
-CYInfix_("instanceof", InstanceOf)
-CYInfix_("in", In)
-CYInfix_("==", Equal)
-CYInfix_("!=", NotEqual)
-CYInfix_("===", Identical)
-CYInfix_("!==", NotIdentical)
-CYInfix_("&", BitwiseAnd)
-CYInfix_("^", BitwiseXOr)
-CYInfix_("|", BitwiseOr)
-CYInfix_("&&", LogicalAnd)
-CYInfix_("||", LogicalOr)
+CYInfix_(5, "*", Multiply)
+CYInfix_(5, "/", Divide)
+CYInfix_(5, "%", Modulus)
+CYInfix_(6, "+", Add)
+CYInfix_(6, "-", Subtract)
+CYInfix_(7, "<<", ShiftLeft)
+CYInfix_(7, ">>", ShiftRightSigned)
+CYInfix_(7, ">>>", ShiftRightUnsigned)
+CYInfix_(8, "<", Less)
+CYInfix_(8, ">", Greater)
+CYInfix_(8, "<=", LessOrEqual)
+CYInfix_(8, ">=", GreaterOrEqual)
+CYInfix_(8, "instanceof", InstanceOf)
+CYInfix_(8, "in", In)
+CYInfix_(9, "==", Equal)
+CYInfix_(9, "!=", NotEqual)
+CYInfix_(9, "===", Identical)
+CYInfix_(9, "!==", NotIdentical)
+CYInfix_(10, "&", BitwiseAnd)
+CYInfix_(11, "^", BitwiseXOr)
+CYInfix_(12, "|", BitwiseOr)
+CYInfix_(13, "&&", LogicalAnd)
+CYInfix_(14, "||", LogicalOr)
CYAssignment_("=", )
CYAssignment_("*=", Multiply)