X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/57d557146c1aa8f72348d62ce461080ba5b2b5d2..58afc6aaca119c6b7b9ac5d91e3c6ee28dbd6fda:/Cycript.yy.in?ds=sidebyside diff --git a/Cycript.yy.in b/Cycript.yy.in index 3ad89f8..9cf3b8e 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -19,15 +19,12 @@ **/ /* }}} */ -@if Bison23 %{ - -@if Bison24 %code top { +%code top { #define cyscanner driver.scanner_ #define YYSTACKEXPANDABLE 1 -@if Bison23 #define yyerrok (yyerrstatus_ = 0) -@if Bison24 } +} -@if Bison24 %code requires { +%code requires { #include "Driver.hpp" #include "Parser.hpp" #define CYNew new($pool) @@ -110,23 +107,15 @@ typedef struct { } YYSTYPE; #define YYSTYPE YYSTYPE +} -@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 %} +%code provides { +int cylex(YYSTYPE *, CYLocation *, void *); +} -%name-prefix="cy" +%name-prefix "cy" -@if Bison23 %skeleton "lalr1.cc" -@if Bison24 %language "C++" +%language "C++" %initial-action { @$.begin.filename = @$.end.filename = &driver.filename_; @@ -135,6 +124,8 @@ int cylex(YYSTYPE *, cy::location *, void *); %locations %defines +%define api.location.type { CYLocation } + //%glr-parser //%expect 1 @@ -245,6 +236,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %token Typedef "typedef" %token Unsigned "unsigned" %token Signed "signed" +%token Extern "extern" @end @begin C @@ -443,7 +435,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %type NullLiteral %type ObjectLiteral %type Parenthetical -%type ParentheticalOpt +//%type ParentheticalOpt %type PostfixExpression %type PrimaryExpression %type Program @@ -586,16 +578,16 @@ LexSetRegExp ; LexNoBrace - : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; } + : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); } ; LexNoFunction - : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; } + : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); } ; LexNoAtImplementation : @begin ObjectiveC - { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; } + { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); } @end ; @@ -718,6 +710,7 @@ Identifier | "typedef" { $$ = $1; } | "unsigned" { $$ = $1; } | "signed" { $$ = $1; } + | "extern" { $$ = $1; } @end @begin ObjectiveC | "YES" { $$ = $1; } @@ -758,12 +751,12 @@ BooleanLiteral /* 7.9 Automatic Semicolon Insertion {{{ */ StrictSemi - : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } + : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); } ; Terminator : ";" - | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi + | error { if (yyla.type_get() != yyeof_ && yyla.type != token::CloseBrace && !yyla.value.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi ; TerminatorOpt @@ -777,10 +770,10 @@ Parenthetical : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; } ; -ParentheticalOpt +/*ParentheticalOpt : Parenthetical { $$ = $1; } | { $$ = NULL; } - ; + ;*/ Variable : Identifier { $$ = CYNew CYVariable($1); } @@ -1434,6 +1427,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; } ; @@ -1730,9 +1724,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 {{{ */