⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grammar.y

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 Y
📖 第 1 页 / 共 5 页
字号:
%token SWITCH WITH RESERVED%token THROW TRY CATCH FINALLY%token DEBUGGER/* give an if without an else higher precedence than an else to resolve the ambiguity */%nonassoc IF_WITHOUT_ELSE%nonassoc ELSE/* punctuators */%token EQEQ NE                     /* == and != */%token STREQ STRNEQ                /* === and !== */%token LE GE                       /* < and > */%token OR AND                      /* || and && */%token PLUSPLUS MINUSMINUS         /* ++ and --  */%token LSHIFT                      /* << */%token RSHIFT URSHIFT              /* >> and >>> */%token PLUSEQUAL MINUSEQUAL        /* += and -= */%token MULTEQUAL DIVEQUAL          /* *= and /= */%token LSHIFTEQUAL                 /* <<= */%token RSHIFTEQUAL URSHIFTEQUAL    /* >>= and >>>= */%token ANDEQUAL MODEQUAL           /* &= and %= */%token XOREQUAL OREQUAL            /* ^= and |= */%token <intValue> OPENBRACE        /* { (with char offset) */%token <intValue> CLOSEBRACE        /* { (with char offset) *//* terminal types */%token <doubleValue> NUMBER%token <ident> IDENT STRING/* automatically inserted semicolon */%token AUTOPLUSPLUS AUTOMINUSMINUS/* non-terminal types */%type <expressionNode>  Literal ArrayLiteral%type <expressionNode>  PrimaryExpr PrimaryExprNoBrace%type <expressionNode>  MemberExpr MemberExprNoBF /* BF => brace or function */%type <expressionNode>  NewExpr NewExprNoBF%type <expressionNode>  CallExpr CallExprNoBF%type <expressionNode>  LeftHandSideExpr LeftHandSideExprNoBF%type <expressionNode>  PostfixExpr PostfixExprNoBF%type <expressionNode>  UnaryExpr UnaryExprNoBF UnaryExprCommon%type <expressionNode>  MultiplicativeExpr MultiplicativeExprNoBF%type <expressionNode>  AdditiveExpr AdditiveExprNoBF%type <expressionNode>  ShiftExpr ShiftExprNoBF%type <expressionNode>  RelationalExpr RelationalExprNoIn RelationalExprNoBF%type <expressionNode>  EqualityExpr EqualityExprNoIn EqualityExprNoBF%type <expressionNode>  BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF%type <expressionNode>  BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF%type <expressionNode>  BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF%type <expressionNode>  LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF%type <expressionNode>  LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF%type <expressionNode>  ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF%type <expressionNode>  AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF%type <expressionNode>  Expr ExprNoIn ExprNoBF%type <expressionNode>  ExprOpt ExprNoInOpt%type <statementNode>   Statement Block%type <statementNode>   VariableStatement ConstStatement EmptyStatement ExprStatement%type <statementNode>   IfStatement IterationStatement ContinueStatement%type <statementNode>   BreakStatement ReturnStatement WithStatement%type <statementNode>   SwitchStatement LabelledStatement%type <statementNode>   ThrowStatement TryStatement%type <statementNode>   DebuggerStatement%type <expressionNode>  Initializer InitializerNoIn%type <statementNode>   FunctionDeclaration%type <funcExprNode>    FunctionExpr%type <functionBodyNode>  FunctionBody%type <sourceElements>  SourceElements%type <parameterList>   FormalParameterList%type <op>              AssignmentOperator%type <argumentsNode>   Arguments%type <argumentList>    ArgumentList%type <varDeclList>     VariableDeclarationList VariableDeclarationListNoIn%type <constDeclList>   ConstDeclarationList%type <constDeclNode>   ConstDeclaration%type <caseBlockNode>   CaseBlock%type <caseClauseNode>  CaseClause DefaultClause%type <clauseList>      CaseClauses CaseClausesOpt%type <intValue>        Elision ElisionOpt%type <elementList>     ElementList%type <propertyNode>    Property%type <propertyList>    PropertyList%%// FIXME: There are currently two versions of the grammar in this file, the normal one, and the NoNodes version used for// lazy recompilation of FunctionBodyNodes.  We should move to generating the two versions from a script to avoid bugs.// In the mean time, make sure to make any changes to the grammar in both versions.Literal:    NULLTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); }  | TRUETOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); }  | FALSETOKEN                          { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); }  | NUMBER                              { $$ = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, $1), 0, 1); }  | STRING                              { $$ = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *$1), 0, 1); }  | '/' /* regexp */                    {                                            Lexer& l = *LEXER;                                            if (!l.scanRegExp())                                                YYABORT;                                            RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags());                                            int size = l.pattern().size() + 2; // + 2 for the two /'s                                            SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);                                            $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);                                        }  | DIVEQUAL /* regexp with /= */       {                                            Lexer& l = *LEXER;                                            if (!l.scanRegExp())                                                YYABORT;                                            RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags());                                            int size = l.pattern().size() + 2; // + 2 for the two /'s                                            SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);                                            $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);                                        };Property:    IDENT ':' AssignmentExpr            { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }  | STRING ':' AssignmentExpr           { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }  | NUMBER ':' AssignmentExpr           { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }  | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE    { $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, 0, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); if (!$$.m_node) YYABORT; }  | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE                                                             {                                                                 $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0);                                                                  if ($4.m_features & ArgumentsFeature)                                                                     $7->setUsesArguments();                                                                  DBG($7, @6, @8);                                                                  if (!$$.m_node)                                                                      YYABORT;                                                              };PropertyList:    Property                            { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node);                                           $$.m_node.tail = $$.m_node.head;                                          $$.m_features = $1.m_features;                                          $$.m_numConstants = $1.m_numConstants; }  | PropertyList ',' Property           { $$.m_node.head = $1.m_node.head;                                          $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail);                                          $$.m_features = $1.m_features | $3.m_features;                                          $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; };PrimaryExpr:    PrimaryExprNoBrace  | OPENBRACE CLOSEBRACE                             { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); }  | OPENBRACE PropertyList CLOSEBRACE                { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }  /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */  | OPENBRACE PropertyList ',' CLOSEBRACE            { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); };PrimaryExprNoBrace:    THISTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }  | Literal  | ArrayLiteral  | IDENT                               { $$ = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }  | '(' Expr ')'                        { $$ = $2; };ArrayLiteral:    '[' ElisionOpt ']'                  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); }  | '[' ElementList ']'                 { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }  | '[' ElementList ',' ElisionOpt ']'  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); };ElementList:    ElisionOpt AssignmentExpr           { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node);                                          $$.m_node.tail = $$.m_node.head;                                          $$.m_features = $2.m_features;                                          $$.m_numConstants = $2.m_numConstants; }  | ElementList ',' ElisionOpt AssignmentExpr                                        { $$.m_node.head = $1.m_node.head;                                          $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node);                                          $$.m_features = $1.m_features | $4.m_features;                                          $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; };ElisionOpt:    /* nothing */                       { $$ = 0; }  | Elision;Elision:    ','                                 { $$ = 1; }  | Elision ','                         { $$ = $1 + 1; };MemberExpr:    PrimaryExpr  | FunctionExpr                        { $$ = createNodeInfo<ExpressionNode*>($1.m_node, $1.m_features, $1.m_numConstants); }  | MemberExpr '[' Expr ']'             { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);                                          SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);                                          $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);                                         }  | MemberExpr '.' IDENT                { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);                                          SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -