X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/3fe283c53edc2a98d0164d893a4a667245da8e78..fa3c5be836cc074bdc12ba66298764a1da026e48:/Cycript.yy.in diff --git a/Cycript.yy.in b/Cycript.yy.in index c8a1862..0f16b6e 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -79,13 +79,19 @@ typedef struct { CYProperty *property_; CYPropertyName *propertyName_; CYRubyProc *rubyProc_; - CYTypeSpecifier *specifier_; CYStatement *statement_; CYString *string_; CYThis *this_; CYTrue *true_; CYWord *word_; +@begin C + CYTypeModifier *modifier_; + CYTypeSpecifier *specifier_; + CYTypedIdentifier *typedIdentifier_; + CYTypedParameter *typedParameter_; +@end + @begin ObjectiveC CYClassName *className_; CYField *field_; @@ -93,9 +99,6 @@ typedef struct { CYMessageParameter *messageParameter_; CYProtocol *protocol_; CYSelectorPart *selector_; - CYTypeModifier *modifier_; - CYTypedIdentifier *typedIdentifier_; - CYTypedParameter *typedParameter_; @end @begin E4X @@ -426,6 +429,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %type MemberAccess %type MemberExpression_ %type MemberExpression +%type Module %type MultiplicativeExpression %type NewExpression %type NullLiteral @@ -472,8 +476,26 @@ int cylex(YYSTYPE *, cy::location *, void *); %type WordOpt %type Variable -@begin ObjectiveC +@begin C %type ArrayedType +%type EncodedType +%type FunctionedType +%type IntegerType +%type IntegerTypeOpt +%type PrefixedType +%type PrimitiveType +%type TypeParenthetical +%type TypeSignifier +%type SuffixedType +%type TypeQualifierLeft +%type TypeQualifierRight +%type TypedIdentifier +%type TypedParameterList_ +%type TypedParameterList +%type TypedParameterListOpt +@end + +@begin ObjectiveC %type BoxableExpression %type CategoryStatement %type ClassExpression @@ -488,10 +510,6 @@ int cylex(YYSTYPE *, cy::location *, void *); %type ClassProtocolListOpt %type ClassProtocols %type ClassProtocolsOpt -%type EncodedType -%type FunctionedType -%type IntegerType -%type IntegerTypeOpt %type MessageExpression %type MessageParameter %type MessageParameters @@ -499,9 +517,6 @@ int cylex(YYSTYPE *, cy::location *, void *); %type MessageParameterListOpt %type MessageScope %type ModifiedType -%type Module -%type PrefixedType -%type PrimitiveType %type SelectorCall_ %type SelectorCall %type SelectorExpression_ @@ -509,16 +524,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %type SelectorExpressionOpt %type SelectorList %type SelectorWordOpt -%type SuffixedType %type TypeOpt -%type TypeParenthetical -%type TypeQualifierLeft -%type TypeQualifierRight -%type TypeSignifier -%type TypedIdentifier -%type TypedParameterList_ -%type TypedParameterList -%type TypedParameterListOpt %type VariadicCall @end @@ -705,6 +711,8 @@ Identifier | "typedef" { $$ = $1; } | "unsigned" { $$ = $1; } | "signed" { $$ = $1; } +@end +@begin ObjectiveC | "YES" { $$ = $1; } | "NO" { $$ = $1; } @end @@ -1054,11 +1062,11 @@ AssignmentExpression /* 11.14 Comma Operator {{{ */ Expression_ : "," Expression { $$ = $2; } - | { $$ = CYNew CYCompound(); } + | { $$ = NULL; } ; Expression - : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; } + : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); } ; ExpressionOpt @@ -1394,8 +1402,8 @@ ProgramBodyOpt ; /* }}} */ -@begin ObjectiveC -/* Cycript (Objective-C): Type Encoding {{{ */ +@begin C +/* Cycript (C): Type Encoding {{{ */ TypeParenthetical : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; } ; @@ -1449,7 +1457,7 @@ IntegerType IntegerTypeOpt : IntegerType { $$ = $1; } - | + | { $$ = CYNew CYTypeVariable("int"); } ; PrimitiveType @@ -1470,9 +1478,12 @@ EncodedType ; PrimaryExpression - : AtEncode "(" EncodedType ")" { $$ = $3; } + : "@encode" "(" EncodedType ")" { $$ = $3; } ; /* }}} */ +@end + +@begin ObjectiveC /* Cycript (Objective-C): @class Declaration {{{ */ ClassSuperOpt /* XXX: why the hell did I choose MemberExpression? */ @@ -1481,7 +1492,7 @@ ClassSuperOpt ; ClassFieldListOpt - : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); } + : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); } | LexSetRegExp { $$ = NULL; } ; @@ -1626,7 +1637,9 @@ PrimaryExpression | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); } ; /* }}} */ -/* Cycript (Objective-C): @import Directive {{{ */ +@end + +/* Cycript: @import Directive {{{ */ Module : Module "." Word { $$ = CYNew CYModule($3, $1); } | Word { $$ = CYNew CYModule($1); } @@ -1636,6 +1649,8 @@ Declaration__ : "@import" Module { $$ = CYNew CYImport($2); } ; /* }}} */ + +@begin ObjectiveC /* Cycript (Objective-C): Boxed Expressions {{{ */ BoxableExpression : NullLiteral { $$ = $1; }