X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/b3378a02d0a811be38e530933fb9a57a3012a823..341d1456832396678c21074a7ec2a07181e12f49:/Cycript.yy.in
diff --git a/Cycript.yy.in b/Cycript.yy.in
index 224d6bf..8b00100 100644
--- a/Cycript.yy.in
+++ b/Cycript.yy.in
@@ -1,35 +1,34 @@
/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2010 Jay Freeman (saurik)
+ * Copyright (C) 2009-2015 Jay Freeman (saurik)
*/
-/* GNU Lesser General Public License, Version 3 {{{ */
+/* GNU Affero 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 .
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program 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 Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
**/
/* }}} */
-@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)
+#include "Stack.hpp"
+#define CYNew new(driver.pool_)
@begin ObjectiveC
#include "ObjectiveC/Syntax.hpp"
@@ -39,8 +38,11 @@
#include "E4X/Syntax.hpp"
@end
+#include "Highlight.hpp"
+
typedef struct {
bool newline_;
+ hi::Value highlight_;
union {
bool bool_;
@@ -54,7 +56,6 @@ typedef struct {
cy::Syntax::Catch *catch_;
CYComment *comment_;
CYComprehension *comprehension_;
- CYCompound *compound_;
CYDeclaration *declaration_;
CYDeclarations *declarations_;
CYElement *element_;
@@ -68,8 +69,10 @@ typedef struct {
CYInfix *infix_;
CYLiteral *literal_;
CYMember *member_;
+ CYModule *module_;
CYNull *null_;
CYNumber *number_;
+ CYParenthetical *parenthetical_;
CYProgram *program_;
CYProperty *property_;
CYPropertyName *propertyName_;
@@ -80,9 +83,16 @@ typedef struct {
CYTrue *true_;
CYWord *word_;
+@begin C
+ CYTypeModifier *modifier_;
+ CYTypeSpecifier *specifier_;
+ CYTypedIdentifier *typedIdentifier_;
+ CYTypedParameter *typedParameter_;
+@end
+
@begin ObjectiveC
CYClassName *className_;
- CYField *field_;
+ CYClassField *classField_;
CYMessage *message_;
CYMessageParameter *messageParameter_;
CYProtocol *protocol_;
@@ -98,18 +108,15 @@ typedef struct {
} YYSTYPE;
#define YYSTYPE YYSTYPE
-@if Bison24 }
+}
-@if Bison24 %code provides {
-int cylex(YYSTYPE *, cy::location *, void *);
-@if Bison24 }
+%code provides {
+int cylex(YYSTYPE *, CYLocation *, void *);
+}
-@if Bison23 %}
+%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_;
@@ -118,6 +125,8 @@ int cylex(YYSTYPE *, cy::location *, void *);
%locations
%defines
+%define api.location.type { CYLocation }
+
//%glr-parser
//%expect 1
@@ -126,6 +135,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
%parse-param { CYDriver &driver }
%lex-param { void *cyscanner }
+/* Token Declarations {{{ */
@begin E4X
%token XMLCDATA
%token XMLComment
@@ -151,6 +161,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
@begin E4X ObjectiveC
%token At "@"
+%token Pound "#"
@end
%token Ampersand "&"
@@ -161,6 +172,8 @@ int cylex(YYSTYPE *, cy::location *, void *);
%token Equal "="
%token EqualEqual "=="
%token EqualEqualEqual "==="
+%token EqualRight "=>"
+%token EqualRight_ "\n=>"
%token Exclamation "!"
%token ExclamationEqual "!="
%token ExclamationEqualEqual "!=="
@@ -176,6 +189,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
%token Percent "%"
%token PercentEqual "%="
%token Period "."
+%token PeriodPeriodPeriod "..."
%token Pipe "|"
%token PipeEqual "|="
%token PipePipe "||"
@@ -208,78 +222,86 @@ int cylex(YYSTYPE *, cy::location *, void *);
%token OpenBrace "{"
%token OpenBrace_ "\n{"
+%token OpenBrace__ ";{"
%token CloseBrace "}"
%token OpenBracket "["
%token CloseBracket "]"
+%token AtError "@error"
+
@begin Java
%token AtClass "@class"
@end
+@begin C
+%token Typedef "typedef"
+%token Unsigned "unsigned"
+%token Signed "signed"
+%token Extern "extern"
+@end
+
+@begin C
+%token AtEncode "@encode"
+@end
+
@begin ObjectiveC
%token AtImplementation "@implementation"
+%token AtImplementation_ ";@implementation"
%token AtImport "@import"
%token AtEnd "@end"
%token AtSelector "@selector"
+%token AtNull "@null"
+%token AtYes "@YES"
+%token AtNo "@NO"
+%token AtTrue "@true"
+%token AtFalse "@false"
+%token Yes "YES"
+%token No "NO"
@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"
+%token False "false"
+%token Null "null"
+%token True "true"
+
+%token Break "break"
+%token Case "case"
+%token Catch "catch"
+%token Class "class"
+%token Const "const"
+%token Continue "continue"
+%token Debugger "debugger"
+%token Default "default"
+%token Delete "delete"
+%token Do "do"
+%token Else "else"
+%token Enum "enum"
+%token Export "export"
+%token Extends "extends"
+%token Finally "finally"
+%token For "for"
+%token Function "function"
+%token Function_ ";function"
+%token If "if"
+%token Import "import"
+%token In "in"
+%token In_ "!in"
+%token InstanceOf "instanceof"
+%token New "new"
+%token Return "return"
+%token Super "super"
+%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 Future
%token Abstract "abstract"
+%token Await "await"
%token Boolean "boolean"
%token Byte "byte"
%token Char "char"
@@ -287,24 +309,29 @@ int cylex(YYSTYPE *, cy::location *, void *);
%token Final "final"
%token Float "float"
%token Goto "goto"
+%token Implements "implements"
%token Int "int"
+%token Interface "interface"
+%token Let "let"
%token Long "long"
%token Native "native"
+%token Package "package"
+%token Private "private"
+%token Protected "protected"
+%token Public "public"
%token Short "short"
+%token Static "static"
%token Synchronized "synchronized"
%token Throws "throws"
%token Transient "transient"
%token Volatile "volatile"
-
-// ES5 Strict
-%token Let "let"
%token Yield "yield"
-// Woah?!
+%token Auto "auto"
%token Each "each"
+%token Of "of"
@begin E4X
-// E4X Conditional
%token Namespace "namespace"
%token XML "xml"
@end
@@ -317,45 +344,45 @@ int cylex(YYSTYPE *, cy::location *, void *);
%token RegularExpressionLiteral
%type AdditiveExpression
-%type AdditiveExpressionNoBF
-%type ArgumentList
%type ArgumentList_
+%type ArgumentList
%type ArgumentListOpt
%type Arguments
+%type ArrayComprehension
+%type ArrayInitialiser
%type ArrayLiteral
-%type AssigneeExpression
-%type AssigneeExpressionNoBF
+%type ArrowFunction
+%type ArrowParameters
%type AssignmentExpression
-%type AssignmentExpression_
-%type AssignmentExpressionNoBF
-%type AssignmentExpressionNoIn
+%type Binding
+%type BindingIdentifier
%type BitwiseANDExpression
-%type BitwiseANDExpressionNoBF
-%type BitwiseANDExpressionNoIn
-%type Block
%type Block_
+%type Block
%type BooleanLiteral
+%type BindingElement
%type BitwiseORExpression
-%type BitwiseORExpressionNoBF
-%type BitwiseORExpressionNoIn
%type BitwiseXORExpression
-%type BitwiseXORExpressionNoBF
-%type BitwiseXORExpressionNoIn
%type BreakStatement
+%type BreakableStatement
+%type CallExpression_
%type CallExpression
-%type CallExpressionNoBF
%type CaseBlock
%type CaseClause
%type CaseClausesOpt
%type CatchOpt
-%type ComprehensionList
-%type ComprehensionListOpt
+%type Comprehension
+%type ComprehensionFor
+%type ComprehensionIf
+%type ComprehensionTail
%type ConditionalExpression
-%type ConditionalExpressionNoBF
-%type ConditionalExpressionNoIn
%type ContinueStatement
+%type ConciseBody
+%type DebuggerStatement
+%type Declaration__
+%type Declaration_
+%type Declaration
%type DefaultClause
-%type DoWhileStatement
%type Element
%type ElementOpt
%type ElementList
@@ -363,125 +390,109 @@ int cylex(YYSTYPE *, cy::location *, void *);
%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 FormalParameter
%type FormalParameterList_
+%type FormalParameterList
+%type FormalParameterListOpt
%type FunctionBody
%type FunctionDeclaration
%type FunctionExpression
%type Identifier
%type IdentifierOpt
-%type IfComprehension
+%type IdentifierType
+%type IdentifierName
%type IfStatement
%type Initialiser
%type InitialiserOpt
-%type InitialiserNoIn
-%type InitialiserNoInOpt
%type IterationStatement
%type LabelledStatement
%type LeftHandSideExpression
-%type LeftHandSideExpressionNoBF
-//%type LetStatement
+%type LetStatement
+%type LexicalDeclaration
%type Literal
-%type LiteralNoRE
-%type LiteralRE
+%type ValueLiteral
%type LogicalANDExpression
-%type LogicalANDExpressionNoBF
-%type LogicalANDExpressionNoIn
%type LogicalORExpression
-%type LogicalORExpressionNoBF
-%type LogicalORExpressionNoIn
%type MemberAccess
-%type MemberExpression
%type MemberExpression_
-%type MemberExpressionNoBF
+%type MemberExpression
+%type Module
%type MultiplicativeExpression
-%type MultiplicativeExpressionNoBF
%type NewExpression
-%type NewExpression_
-%type NewExpressionNoBF
%type NullLiteral
%type ObjectLiteral
+%type Parenthetical
%type PostfixExpression
-%type PostfixExpressionNoBF
%type PrimaryExpression
-%type PrimaryExpressionNo
-%type PrimaryExpressionNoBF
-%type PrimaryExpressionNoRE
-%type PrimaryExpressionBF
%type Program
-%type PropertyName
+%type ProgramBody
+%type ProgramBodyOpt
%type PropertyName_
-%type PropertyNameAndValueList
-%type PropertyNameAndValueList_
-%type PropertyNameAndValueListOpt
+%type PropertyName
+%type PropertyDefinition
+%type PropertyDefinitionList_
+%type PropertyDefinitionList
+%type PropertyDefinitionListOpt
%type RelationalExpression
-%type RelationalExpression_
-%type RelationalExpressionNoBF
-%type RelationalExpressionNoIn
-%type RelationalExpressionNoIn_
%type ReturnStatement
%type RubyProcExpression
-%type RubyProcParameterList
%type RubyProcParameterList_
+%type RubyProcParameterList
+%type RubyProcParameters
%type RubyProcParametersOpt
%type ShiftExpression
-%type ShiftExpressionNoBF
-%type SourceElement
-%type SourceElement_
-%type SourceElements
-%type Statement
+%type SingleNameBinding
+%type Statement__
%type Statement_
+%type Statement
%type StatementList
%type