"@class" L C F(tk::AtClass, hi::Meta);
@end
+@begin C
+"typedef" L C I(identifier, Identifier("typedef"), tk::Typedef, hi::Meta);
+@end
+
@begin ObjectiveC
"@encode" L C F(tk::AtEncode, hi::Meta);
"@end" L C F(tk::AtEnd, hi::Meta);
%token AtClass "@class"
@end
+@begin C
+%token <identifier_> Typedef "typedef"
+@end
+
@begin ObjectiveC
%token AtImplementation "@implementation"
%token AtImplementation_ ";@implementation"
Identifier
: Identifier_ { $$ = $1; }
+@begin C
+ | "typedef" { $$ = $1; }
+@end
+
| "implements" { $$ = $1; }
| "interface" { $$ = $1; }
| "package" { $$ = $1; }
: "[" LexPushInOff LexSetRegExp "=" "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" ModifiedType BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($13, $9, $16); }
;
/* }}} */
+/* Cycript (C): Type Definitions {{{ */
+Statement__
+ : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
+ ;
+/* }}} */
@end
/* YUI: Documentation Comments {{{ */
statement_->Single(out, CYRight(flags));
}
+void CYTypedIdentifier::Output(CYOutput &out) const {
+ // XXX: this is clearly wrong
+ out << "XXX";
+}
+
void CYLambda::Output(CYOutput &out, CYFlags flags) const {
// XXX: this is seriously wrong
out << "[](";
out << "}";
}
+void CYTypeDefinition::Output(CYOutput &out, CYFlags flags) const {
+ out << "typedef" << *typed_;
+}
+
void CYLetStatement::Output(CYOutput &out, CYFlags flags) const {
out << "let" << ' ' << '(' << *declarations_ << ')';
code_->Single(out, CYRight(flags));
};
struct CYTypedIdentifier :
- CYNext<CYTypedIdentifier>
+ CYNext<CYTypedIdentifier>,
+ CYThing
{
CYIdentifier *identifier_;
CYTypeModifier *type_;
type_(NULL)
{
}
+
+ virtual void Output(CYOutput &out) const;
};
struct CYTypedParameter :
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 {
return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("constant")));
}
+CYStatement *CYTypeDefinition::Replace(CYContext &context) {
+ return $E($ CYAssign($V(typed_->identifier_), typed_->type_->Replace(context)));
+}
+
CYExpression *CYTypePointerTo::Replace(CYContext &context) {
return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("pointerTo")));
}