CYClassName,
CYThing
{
- virtual unsigned Precedence() const = 0;
+ virtual int Precedence() const = 0;
virtual bool RightHand() const {
return true;
virtual void Output(CYOutput &out) const;
virtual void Output(CYOutput &out, CYFlags flags) const = 0;
- void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
+ void Output(CYOutput &out, int precedence, CYFlags flags) const;
virtual CYExpression *ClassName(CYContext &context, bool object);
virtual void ClassName(CYOutput &out, bool object) const;
}
#define CYPrecedence(value) \
- static const unsigned Precedence_ = value; \
- virtual unsigned Precedence() const { \
+ static const int Precedence_ = value; \
+ virtual int Precedence() const { \
return Precedence_; \
}
{
}
- virtual unsigned Precedence() const {
+ virtual int Precedence() const {
return arguments_ == NULL ? 2 : 1;
}
{
}
- virtual CYExpression *Replace(CYContext &context) = 0;
+ virtual int Precedence() const = 0;
+
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type) = 0;
+ CYExpression *Replace(CYContext &context, CYExpression *type);
+
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const = 0;
+ void Output(CYOutput &out, int precedence, CYIdentifier *identifier) const;
};
struct CYTypeArrayOf :
{
}
- CYPrecedence(2)
+ CYPrecedence(1)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
};
struct CYTypeConstant :
{
}
- CYPrecedence(3)
+ CYPrecedence(0)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
};
struct CYTypePointerTo :
{
}
- CYPrecedence(3)
+ CYPrecedence(0)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
};
-struct CYTypeVariable :
+struct CYTypeVolatile :
CYTypeModifier
{
- CYExpression *expression_;
-
- CYTypeVariable(CYExpression *expression) :
- CYTypeModifier(NULL),
- expression_(expression)
+ CYTypeVolatile(CYTypeModifier *next = NULL) :
+ CYTypeModifier(next)
{
}
- CYPrecedence(1)
+ CYPrecedence(0)
- virtual CYExpression *Replace(CYContext &context);
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
};
struct CYTypedIdentifier :
CYThing
{
CYIdentifier *identifier_;
- CYTypeModifier *type_;
+ CYExpression *type_;
+ CYTypeModifier *modifier_;
- CYTypedIdentifier(CYIdentifier *identifier) :
+ CYTypedIdentifier(CYIdentifier *identifier = NULL) :
identifier_(identifier),
- type_(NULL)
+ type_(NULL),
+ modifier_(NULL)
{
}
+ CYTypedIdentifier(CYExpression *type, CYTypeModifier *modifier = NULL) :
+ identifier_(NULL),
+ type_(type),
+ modifier_(modifier)
+ {
+ }
+
+ inline CYTypedIdentifier *Modify(CYTypeModifier *modifier) {
+ CYSetLast(modifier_) = modifier;
+ return this;
+ }
+
+ virtual CYExpression *Replace(CYContext &context);
virtual void Output(CYOutput &out) const;
};
+struct CYEncodedType :
+ CYExpression
+{
+ CYTypedIdentifier *typed_;
+
+ CYEncodedType(CYTypedIdentifier *typed) :
+ typed_(typed)
+ {
+ }
+
+ CYPrecedence(1)
+
+ virtual CYExpression *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
struct CYTypedParameter :
- CYNext<CYTypedParameter>
+ CYNext<CYTypedParameter>,
+ CYThing
{
CYTypedIdentifier *typed_;
{
}
+ CYArgument *Argument(CYContext &context);
CYFunctionParameter *Parameters(CYContext &context);
CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
+
+ virtual void Output(CYOutput &out) const;
};
struct CYLambda :
CYExpression
{
- CYTypeModifier *type_;
+ CYTypedIdentifier *typed_;
CYTypedParameter *parameters_;
CYStatement *statements_;
- CYLambda(CYTypeModifier *type, CYTypedParameter *parameters, CYStatement *statements) :
- type_(type),
+ CYLambda(CYTypedIdentifier *typed, CYTypedParameter *parameters, CYStatement *statements) :
+ typed_(typed),
parameters_(parameters),
statements_(statements)
{
virtual void Output(CYOutput &out, CYFlags flags) const;
};
+struct CYTypeBlockWith :
+ CYTypeModifier
+{
+ CYTypedParameter *parameters_;
+
+ CYTypeBlockWith(CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
+ CYTypeModifier(next),
+ parameters_(parameters)
+ {
+ }
+
+ CYPrecedence(0)
+
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
+};
+
+struct CYTypeFunctionWith :
+ CYTypeModifier
+{
+ CYTypedParameter *parameters_;
+
+ CYTypeFunctionWith(CYTypedParameter *parameters, CYTypeModifier *next = NULL) :
+ CYTypeModifier(next),
+ parameters_(parameters)
+ {
+ }
+
+ CYPrecedence(1)
+
+ virtual CYExpression *Replace_(CYContext &context, CYExpression *type);
+ virtual void Output(CYOutput &out, CYIdentifier *identifier) const;
+};
+
namespace cy {
namespace Syntax {