CYProperty *property_;
CYPropertyName *propertyName_;
CYRubyProc *rubyProc_;
+ CYTypeSpecifier *specifier_;
CYStatement *statement_;
CYString *string_;
CYThis *this_;
@begin E4X ObjectiveC
%token At "@"
-%token Pound "#"
@end
%token Ampersand "&"
@begin C
%token <identifier_> Typedef "typedef"
+%token <identifier_> Unsigned "unsigned"
+%token <identifier_> Signed "signed"
@end
@begin ObjectiveC
%type <expression_> FunctionExpression
%type <identifier_> Identifier
%type <identifier_> IdentifierOpt
+%type <identifier_> IdentifierType
%type <word_> IdentifierName
%type <statement_> IfStatement
%type <expression_> Initialiser
%type <protocol_> ClassProtocolsOpt
%type <expression_> EncodedType
%type <modifier_> FunctionedType
+%type <specifier_> IntegerType
+%type <specifier_> IntegerTypeOpt
%type <expression_> MessageExpression
%type <messageParameter_> MessageParameter
%type <messageParameter_> MessageParameters
%type <typedIdentifier_> ModifiedType
%type <module_> Module
%type <typedIdentifier_> PrefixedType
-%type <expression_> PrimitiveType
+%type <specifier_> PrimitiveType
%type <argument_> SelectorCall_
%type <argument_> SelectorCall
%type <selector_> SelectorExpression_
| { $$ = NULL; }
;
-Identifier
+IdentifierType
: Identifier_ { $$ = $1; }
-@begin C
- | "typedef" { $$ = $1; }
- | "YES" { $$ = $1; }
- | "NO" { $$ = $1; }
-@end
-
| "implements" { $$ = $1; }
| "interface" { $$ = $1; }
| "package" { $$ = $1; }
| "abstract" { $$ = $1; }
| "boolean" { $$ = $1; }
| "byte" { $$ = $1; }
- | "char" { $$ = $1; }
| "double" { $$ = $1; }
| "final" { $$ = $1; }
| "float" { $$ = $1; }
| "goto" { $$ = $1; }
- | "int" { $$ = $1; }
- | "long" { $$ = $1; }
| "native" { $$ = $1; }
- | "short" { $$ = $1; }
| "synchronized" { $$ = $1; }
| "throws" { $$ = $1; }
| "transient" { $$ = $1; }
- | "volatile" { $$ = $1; }
// XXX: currently I only have this as Word
// | "let" { $$ = $1; }
| "of" { $$ = $1; }
;
+Identifier
+ : IdentifierType
+ | "char" { $$ = $1; }
+ | "int" { $$ = $1; }
+ | "long" { $$ = $1; }
+ | "short" { $$ = $1; }
+ | "volatile" { $$ = $1; }
+@begin C
+ | "typedef" { $$ = $1; }
+ | "unsigned" { $$ = $1; }
+ | "signed" { $$ = $1; }
+ | "YES" { $$ = $1; }
+ | "NO" { $$ = $1; }
+@end
+ ;
+
IdentifierOpt
: Identifier { $$ = $1; }
| { $$ = NULL; }
ConditionalExpression
: LogicalORExpression { $$ = $1; }
| LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
+ | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
;
/* }}} */
/* 11.13 Assignment Operators {{{ */
/* 11.14 Comma Operator {{{ */
Expression_
: "," Expression { $$ = $2; }
- | { $$ = CYNew CYCompound(); }
+ | { $$ = NULL; }
;
Expression
- : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
+ : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
;
ExpressionOpt
;
TypeSignifier
- : Identifier { $$ = CYNew CYTypedIdentifier($1); }
+ : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
| TypeParenthetical { $$ = $1; }
;
;
TypeQualifierLeft
- : "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
- /* XXX: | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); } */
- | { $$ = NULL; }
+ : { $$ = NULL; }
+ | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
+ | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
;
TypeQualifierRight
- : "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
- | PrefixedType { $$ = $1; }
+ : PrefixedType { $$ = $1; }
| SuffixedType { $$ = $1; }
+ | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
+ | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
+ ;
+
+IntegerType
+ : "int" { $$ = CYNew CYTypeVariable("int"); }
+ | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
+ | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
+ | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
+ | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
+ ;
+
+IntegerTypeOpt
+ : IntegerType { $$ = $1; }
+ | { $$ = CYNew CYTypeVariable("int"); }
;
PrimitiveType
- : Variable { $$ = $1; }
- | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
+ : IdentifierType { $$ = CYNew CYTypeVariable($1); }
+ | IntegerType { $$ = $1; }
+ | "void" { $$ = CYNew CYTypeVoid(); }
+ | "char" { $$ = CYNew CYTypeVariable("char"); }
+ | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
+ | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
;
TypedIdentifier
- : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->type_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
+ : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
;
EncodedType
;
PrimaryExpression
- : AtEncode "(" EncodedType ")" { $$ = $3; }
+ : "@encode" "(" EncodedType ")" { $$ = $3; }
;
/* }}} */
/* Cycript (Objective-C): @class Declaration {{{ */
;
ClassFieldListOpt
- : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
+ : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
| LexSetRegExp { $$ = NULL; }
;
/* }}} */
/* Cycript (Objective-C): Block Expressions {{{ */
ModifiedType
- : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->type_ = $2; $$->modifier_ = $1; }
+ : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
| ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
;
: "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
;
/* }}} */
+/* Cycript (Objective-C): Instance Literals {{{ */
+PrimaryExpression
+ : "^" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
+ ;
+/* }}} */
@end
@begin C