bool pretty_;
unsigned indent_;
+ enum {
+ NoMode,
+ NoLetter,
+ NoHyphen,
+ Terminated
+ } mode_;
+
CYOutput(std::ostream &out) :
out_(out),
pretty_(false),
- indent_(0)
+ indent_(0),
+ mode_(NoMode)
{
}
- _finline CYOutput &operator <<(char rhs) {
- out_ << rhs;
- return *this;
- }
+ void Check(char value);
- _finline CYOutput &operator <<(const char *rhs) {
- out_ << rhs;
+ CYOutput &operator <<(char rhs);
+ CYOutput &operator <<(const char *rhs);
+
+ _finline CYOutput &operator <<(const CYThing *rhs) {
+ if (rhs != NULL)
+ rhs->Output(*this);
return *this;
}
}
void Indent();
+ void Space();
};
struct CYPropertyName {
CYNoFlags = 0,
CYNoBrace = (1 << 0),
CYNoFunction = (1 << 1),
- CYNoLeader = (1 << 2),
- CYNoTrailer = (1 << 3),
- CYNoIn = (1 << 4),
- CYNoHyphen = (1 << 5),
- CYNoCall = (1 << 6),
- CYNoRightHand = (1 << 7),
- CYNoDangle = (1 << 8),
- CYNoTerminator = (1 << 9),
+ CYNoIn = (1 << 2),
+ CYNoCall = (1 << 3),
+ CYNoRightHand = (1 << 4),
+ CYNoDangle = (1 << 5),
CYNoBF = (CYNoBrace | CYNoFunction),
};
CYNext<CYExpression>,
CYForInitialiser,
CYForInInitialiser,
- CYClassName
+ CYClassName,
+ CYThing
{
virtual unsigned Precedence() const = 0;
virtual const char *ForEachIn() const;
virtual void ForEachIn(CYOutput &out) const;
+ virtual void Output(CYOutput &out) const;
virtual void Output(CYOutput &out, CYFlags flags) const = 0;
void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
};
struct CYComprehension :
- CYNext<CYComprehension>
+ CYNext<CYComprehension>,
+ CYThing
{
void Output(CYOutput &out) const;
virtual const char *Name() const = 0;
};
struct CYSelectorPart :
- CYNext<CYSelectorPart>
+ CYNext<CYSelectorPart>,
+ CYThing
{
CYWord *name_;
bool value_;
};
struct CYArgument :
- CYNext<CYArgument>
+ CYNext<CYArgument>,
+ CYThing
{
CYWord *name_;
CYExpression *value_;
};
struct CYElement :
- CYNext<CYElement>
+ CYNext<CYElement>,
+ CYThing
{
CYExpression *value_;
struct CYDeclarations :
CYNext<CYDeclarations>,
- CYForInitialiser
+ CYForInitialiser,
+ CYThing
{
CYDeclaration *declaration_;
}
virtual void For(CYOutput &out) const;
+
+ virtual void Output(CYOutput &out) const;
virtual void Output(CYOutput &out, CYFlags flags) const;
};
};
struct CYProperty :
- CYNext<CYProperty>
+ CYNext<CYProperty>,
+ CYThing
{
CYPropertyName *name_;
CYExpression *value_;
virtual void Output(CYOutput &out, CYFlags flags) const;
};
-struct CYFinally {
+struct CYFinally :
+ CYThing
+{
CYStatement *code_;
CYFinally(CYStatement *code) :