X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/f95d2598051e347460e028286ff2d33e5825e548..79492f212da2fcaa4ce44d00fc08530e1630d05b:/Cycript.yy.in diff --git a/Cycript.yy.in b/Cycript.yy.in index f761c26..b2f5629 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -110,12 +110,17 @@ typedef struct { } YYSTYPE; #define YYSTYPE YYSTYPE -@if Bison24 } @if Bison24 %code provides { int cylex(YYSTYPE *, cy::location *, void *); @if Bison24 } +@if Bison23 %} +@if Bison23 %union { +@if Bison23 } +@if Bison23 %{ + +@if Bison24 } @if Bison23 %} %name-prefix="cy" @@ -240,6 +245,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %token Typedef "typedef" %token Unsigned "unsigned" %token Signed "signed" +%token Extern "extern" @end @begin C @@ -481,7 +487,6 @@ int cylex(YYSTYPE *, cy::location *, void *); @begin C %type ArrayedType -%type EncodedType %type FunctionedType %type IntegerType %type IntegerTypeOpt @@ -527,7 +532,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %type SelectorExpressionOpt %type SelectorList %type SelectorWordOpt -%type TypeOpt +%type TypeOpt %type VariadicCall @end @@ -714,6 +719,7 @@ Identifier | "typedef" { $$ = $1; } | "unsigned" { $$ = $1; } | "signed" { $$ = $1; } + | "extern" { $$ = $1; } @end @begin ObjectiveC | "YES" { $$ = $1; } @@ -1430,6 +1436,7 @@ SuffixedType : ArrayedType { $$ = $1; } | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); } | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; } + | IdentifierType FunctionedType { $$ = CYNew CYTypedIdentifier($1); CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; } | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; } ; @@ -1476,12 +1483,8 @@ TypedIdentifier : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; } ; -EncodedType - : TypedIdentifier { $$ = CYNew CYEncodedType($1); } - ; - PrimaryExpression - : "@encode" "(" EncodedType ")" { $$ = $3; } + : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); } ; /* }}} */ @end @@ -1509,7 +1512,7 @@ MessageScope ; TypeOpt - : "(" LexSetRegExp EncodedType ")" { $$ = $3; } + : "(" LexSetRegExp TypedIdentifier ")" { $$ = $3; } | { $$ = NULL; } ; @@ -1730,9 +1733,15 @@ PrimaryExpression /* }}} */ /* Cycript (C): Type Definitions {{{ */ Statement__ - : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); } + : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) YYABORT; } Terminator { $$ = CYNew CYTypeDefinition($2); } ; /* }}} */ +/* Cycript (C): extern "C" {{{ */ +Statement__ + : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) YYABORT; } TypedIdentifier Terminator { $$ = CYNew CYExternal($2, $4); } + ; +/* }}} */ + @end /* YUI: Documentation Comments {{{ */