📄 netscape-ecma-v4.y
字号:
%{ /* asc.y -- written by Alexis WILKE for Made to Order Software, Ltd. (c) 2005-2006 */ /* grammar parser for SSWF Action Scripts *//*Copyright (c) 2005-2006 Made to Order Software, Ltd.Permission is hereby granted, free of charge, to anyperson obtaining a copy of this software andassociated documentation files (the "Software"), todeal in the Software without restriction, includingwithout limitation the rights to use, copy, modify,merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whomthe Software is furnished to do so, subject to thefollowing conditions:The above copyright notice and this permission noticeshall be included in all copies or substantialportions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OFANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOTLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NOEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.*/#include "sswf.h"#define YYPARSE_PARAM resultstatic void yyerror(const char *msg);%}%union{ struct node_t *node; int unused;};/* terminals */%token <node> AS%token <node> ASSIGNMENT // = := *= /= %= += -= <<= >>= >>>= &= ^= |= &&= ^^= ||=%token <node> BREAK%token <node> CASE%token <node> CATCH%token <node> CLASS%token <node> CONST%token <node> CONTINUE%token <node> DECREMENT // --%token <node> DEFAULT%token <node> DELETE%token <node> DO%token <node> ELIPSIS // ...%token <node> ELSE%token <node> EQUAL // ==%token <node> EXTENDS%token <node> FALSE%token <node> FOR%token <node> FINALLY%token <node> FUNCTION%token <node> GET%token <node> GREATER_EQUAL // >=%token <node> IDENTIFIER%token <node> IF%token <node> IMPORT%token <node> IN%token <node> INCREMENT // ++%token <node> INSTANCEOF%token <node> IS%token <node> LOGICAL_AND // &&%token <node> LOGICAL_OR // ||%token <node> LOGICAL_XOR // ^^%token <node> NAMESPACE%token <node> NEGATED_MIN_LONG%token <node> NEW%token <node> NOT_EQUAL // != <> (?)%token <node> NULL_LITERAL // null%token <node> NUMBER%token <node> LESS_EQUAL // <=%token <node> PACKAGE%token <node> PRIVATE%token <node> PUBLIC%token <node> REGULAR_EXPRESSION // /<expr>/<flags>%token <node> RETURN%token <node> SCOPE // ::%token <node> SET%token <node> SHIFT_LEFT // <<%token <node> SHIFT_RIGHT // >>%token <node> SHIFT_RIGHT_UNSIGNED // >>>%token <node> STRICTLY_EQUAL // ===%token <node> STRICTLY_NOT_EQUAL // !==%token <node> STRING%token <node> SUPER%token <node> SWITCH%token <node> THIS%token <node> THROW%token <node> TRUE%token <node> TRY%token <node> TYPEOF%token <node> USE%token <node> VAR%token <node> VOID%token <node> WITH%token <node> WHILE/* all these yacc expressions are nodes */%%start: program { };identifier: IDENTIFIER { } | GET { } | SET { };simple_qualified_identifier: identifier { } | identifier SCOPE identifier { } | reserved_namespace SCOPE identifier { };expression_qualified_identifier: paren_expression SCOPE identifier { };qualified_identifier: simple_qualified_identifier { } | expression_qualified_identifier { };primary_expression: NULL_LITERAL { } | TRUE { } | FALSE { } | NUMBER { } | STRING { } | THIS { } | REGULAR_EXPRESSION { } | reserved_namespace { } | paren_list_expression { } | array_literal { } | object_literal { } | function_expression { };reserved_namespace: PUBLIC { } | PRIVATE { };paren_expression: '(' assignment_expression ')' { };paren_list_expression: paren_expression { } | '(' list_expression ',' assignment_expression ')' { };function_expression: FUNCTION function_common { } | FUNCTION IDENTIFIER function_common { };object_literal: '{' field_list '}' { };field_list: /* EMPTY */ { } | nonempty_field_list { };nonempty_field_list: literal_field { } | literal_field ',' nonempty_field_list { };literal_field: field_name ':' assignment_expression { };field_name: qualified_identifier { } | STRING { } | NUMBER { } | paren_expression { };array_literal: '[' element_list ']' { };element_list: /* EMPTY */ { } | literal_element { } | ',' element_list { } | literal_element ',' element_list { };literal_element: assignment_expression { };super_expression: SUPER { } | SUPER paren_expression { };postfix_expression: attribute_expression { } | full_postfix_expression { } | short_new_expression { };attribute_expression: simple_qualified_identifier { } | attribute_expression property_operator { } | attribute_expression arguments { };full_postfix_expression: primary_expression { } | expression_qualified_identifier { } | full_new_expression { } | full_postfix_expression property_operator { } | super_expression property_operator { } | full_postfix_expression arguments { } | postfix_expression INCREMENT { } | postfix_expression DECREMENT { };full_new_expression: NEW full_new_subexpression arguments { };full_new_subexpression: primary_expression { } | qualified_identifier { } | full_new_expression { } | full_new_subexpression property_operator { } | super_expression property_operator { };short_new_expression: NEW short_new_subexpression { };short_new_subexpression: full_new_subexpression { } | short_new_expression { };property_operator: '.' qualified_identifier { } | brackets { };brackets: '[' ']' { } | '[' list_expression ']' { } | '[' expressions_with_rest ']' { };arguments: '(' ')' { } | paren_list_expression { } | '(' expressions_with_rest ')' { };expressions_with_rest: rest_expression { } | list_expression ',' rest_expression { };rest_expression: ELIPSIS assignment_expression { };unary_expression: postfix_expression { } | DELETE postfix_expression { } | VOID unary_expression { } | TYPEOF unary_expression { } | INCREMENT postfix_expression { } | DECREMENT postfix_expression { } | '+' unary_expression { } | '-' unary_expression { } | '-' NEGATED_MIN_LONG { } | '~' unary_expression { } | '!' unary_expression { };multiplicative_expression: unary_expression { } | multiplicative_expression '*' unary_expression { } | multiplicative_expression '/' unary_expression { } | multiplicative_expression '%' unary_expression { };additive_expression: multiplicative_expression { } | additive_expression '+' multiplicative_expression { } | additive_expression '-' multiplicative_expression { };shift_expression: additive_expression { } | shift_expression SHIFT_LEFT additive_expression { } | shift_expression SHIFT_RIGHT additive_expression { } | shift_expression SHIFT_RIGHT_UNSIGNED additive_expression { };relational_expression: shift_expression { } | relational_expression '<' shift_expression { } | relational_expression '>' shift_expression { } | relational_expression LESS_EQUAL shift_expression { } | relational_expression GREATER_EQUAL shift_expression { } | relational_expression IS shift_expression { } | relational_expression AS shift_expression { } | relational_expression IN shift_expression { } | relational_expression INSTANCEOF shift_expression { };equality_expression: relational_expression { } | equality_expression EQUAL relational_expression { } | equality_expression NOT_EQUAL relational_expression { } | equality_expression STRICTLY_EQUAL relational_expression { } | equality_expression STRICTLY_NOT_EQUAL relational_expression { };bitwise_and_expression: equality_expression { } | bitwise_and_expression '&' equality_expression { };bitwise_xor_expression: bitwise_and_expression { } | bitwise_xor_expression '^' bitwise_and_expression { };bitwise_or_expression: bitwise_xor_expression { } | bitwise_or_expression '|' bitwise_xor_expression { };logical_and_expression: bitwise_or_expression { } | logical_and_expression LOGICAL_AND bitwise_or_expression { };logical_xor_expression: logical_and_expression { } | logical_xor_expression LOGICAL_XOR logical_and_expression { };logical_or_expression: logical_xor_expression { } | logical_or_expression LOGICAL_OR logical_xor_expression { };conditional_expression: logical_or_expression { } | logical_or_expression '?' assignment_expression ':' assignment_expression { };non_assignment_expression: logical_or_expression { } | logical_or_expression '?' non_assignment_expression ':' non_assignment_expression { };assignment_expression: conditional_expression { } | postfix_expression ASSIGNMENT assignment_expression { };list_expression: assignment_expression { } | list_expression ',' assignment_expression { };type_expression: non_assignment_expression { };statement: expression_statement ';' { } | super_statement ';' { } | block { } | labeled_statement { } | if_statement { } | switch_statement { } | do_statement ';' { } | while_statement { } | for_statement { } | with_statement { }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -