#include <iostream>
-#include <stack>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
-#include "location.hh"
-
#include "List.hpp"
#include "Pooling.hpp"
#include "Options.hpp"
virtual void Output(CYOutput &out, CYFlags flags) const;
};
-enum CYState {
- CYClear,
- CYRestricted,
- CYNewLine
-};
-
class CYStream :
public std::istream
{
}
};
-class CYDriver {
- public:
- void *scanner_;
-
- CYState state_;
- std::stack<bool> in_;
-
- struct {
- bool AtImplementation;
- bool Function;
- bool OpenBrace;
- } no_;
-
- std::istream &data_;
-
- bool strict_;
- bool commented_;
-
- enum Condition {
- RegExpCondition,
- XMLContentCondition,
- XMLTagCondition,
- };
-
- std::string filename_;
-
- struct Error {
- bool warning_;
- cy::location location_;
- std::string message_;
- };
-
- typedef std::vector<Error> Errors;
-
- CYProgram *program_;
- Errors errors_;
-
- bool auto_;
-
- struct Context {
- CYExpression *context_;
-
- Context(CYExpression *context) :
- context_(context)
- {
- }
-
- typedef std::vector<CYWord *> Words;
- Words words_;
- };
-
- typedef std::vector<Context> Contexts;
- Contexts contexts_;
-
- CYExpression *context_;
-
- enum Mode {
- AutoNone,
- AutoPrimary,
- AutoDirect,
- AutoIndirect,
- AutoMessage
- } mode_;
-
- private:
- void ScannerInit();
- void ScannerDestroy();
-
- public:
- CYDriver(std::istream &data, const std::string &filename = "");
- ~CYDriver();
-
- Condition GetCondition();
- void SetCondition(Condition condition);
-
- void PushCondition(Condition condition);
- void PopCondition();
-
- void Warning(const cy::location &location, const char *message);
-};
-
struct CYForInitialiser {
virtual ~CYForInitialiser() {
}
virtual void Output(CYOutput &out) const;
};
+struct CYTypeModifier :
+ CYNext<CYTypeModifier>
+{
+ CYTypeModifier(CYTypeModifier *next) :
+ CYNext<CYTypeModifier>(next)
+ {
+ }
+
+ virtual CYExpression *Replace(CYContext &context) = 0;
+};
+
+struct CYTypeArrayOf :
+ CYTypeModifier
+{
+ CYExpression *size_;
+
+ CYTypeArrayOf(CYExpression *size, CYTypeModifier *next = NULL) :
+ CYTypeModifier(next),
+ size_(size)
+ {
+ }
+
+ CYPrecedence(2)
+
+ virtual CYExpression *Replace(CYContext &context);
+};
+
+struct CYTypeConstant :
+ CYTypeModifier
+{
+ CYTypeConstant(CYTypeModifier *next = NULL) :
+ CYTypeModifier(next)
+ {
+ }
+
+ CYPrecedence(3)
+
+ virtual CYExpression *Replace(CYContext &context);
+};
+
+struct CYTypePointerTo :
+ CYTypeModifier
+{
+ CYTypePointerTo(CYTypeModifier *next = NULL) :
+ CYTypeModifier(next)
+ {
+ }
+
+ CYPrecedence(3)
+
+ virtual CYExpression *Replace(CYContext &context);
+};
+
+struct CYTypeVariable :
+ CYTypeModifier
+{
+ CYExpression *expression_;
+
+ CYTypeVariable(CYExpression *expression) :
+ CYTypeModifier(NULL),
+ expression_(expression)
+ {
+ }
+
+ CYPrecedence(1)
+
+ virtual CYExpression *Replace(CYContext &context);
+};
+
+struct CYTypedIdentifier :
+ CYNext<CYTypedIdentifier>,
+ CYThing
+{
+ CYIdentifier *identifier_;
+ CYTypeModifier *type_;
+
+ CYTypedIdentifier(CYIdentifier *identifier) :
+ identifier_(identifier),
+ type_(NULL)
+ {
+ }
+
+ virtual void Output(CYOutput &out) const;
+};
+
+struct CYTypedParameter :
+ CYNext<CYTypedParameter>
+{
+ CYTypedIdentifier *typed_;
+
+ CYTypedParameter(CYTypedIdentifier *typed, CYTypedParameter *next) :
+ CYNext<CYTypedParameter>(next),
+ typed_(typed)
+ {
+ }
+
+ CYFunctionParameter *Parameters(CYContext &context);
+ CYExpression *TypeSignature(CYContext &context, CYExpression *prefix);
+};
+
+struct CYLambda :
+ CYExpression
+{
+ CYTypeModifier *type_;
+ CYTypedParameter *parameters_;
+ CYStatement *statements_;
+
+ CYLambda(CYTypeModifier *type, CYTypedParameter *parameters, CYStatement *statements) :
+ type_(type),
+ parameters_(parameters),
+ statements_(statements)
+ {
+ }
+
+ CYPrecedence(1)
+
+ virtual CYExpression *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYTypeDefinition :
+ CYStatement
+{
+ CYTypedIdentifier *typed_;
+
+ CYTypeDefinition(CYTypedIdentifier *typed) :
+ typed_(typed)
+ {
+ }
+
+ virtual CYStatement *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
namespace cy {
namespace Syntax {