X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/5a6c975adbe2588a10190cba75e9152682bedeae..849b0beafc5d722cd9abf4050430600d149cc342:/Parser.ypp.in diff --git a/Parser.ypp.in b/Parser.ypp.in index acda20a..c3f2379 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -27,6 +27,7 @@ #include "Driver.hpp" #include "Parser.hpp" #include "Stack.hpp" +#include "Syntax.hpp" #define CYNew new(driver.pool_) @begin ObjectiveC @@ -48,11 +49,13 @@ %union { CYBinding *binding_; } %union { CYBindings *bindings_; } %union { CYBoolean *boolean_; } +%union { CYBraced *braced_; } %union { CYClause *clause_; } %union { cy::Syntax::Catch *catch_; } %union { CYClassTail *classTail_; } %union { CYComprehension *comprehension_; } %union { CYElement *element_; } +%union { CYEnumConstant *constant_; } %union { CYExpression *expression_; } %union { CYFalse *false_; } %union { CYVariable *variable_; } @@ -71,7 +74,7 @@ %union { CYParenthetical *parenthetical_; } %union { CYProperty *property_; } %union { CYPropertyName *propertyName_; } -%union { CYRubyProc *rubyProc_; } +%union { CYTypeSigning signing_; } %union { CYSpan *span_; } %union { CYStatement *statement_; } %union { CYString *string_; } @@ -85,6 +88,7 @@ %union { CYTypeStructField *structField_; } %union { CYTypeModifier *modifier_; } %union { CYTypeSpecifier *specifier_; } +%union { CYTypedFormal *typedFormal_; } %union { CYTypedIdentifier *typedIdentifier_; } %union { CYTypedParameter *typedParameter_; } @end @@ -183,6 +187,13 @@ type; }) yyla.type = yytranslate_(token::to); \ } while (false) +#define CYHLD(location, token) do { \ + if (driver.hold_ != empty_symbol) \ + CYERR(location, "unexpected hold"); \ + driver.hold_ = yyla.type; \ + yyla.type = yytranslate_(token); \ +} while (false) + #define CYERR(location, message) do { \ error(location, message); \ YYABORT; \ @@ -217,6 +228,9 @@ type; }) case CYMarkModule: driver.hold_ = yytranslate_(token::MarkModule); break; + case CYMarkExpression: + driver.hold_ = yytranslate_(token::MarkExpression); + break; } }; @@ -252,13 +266,11 @@ type; }) %token SlashRight "/>" %token LeftSlash " BindingElement %type BitwiseORExpression %type BitwiseXORExpression +%type BracedExpression_ +%type BracedExpression %type BreakStatement %type BreakableStatement %type CallExpression_ @@ -614,9 +632,7 @@ type; }) %type RegularExpressionSlash %type RelationalExpression %type ReturnStatement -%type RubyBlockExpression_ -%type RubyBlockExpression -%type RubyProcExpression +%type BracedParameter %type RubyProcParameterList_ %type RubyProcParameterList %type RubyProcParameters @@ -650,15 +666,20 @@ type; }) %type VariableStatement %type WithStatement %type Word +%type WordNoUnary @begin ObjectiveC %type WordOpt @end %type YieldExpression @begin C +%type EnumConstantListOpt_ +%type EnumConstantListOpt +%type IntegerNumber %type IntegerType %type IntegerTypeOpt %type PrefixedType +%type PrimitiveReference %type PrimitiveType %type StructFieldListOpt %type SuffixedType @@ -666,6 +687,7 @@ type; }) %type TypeSignifier %type TypeSignifierNone %type TypeSignifierOpt +%type TypeSigning %type ParameterTail %type TypeQualifierLeft %type TypeQualifierLeftOpt @@ -676,10 +698,12 @@ type; }) %type TypedIdentifierField %type TypedIdentifierMaybe %type TypedIdentifierNo +%type TypedIdentifierTagged %type TypedIdentifierYes -%type TypedParameterList_ -%type TypedParameterList -%type TypedParameterListOpt +%type TypedParameterList_ +%type TypedParameterList +%type TypedParameterListOpt +%type TypedParameters @end @begin ObjectiveC @@ -739,17 +763,22 @@ type; }) /* Token Priorities {{{ */ %nonassoc "if" %nonassoc "else" + +%nonassoc ":" +%nonassoc "!yield" /* }}} */ %start Program %token MarkModule %token MarkScript +%token MarkExpression %% Program : MarkScript Script | MarkModule Module + | MarkExpression Expression[expression] { driver.context_ = $expression; } ; /* Lexer State {{{ */ @@ -771,11 +800,11 @@ LexPushYieldOff: { driver.yield_.push(false); }; LexPopYield: { driver.yield_.pop(); }; LexNewLineOrOpt - : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } } + : { CYLEX(); if (driver.newline_) { CYHLD(@$, tk::NewLine); } } ; LexNewLineOrNot - : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); driver.hold_ = yyla.type; yyla.type = yytranslate_(driver.newline_ ? cy::parser::token::NewLine : cy::parser::token::__); } + : { CYLEX(); CYHLD(@$, driver.newline_ ? tk::NewLine : tk::__); } ; LexNoStar @@ -812,7 +841,7 @@ IdentifierName | "instanceof" { $$ = CYNew CYWord("instanceof"); } ; -Word +WordNoUnary : IdentifierNoOf[pass] { $$ = $pass; } | "break" { $$ = CYNew CYWord("break"); } | "case" { $$ = CYNew CYWord("case"); } @@ -823,7 +852,6 @@ Word | "continue" { $$ = CYNew CYWord("continue"); } | "debugger" { $$ = CYNew CYWord("debugger"); } | "default" { $$ = CYNew CYWord("default"); } - | "delete" { $$ = CYNew CYWord("delete"); } | "do" { $$ = CYNew CYWord("do"); } | "else" { $$ = CYNew CYWord("else"); } | "enum" { $$ = CYNew CYWord("enum"); } @@ -836,7 +864,6 @@ Word | "import" { $$ = CYNew CYWord("import"); } | "!in" { $$ = CYNew CYWord("in"); } | "!of" { $$ = CYNew CYWord("of"); } - | "new" { $$ = CYNew CYWord("new"); } | "null" { $$ = CYNew CYWord("null"); } | "return" { $$ = CYNew CYWord("return"); } | "super" { $$ = CYNew CYWord("super"); } @@ -845,11 +872,16 @@ Word | "throw" { $$ = CYNew CYWord("throw"); } | "true" { $$ = CYNew CYWord("true"); } | "try" { $$ = CYNew CYWord("try"); } - | "typeof" { $$ = CYNew CYWord("typeof"); } | "var" { $$ = CYNew CYWord("var"); } - | "void" { $$ = CYNew CYWord("void"); } | "while" { $$ = CYNew CYWord("while"); } | "with" { $$ = CYNew CYWord("with"); } + ; + +Word + : WordNoUnary[pass] { $$ = $pass; } + | "delete" { $$ = CYNew CYWord("delete"); } + | "typeof" { $$ = CYNew CYWord("typeof"); } + | "void" { $$ = CYNew CYWord("void"); } | "yield" { $$ = CYNew CYIdentifier("yield"); } ; @@ -972,6 +1004,7 @@ IdentifierTypeNoOf | "target" { $$ = CYNew CYIdentifier("target"); } | "throws" { $$ = CYNew CYIdentifier("throws"); } | "transient" { $$ = CYNew CYIdentifier("transient"); } + | "typeid" { $$ = CYNew CYIdentifier("typeid"); } | "undefined" { $$ = CYNew CYIdentifier("undefined"); } @begin ObjectiveC | "bool" { $$ = CYNew CYIdentifier("bool"); } @@ -995,6 +1028,7 @@ IdentifierNoOf : IdentifierTypeNoOf | "char" { $$ = CYNew CYIdentifier("char"); } | "int" { $$ = CYNew CYIdentifier("int"); } + | "__int128" { $$ = CYNew CYIdentifier("__int128"); } | "long" { $$ = CYNew CYIdentifier("long"); } | "__restrict" { $$ = CYNew CYIdentifier("__restrict"); } | "restrict" { $$ = CYNew CYIdentifier("restrict"); } @@ -1215,13 +1249,13 @@ AccessExpression ; LeftHandSideExpression - : RubyBlockExpression[pass] { $$ = $pass; } + : BracedExpression[pass] { $$ = $pass; } | IndirectExpression[pass] { $$ = $pass; } ; /* }}} */ /* 12.4 Postfix Expressions {{{ */ PostfixExpression - : RubyBlockExpression[pass] { $$ = $pass; } + : BracedExpression[pass] { $$ = $pass; } | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); } | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); } ; @@ -1604,7 +1638,7 @@ ForStatementInitializer ; ForInStatementInitializer - : LexLet LexOf RubyBlockExpression[pass] { $$ = $pass; } + : LexLet LexOf BracedExpression[pass] { $$ = $pass; } | LexLet LexOf IndirectExpression[pass] { $$ = $pass; } | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); } | ForDeclaration[pass] { $$ = $pass; } @@ -1798,7 +1832,7 @@ GeneratorBody YieldExpression : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } - | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } + | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } %prec "!yield" | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ } | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ } ; @@ -2026,12 +2060,12 @@ ParameterModifierOpt ; ParameterTail - : TypedParameterListOpt[parameters] ")" ParameterModifierOpt { $$ = CYNew CYTypeFunctionWith($parameters); } + : TypedParameterListOpt[formal] ")" ParameterModifierOpt { $$ = CYNew CYTypeFunctionWith($formal->variadic_, $formal->parameters_); } ; SuffixedType : SuffixedTypeOpt[typed] "[" RestrictOpt NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); } - | "(" "^" TypeQualifierRightOpt[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); } + | "(" "^" TypeQualifierRightOpt[typed] ")" "(" TypedParameters[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); } | TypeSignifier[typed] "(" ParameterTail[modifier] { $$ = $typed; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } | "("[parenthesis] ParameterTail[modifier] { $$ = CYNew CYTypedIdentifier(@parenthesis); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } ; @@ -2086,19 +2120,46 @@ StructFieldListOpt | { $$ = NULL; } ; +IntegerNumber + : NumericLiteral[pass] { $$ = $pass; } + | "-" NumericLiteral[positive] { $$ = $positive; $$->value_ = -$$->value_; } + ; + +EnumConstantListOpt_ + : "," EnumConstantListOpt[pass] { $$ = $pass; } + | { $$ = NULL; } + ; + +EnumConstantListOpt + : IdentifierType[name] "=" IntegerNumber[value] EnumConstantListOpt_[next] { $$ = CYNew CYEnumConstant($name, $value, $next); } + | { $$ = NULL; } + ; + +TypeSigning + : { $$ = CYTypeNeutral; } + | "signed" { $$ = CYTypeSigned; } + | "unsigned" { $$ = CYTypeUnsigned; } + ; + PrimitiveType : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); } | IntegerType[pass] { $$ = $pass; } - | "char" { $$ = CYNew CYTypeCharacter(CYTypeNeutral); } - | "signed" "char" { $$ = CYNew CYTypeCharacter(CYTypeSigned); } - | "unsigned" "char" { $$ = CYNew CYTypeCharacter(CYTypeUnsigned); } - | "struct" IdentifierType[name] { $$ = CYNew CYTypeReference($name); } + | TypeSigning[signing] "char" { $$ = CYNew CYTypeCharacter($signing); } + | TypeSigning[signing] "__int128" { $$ = CYNew CYTypeInt128($signing); } + ; + +PrimitiveReference + : PrimitiveType[pass] { $$ = $pass; } + | "struct" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); } + | "enum" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceEnum, $name); } + | "struct" AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; } + | "enum" AutoComplete { driver.mode_ = CYDriver::AutoEnum; YYACCEPT; } ; TypedIdentifierMaybe : TypeQualifierLeft[modifier] "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } | "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } - | TypeQualifierLeftOpt[modifier] PrimitiveType[specifier] TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + | TypeQualifierLeftOpt[modifier] PrimitiveReference[specifier] TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } ; TypedIdentifierYes @@ -2109,19 +2170,26 @@ TypedIdentifierNo : TypedIdentifierMaybe[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; } ; +TypedIdentifierTagged + : TypeQualifierLeftOpt[modifier] "struct" "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeStruct(NULL, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + | TypeQualifierLeftOpt[modifier] "enum" ":" PrimitiveType[specifier] "{" EnumConstantListOpt[constants] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeEnum(NULL, $specifier, $constants); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + ; + TypedIdentifierField : TypedIdentifierYes[pass] { $$ = $pass; } - | TypeQualifierLeftOpt[modifier] "struct" "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; $$->specifier_ = CYNew CYTypeStruct(NULL, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + | TypedIdentifierTagged[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; } ; TypedIdentifierEncoding : TypedIdentifierNo[pass] { $$ = $pass; } - | TypeQualifierLeftOpt[modifier] "struct" "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; $$->specifier_ = CYNew CYTypeStruct(NULL, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + | TypedIdentifierTagged[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; } + | "void" TypeSignifierNone[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } ; TypedIdentifierDefinition : TypedIdentifierYes[pass] { $$ = $pass; } | TypeQualifierLeftOpt[modifier] "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; $$->specifier_ = CYNew CYTypeStruct($name, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } + | "void" TypeSignifier[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } ; PrimaryExpression @@ -2163,7 +2231,7 @@ MessageParameterList MessageParameterListOpt : MessageParameterList[pass] { $$ = $pass; } - | { $$ = NULL; } + | TypedParameterList_[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); /*XXX*/ if ($formal->parameters_ != NULL) CYERR(@$, "temporarily unsupported"); $$ = NULL; } ; MessageParameters @@ -2346,21 +2414,26 @@ MemberAccess /* Cycript (C): Lambda Expressions {{{ */ TypedParameterList_ : "," TypedParameterList[parameters] { $$ = $parameters; } - | { $$ = NULL; } + | { $$ = CYNew CYTypedFormal(false); } ; TypedParameterList - : TypedIdentifierMaybe[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); } + : TypedIdentifierMaybe[typed] TypedParameterList_[formal] { $$ = $formal; $$->parameters_ = CYNew CYTypedParameter($typed, $$->parameters_); } + | "..." { $$ = CYNew CYTypedFormal(true); } ; TypedParameterListOpt : TypedParameterList[pass] { $$ = $pass; } - | "void" { $$ = NULL; } - | { $$ = NULL; } + | "void" { $$ = CYNew CYTypedFormal(false); } + | { $$ = CYNew CYTypedFormal(false); } + ; + +TypedParameters + : TypedParameterListOpt[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); $$ = $formal->parameters_; } ; PrimaryExpression - : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); } + : "[" LexOf "&" "]" "(" TypedParameters[parameters] ")" "->" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); } ; /* }}} */ /* Cycript (C): Structure Definitions {{{ */ @@ -2373,7 +2446,8 @@ Statement__ ; PrimaryExpression - : "(" LexOf "struct" NewLineOpt IdentifierType[name] TypeQualifierRightOpt[typed] ")" { $typed->specifier_ = CYNew CYTypeReference($name); $$ = CYNew CYTypeExpression($typed); } + : "(" LexOf "struct" NewLineOpt IdentifierType[name] TypeQualifierRightOpt[typed] ")" { $typed->specifier_ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); $$ = CYNew CYTypeExpression($typed); } + | "(" LexOf "struct" NewLineOpt AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; } ; /* }}} */ /* Cycript (C): Type Definitions {{{ */ @@ -2399,7 +2473,7 @@ IdentifierNoOf ; ExternCStatement - : TypedIdentifierField[typed] TerminatorHard { $$ = CYNew CYExternal(CYNew CYString("C"), $typed); } + : TypedIdentifierField[typed] TerminatorHard { $$ = CYNew CYExternalDefinition(CYNew CYString("C"), $typed); } | TypeDefinition[pass] { $$ = $pass; } ; @@ -2413,8 +2487,16 @@ ExternC | ExternCStatement[pass] { $$ = $pass; } ; +ABI + : StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } + ; + Statement__ - : "extern" NewLineNot StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } ExternC[pass] { $$ = $pass; } + : "extern" NewLineNot ABI[abi] ExternC[pass] { $$ = $pass; } + ; + +PrimaryExpression + : "(" LexOf "extern" NewLineOpt ABI[abi] TypedIdentifierField[typed] ")" { $$ = CYNew CYExternalExpression(CYNew CYString("C"), $typed); } ; /* }}} */ @end @@ -2636,16 +2718,23 @@ ComprehensionIf : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); } ; /* }}} */ -/* JavaScript FTW: Coalesce Operator {{{ */ -ConditionalExpression - : LogicalORExpression[test] "?" LexPushInOff LexOf ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); } - ; -/* }}} */ /* JavaScript FTW: Named Arguments {{{ */ ArgumentList - : LexOf Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); } + : LexOf WordNoUnary[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); } + ; +/* }}} */ +/* JavaScript FTW: Subscript Access {{{ */ +MemberAccess + : "." "[" AssignmentExpression[property] "]" { $$ = CYNew CYSubscriptMember(NULL, $property); } + ; +/* }}} */ + +/* JavaScript FTW: Java "Anonymous Inner Classes" {{{ */ +BracedParameter + : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYExtend(NULL, $properties); } ; /* }}} */ + /* JavaScript FTW: Ruby Blocks {{{ */ RubyProcParameterList_ : "," RubyProcParameterList[parameters] { $$ = $parameters; } @@ -2667,22 +2756,34 @@ RubyProcParametersOpt | { $$ = NULL; } ; -RubyProcExpression - : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); } +BracedParameter + : ";{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyBlock(NULL, CYNew CYRubyProc($parameters, $code)); } ; PrimaryExpression : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); } ; -RubyBlockExpression_ +BracedExpression_ : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; } - | RubyBlockExpression_[lhs] RubyProcExpression[rhs] LexNewLineOrOpt { $$ = CYNew CYRubyBlock($lhs, $rhs); } + | BracedExpression_[lhs] { if (!$lhs->IsNew()) CYMAP(OpenBrace_, OpenBrace); } BracedParameter[rhs] LexNewLineOrOpt { $rhs->SetLeft($lhs); $$ = $rhs; } ; -RubyBlockExpression - : RubyBlockExpression_[pass] "\n" { $$ = $pass; } - | RubyBlockExpression_[pass] { $$ = $pass; } +BracedExpression + : BracedExpression_[pass] "\n" { $$ = $pass; } + | BracedExpression_[pass] { $$ = $pass; } + ; +/* }}} */ +/* JavaScript FTW: Ruby Scopes {{{ */ +MemberAccess + : "::" "[" Expression[property] "]" { $$ = CYNew CYResolveMember(NULL, $property); } + | "::" IdentifierName[property] { $$ = CYNew CYResolveMember(NULL, CYNew CYString($property)); } + | "::" AutoComplete { driver.mode_ = CYDriver::AutoResolve; YYACCEPT; } + ; +/* }}} */ +/* JavaScript FTW: Ruby Symbols {{{ */ +PrimaryExpression + : ":" Word[name] { $$ = CYNew CYSymbol($name->Word()); } ; /* }}} */