~CYDriver();
};
+enum CYFlags {
+ CYNoFlags = 0,
+ CYNoBrace = (1 << 0),
+ CYNoFunction = (1 << 1),
+ CYNoLeader = (1 << 2),
+ CYNoTrailer = (1 << 3),
+ CYNoIn = (1 << 4),
+ CYNoHyphen = (1 << 5),
+ CYNoBF = (CYNoBrace | CYNoFunction),
+};
+
struct CYPart {
- virtual void Part(std::ostream &out) const = 0;
+ virtual void Part(std::ostream &out, CYFlags flags) const = 0;
};
struct CYForInitialiser :
struct CYForInInitialiser :
CYPart
{
-};
-
-enum CYFlags {
- CYNoFlags = 0,
- CYNoBrace = (1 << 0),
- CYNoFunction = (1 << 1),
- CYNoLeader = (1 << 2),
- CYNoTrailer = (1 << 3),
- CYNoIn = (1 << 4),
- CYNoHyphen = (1 << 5),
- CYNoBF = (CYNoBrace | CYNoFunction),
+ virtual const char *ForEachIn() const = 0;
+ virtual void ForEachIn(std::ostream &out) const = 0;
};
struct CYExpression :
CYClassName
{
virtual unsigned Precedence() const = 0;
- virtual void Part(std::ostream &out) const;
+ virtual void Part(std::ostream &out, CYFlags flags) const;
+
+ virtual const char *ForEachIn() const {
+ return NULL;
+ }
+
+ virtual void ForEachIn(std::ostream &out) const;
+
virtual void Output(std::ostream &out, CYFlags flags) const = 0;
void Output(std::ostream &out, unsigned precedence, CYFlags flags) const;
void Output(std::ostream &out, CYFlags flags) const;
};
+struct CYComprehension :
+ CYNext<CYComprehension>
+{
+ void Output(std::ostream &out) const;
+ virtual const char *Name() const = 0;
+
+ virtual void Begin_(std::ostream &out) const = 0;
+
+ virtual void End_(std::ostream &out) const {
+ }
+};
+
+struct CYForInComprehension :
+ CYComprehension
+{
+ CYIdentifier *name_;
+ CYExpression *set_;
+
+ CYForInComprehension(CYIdentifier *name, CYExpression *set) :
+ name_(name),
+ set_(set)
+ {
+ }
+
+ virtual const char *Name() const {
+ return name_->Value();
+ }
+
+ virtual void Begin_(std::ostream &out) const;
+};
+
+struct CYForEachInComprehension :
+ CYComprehension
+{
+ CYIdentifier *name_;
+ CYExpression *set_;
+
+ CYForEachInComprehension(CYIdentifier *name, CYExpression *set) :
+ name_(name),
+ set_(set)
+ {
+ }
+
+ virtual const char *Name() const {
+ return name_->Value();
+ }
+
+ virtual void Begin_(std::ostream &out) const;
+ virtual void End_(std::ostream &out) const;
+};
+
+struct CYIfComprehension :
+ CYComprehension
+{
+ CYExpression *test_;
+
+ CYIfComprehension(CYExpression *test) :
+ test_(test)
+ {
+ }
+
+ virtual const char *Name() const {
+ return NULL;
+ }
+
+ virtual void Begin_(std::ostream &out) const;
+};
+
+struct CYArrayComprehension :
+ CYExpression
+{
+ CYExpression *expression_;
+ CYComprehension *comprehensions_;
+
+ CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
+ expression_(expression),
+ comprehensions_(comprehensions)
+ {
+ }
+
+ CYPrecedence(0)
+
+ virtual void Output(std::ostream &out, CYFlags flags) const;
+};
+
struct CYLiteral :
CYExpression
{
};
struct CYDeclaration :
- CYThing,
CYForInInitialiser
{
CYIdentifier *identifier_;
{
}
- virtual void Part(std::ostream &out) const;
- virtual void Output(std::ostream &out) const;
+ virtual void Part(std::ostream &out, CYFlags flags) const;
+
+ virtual const char *ForEachIn() const {
+ return identifier_->Value();
+ }
+
+ virtual void ForEachIn(std::ostream &out) const;
+
+ virtual void Output(std::ostream &out, CYFlags flags) const;
};
struct CYDeclarations :
{
}
- virtual void Part(std::ostream &out) const;
+ virtual void Part(std::ostream &out, CYFlags flags) const;
virtual void Output(std::ostream &out) const;
};
virtual void Output(std::ostream &out) const;
};
+struct CYForEachIn :
+ CYStatement
+{
+ CYForInInitialiser *initialiser_;
+ CYExpression *set_;
+ CYStatement *code_;
+
+ CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
+ initialiser_(initialiser),
+ set_(set),
+ code_(code)
+ {
+ }
+
+ virtual void Output(std::ostream &out) const;
+};
+
struct CYProperty :
CYNext<CYProperty>
{