/* Cycript - Optimizing JavaScript Compiler/Runtime
* Copyright (C) 2009-2010 Jay Freeman (saurik)
*/
/* GNU Lesser General Public License, Version 3 {{{ */
/*
* Cycript is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Cycript is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Cycript. If not, see .
**/
/* }}} */
@if Bison23 %{
@if Bison24 %code top {
#define cyscanner driver.scanner_
#define YYSTACKEXPANDABLE 1
@if Bison23 #define yyerrok (yyerrstatus_ = 0)
@if Bison24 }
@if Bison24 %code requires {
#include "Parser.hpp"
#define CYNew new($pool)
@begin ObjectiveC
#include "ObjectiveC/Syntax.hpp"
@end
@begin E4X
#include "E4X/Syntax.hpp"
@end
typedef struct {
bool newline_;
union {
bool bool_;
CYDriver::Condition condition_;
CYArgument *argument_;
CYAssignment *assignment_;
CYBoolean *boolean_;
CYClause *clause_;
cy::Syntax::Catch *catch_;
CYComment *comment_;
CYComprehension *comprehension_;
CYCompound *compound_;
CYDeclaration *declaration_;
CYDeclarations *declarations_;
CYElement *element_;
CYExpression *expression_;
CYFalse *false_;
CYFinally *finally_;
CYForInitialiser *for_;
CYForInInitialiser *forin_;
CYFunctionParameter *functionParameter_;
CYIdentifier *identifier_;
CYInfix *infix_;
CYLiteral *literal_;
CYMember *member_;
CYNull *null_;
CYNumber *number_;
CYProgram *program_;
CYProperty *property_;
CYPropertyName *propertyName_;
CYRubyProc *rubyProc_;
CYStatement *statement_;
CYString *string_;
CYThis *this_;
CYTrue *true_;
CYWord *word_;
@begin ObjectiveC
CYClassName *className_;
CYField *field_;
CYMessage *message_;
CYMessageParameter *messageParameter_;
CYProtocol *protocol_;
CYSelectorPart *selector_;
@end
@begin E4X
CYAttribute *attribute_;
CYPropertyIdentifier *propertyIdentifier_;
CYSelector *selector_;
@end
};
} YYSTYPE;
#define YYSTYPE YYSTYPE
@if Bison24 }
@if Bison24 %code provides {
int cylex(YYSTYPE *, cy::location *, void *);
@if Bison24 }
@if Bison23 %}
%name-prefix="cy"
@if Bison23 %skeleton "lalr1.cc"
@if Bison24 %language "C++"
%initial-action {
@$.begin.filename = @$.end.filename = &driver.filename_;
};
%locations
%defines
//%glr-parser
//%expect 1
%error-verbose
%parse-param { CYDriver &driver }
%lex-param { void *cyscanner }
@begin E4X
%token XMLCDATA
%token XMLComment
%token XMLPI
%token XMLAttributeValue
%token XMLName
%token XMLTagCharacters
%token XMLText
%token XMLWhitespace
@end
@begin E4X
%token LeftRight "<>"
%token LeftSlashRight ">"
%token SlashRight "/>"
%token LeftSlash ""
%token ColonColon "::"
%token PeriodPeriod ".."
@end
@begin E4X ObjectiveC
%token At "@"
@end
%token Ampersand "&"
%token AmpersandAmpersand "&&"
%token AmpersandEqual "&="
%token Carrot "^"
%token CarrotEqual "^="
%token Equal "="
%token EqualEqual "=="
%token EqualEqualEqual "==="
%token Exclamation "!"
%token ExclamationEqual "!="
%token ExclamationEqualEqual "!=="
%token Hyphen "-"
%token HyphenEqual "-="
%token HyphenHyphen "--"
%token HyphenHyphen_ "\n--"
%token HyphenRight "->"
%token Left "<"
%token LeftEqual "<="
%token LeftLeft "<<"
%token LeftLeftEqual "<<="
%token Percent "%"
%token PercentEqual "%="
%token Period "."
%token Pipe "|"
%token PipeEqual "|="
%token PipePipe "||"
%token Plus "+"
%token PlusEqual "+="
%token PlusPlus "++"
%token PlusPlus_ "\n++"
%token Right ">"
%token RightEqual ">="
%token RightRight ">>"
%token RightRightEqual ">>="
%token RightRightRight ">>>"
%token RightRightRightEqual ">>>="
%token Slash "/"
%token SlashEqual "/="
%token Star "*"
%token StarEqual "*="
%token Tilde "~"
%token Colon ":"
%token Comma ","
%token Question "?"
%token SemiColon ";"
%token NewLine "\n"
%token Comment
%token OpenParen "("
%token CloseParen ")"
%token OpenBrace "{"
%token OpenBrace_ "\n{"
%token CloseBrace "}"
%token OpenBracket "["
%token CloseBracket "]"
@begin Java
%token AtClass "@class"
@end
@begin ObjectiveC
%token AtImplementation "@implementation"
%token AtImport "@import"
%token AtEnd "@end"
%token AtSelector "@selector"
@end
%token False "false"
%token Null "null"
%token True "true"
// ES3/ES5/WIE/JSC Reserved
%token Break "break"
%token Case "case"
%token Catch "catch"
%token Continue "continue"
%token Default "default"
%token Delete "delete"
%token Do "do"
%token Else "else"
%token Finally "finally"
%token For "for"
%token Function "function"
%token If "if"
%token In "in"
%token InstanceOf "instanceof"
%token New "new"
%token Return "return"
%token Switch "switch"
%token This "this"
%token Throw "throw"
%token Try "try"
%token TypeOf "typeof"
%token Var "var"
%token Void "void"
%token While "while"
%token With "with"
// ES3/IE6 Future, ES5/JSC Reserved
%token Debugger "debugger"
// ES3/ES5/IE6 Future, JSC Reserved
%token Const "const"
// ES3/ES5/IE6/JSC Future
%token Class "class"
%token Enum "enum"
%token Export "export"
%token Extends "extends"
%token Import "import"
%token Super "super"
// ES3 Future, ES5 Strict Future
%token Implements "implements"
%token Interface "interface"
%token Package "package"
%token Private "private"
%token Protected "protected"
%token Public "public"
%token Static "static"
// ES3 Future
%token Abstract "abstract"
%token Boolean "boolean"
%token Byte "byte"
%token Char "char"
%token Double "double"
%token Final "final"
%token Float "float"
%token Goto "goto"
%token Int "int"
%token Long "long"
%token Native "native"
%token Short "short"
%token Synchronized "synchronized"
%token Throws "throws"
%token Transient "transient"
%token Volatile "volatile"
// ES5 Strict
%token Let "let"
%token Yield "yield"
// Woah?!
%token Each "each"
@begin E4X
// E4X Conditional
%token Namespace "namespace"
%token XML "xml"
@end
%token AutoComplete
%token Identifier_
%token NumericLiteral
%token StringLiteral
%token RegularExpressionLiteral
%type AdditiveExpression
%type AdditiveExpressionNoBF
%type ArgumentList
%type ArgumentList_
%type ArgumentListOpt
%type Arguments
%type ArrayLiteral
%type AssigneeExpression
%type AssigneeExpressionNoBF
%type AssignmentExpression
%type AssignmentExpression_
%type AssignmentExpressionNoBF
%type AssignmentExpressionNoIn
%type BitwiseANDExpression
%type BitwiseANDExpressionNoBF
%type BitwiseANDExpressionNoIn
%type Block
%type Block_
%type BooleanLiteral
%type BitwiseORExpression
%type BitwiseORExpressionNoBF
%type BitwiseORExpressionNoIn
%type BitwiseXORExpression
%type BitwiseXORExpressionNoBF
%type BitwiseXORExpressionNoIn
%type BreakStatement
%type CallExpression
%type CallExpressionNoBF
%type CaseBlock
%type CaseClause
%type CaseClausesOpt
%type CatchOpt
%type ComprehensionList
%type ComprehensionListOpt
%type ConditionalExpression
%type ConditionalExpressionNoBF
%type ConditionalExpressionNoIn
%type ContinueStatement
%type DefaultClause
%type DoWhileStatement
%type Element
%type ElementOpt
%type ElementList
%type ElementListOpt
%type ElseStatementOpt
%type EmptyStatement
%type EqualityExpression
%type EqualityExpressionNoBF
%type EqualityExpressionNoIn
%type Expression
%type ExpressionOpt
%type Expression_
%type ExpressionNoBF
%type ExpressionNoIn
%type ExpressionNoIn_
%type ExpressionNoInOpt
%type ExpressionStatement
%type FinallyOpt
%type ForComprehension
%type ForStatement
%type ForStatementInitialiser
%type ForInStatement
%type ForInStatementInitialiser
%type FormalParameterList
%type FormalParameterList_
%type FunctionBody
%type FunctionDeclaration
%type FunctionExpression
%type Identifier
%type IdentifierOpt
%type IfComprehension
%type IfStatement
%type Initialiser
%type InitialiserOpt
%type InitialiserNoIn
%type InitialiserNoInOpt
%type IterationStatement
%type LabelledStatement
%type LeftHandSideExpression
%type LeftHandSideExpressionNoBF
//%type LetStatement
%type Literal
%type LiteralNoRE
%type LiteralRE
%type LogicalANDExpression
%type LogicalANDExpressionNoBF
%type LogicalANDExpressionNoIn
%type LogicalORExpression
%type LogicalORExpressionNoBF
%type LogicalORExpressionNoIn
%type MemberAccess
%type MemberExpression
%type MemberExpression_
%type MemberExpressionNoBF
%type MultiplicativeExpression
%type MultiplicativeExpressionNoBF
%type NewExpression
%type NewExpression_
%type NewExpressionNoBF
%type NullLiteral
%type ObjectLiteral
%type PostfixExpression
%type PostfixExpressionNoBF
%type PrimaryExpression
%type PrimaryExpressionNo
%type PrimaryExpressionNoBF
%type PrimaryExpressionNoRE
%type PrimaryExpressionBF
%type Program
%type PropertyName
%type PropertyName_
%type PropertyNameAndValueList
%type PropertyNameAndValueList_
%type PropertyNameAndValueListOpt
%type RelationalExpression
%type RelationalExpression_
%type RelationalExpressionNoBF
%type RelationalExpressionNoIn
%type RelationalExpressionNoIn_
%type ReturnStatement
%type RubyProcExpression
%type RubyProcExpressionNoOA
%type RubyProcParameterList
%type RubyProcParameterList_
%type RubyProcParameters
%type RubyProcParametersOpt
%type ShiftExpression
%type ShiftExpressionNoBF
%type SourceElement
%type SourceElement_
%type SourceElements
%type Statement
%type Statement_
%type StatementList
%type StatementListOpt
%type SwitchStatement
%type ThrowStatement
%type TryStatement
%type UnaryExpression
%type UnaryExpression_
%type UnaryExpressionNoBF
%type VariableDeclaration
%type VariableDeclarationNoIn
%type VariableDeclarationList
%type VariableDeclarationList_
%type VariableDeclarationListNoIn
%type VariableDeclarationListNoIn_
%type VariableStatement
%type WhileStatement
%type WithStatement
@begin C
%type AssigneeExpressionNoRE
%type CallExpressionNoRE
%type LeftHandSideExpressionNoRE
%type MemberExpressionNoRE
%type NewExpressionNoRE
%type PostfixExpressionNoRE
%type UnaryAssigneeExpression
%type UnaryExpressionNoRE
@end
@begin ObjectiveC
%type CategoryStatement
%type ClassExpression
%type ClassStatement
%type ClassSuperOpt
%type ClassFieldList
%type ClassMessageDeclaration
%type ClassMessageDeclarationListOpt
%type ClassName
%type ClassNameOpt
%type ClassProtocolListOpt
%type ClassProtocols
%type ClassProtocolsOpt
%type MessageExpression
%type MessageParameter
%type MessageParameters
%type MessageParameterList
%type MessageParameterListOpt
%type MessageScope
%type SelectorCall
%type SelectorCall_
%type SelectorExpression
%type SelectorExpression_
%type SelectorExpressionOpt
%type SelectorList
%type SelectorWordOpt
%type TypeOpt
%type VariadicCall
%type