📄 java.pars
字号:
{ tree := { tree = ClassBodyDeclaration:tree; tree->\field.next = ClassBodyDeclarations:tree; }; } . = ClassBodyDeclarations ';' .> .ClassBodyDeclaration = < ClassMemberDeclaration = < = FieldDeclaration . = MethodDeclaration . > . = ClassDeclaration . = InterfaceDeclaration . = ClassInitializer . = ConstructorDeclaration .> .get_type_1 = { => { current_attr = PAF_PRIVATE; current_type = $0.Type.tree; }; } .get_type_2 = { => { current_attr = $-1.Modifiers.attr; if ((current_attr & (PAF_PRIVATE | PAF_PROTECTED | PAF_PUBLIC)) == 0L) current_attr |= PAF_PRIVATE; current_type = $0.Type.tree; }; } .FieldDeclaration = < = Type get_type_1 VariableDeclarators ';' { tree := mvar_decl (NoTree, 0L, Type:tree, VariableDeclarators:tree); } . = Modifiers Type get_type_2 VariableDeclarators ';' { tree := mvar_decl (NoTree, Modifiers:attr, Type:tree, VariableDeclarators:tree); } .> .VariableDeclarators = < = VariableDeclarator { tree := { tree = VariableDeclarator:tree; tree->variable.next = dnodecl; }; } . = VariableDeclarators ',' VariableDeclarator { tree := { tree = VariableDeclarator:tree; tree->variable.next = VariableDeclarators:tree; }; } .> .VariableDeclarator = id: VariableDeclaratorId VariableInitializerOpt { => { if (hl >= 0) { current_ident = GetCStr (id:ident); put_symbol (PAF_MBR_VAR_DEF, current_class, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) id:Position.Line, (int) (id:Position.Column + LengthSt (GetStringRef (id:ident)) - 1), current_attr, NIL, NIL, NIL, NIL, 0, 0, 0, 0); } }; tree := mvariable (NoTree, current_attr, current_type, id:ident, id:Position, id:tree, VariableInitializerOpt:tree); } .VariableDeclaratorId = < = Identifier { tree := dnotype; } . = VariableDeclaratorId '[' ']' { tree := marray_type (VariableDeclaratorId:tree); Position := VariableDeclaratorId:Position; } .> .LocalVariableDeclaration = < = Type { => { current_attr = 0L; current_type = Type:tree; }; } LocalVariableDeclarators { tree := mvar_decl_stmt (Type:tree, ReverseTree (LocalVariableDeclarators:tree)); } . = final Type { => { current_attr = a_FINAL; current_type = Type:tree; }; } LocalVariableDeclarators { tree := mvar_decl_stmt (Type:tree, ReverseTree (LocalVariableDeclarators:tree)); } .> .LocalVariableDeclarators = < = LocalVariableDeclarator { tree := { tree = LocalVariableDeclarator:tree; tree->variable.next = dnodecl; }; } . = LocalVariableDeclarators ',' LocalVariableDeclarator { tree := { tree = LocalVariableDeclarator:tree; tree->variable.next = LocalVariableDeclarators:tree; }; } .> .LocalVariableDeclarator = id: VariableDeclaratorId VariableInitializerOpt { => { if (hl >= 0) { current_ident = GetCStr (id:ident); put_symbol (PAF_LOCAL_VAR_DEF, NIL, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) id:Position.Line, (int) (id:Position.Column + LengthSt (GetStringRef (id:ident)) - 1), 0L, NIL, NIL, NIL, NIL, 0, 0, 0, 0); } }; tree := mvariable (NoTree, current_attr, current_type, id:ident, id:Position, id:tree, VariableInitializerOpt:tree); } .MethodDeclaration = MethodHeader MethodBody { => { if (hl >= 0) { current_ident = GetCStr (MethodHeader:ident); to_types (MethodHeader:type, ret_buffer); to_types (MethodHeader:tree, arg_types_buffer); to_names (MethodHeader:tree, args_buffer); current_attr = MethodHeader:attr; if ((current_attr & (PAF_PRIVATE | PAF_PROTECTED | PAF_PUBLIC)) == 0L) current_attr |= PAF_PRIVATE; put_symbol (PAF_MBR_FUNC_DEF, current_class, current_ident, current_file, (int) MethodHeader:Position.Line, (int) MethodHeader:Position.Column - 1, (int) MethodBody:epos.Line, (int) MethodBody:epos.Column, current_attr, ret_buffer, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); put_symbol (PAF_MBR_FUNC_DCL, current_class, current_ident, current_file, (int) MethodHeader:Position.Line, (int) MethodHeader:Position.Column - 1, (int) MethodBody:epos.Line, (int) MethodBody:epos.Column, current_attr, ret_buffer, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); } }; tree := mmethod (NoTree, MethodHeader:attr, MethodHeader:ident, MethodHeader:Position, MethodHeader:tree, MethodHeader:throws, MethodBody:tree, MethodHeader:type, MethodHeader:array); } .MethodHeader = < = Type get_type_1 MethodDeclarator ThrowsOpt { tree := MethodDeclarator:tree; attr := 0L; type := Type:tree; throws := ThrowsOpt:tree; Position := MethodDeclarator:Position; } . = Modifiers Type get_type_2 MethodDeclarator ThrowsOpt { tree := MethodDeclarator:tree; type := Type:tree; throws := ThrowsOpt:tree; Position := MethodDeclarator:Position; } .> .MethodDeclarator = < = Identifier '(' FormalParameterListOpt ')' { array := dnotype; Position := Identifier:Position; } . = MethodDeclarator '[' ']' { array := marray_type (MethodDeclarator:array); Position := MethodDeclarator:Position; } .> .MethodBody = < = Block . = ';' { epos := ';':Position; tree := mnull_stmt (); } .> .FormalParameterListOpt = < = { tree := dnodecl; } . = FormalParameterList { tree := ReverseTree (FormalParameterList:tree); } .> .FormalParameterList = < = FormalParameter { tree := { tree = FormalParameter:tree; tree->\parameter.next = dnodecl; }; } . = FormalParameterList ',' FormalParameter { tree := { tree = FormalParameter:tree; tree->\parameter.next = FormalParameterList:tree; }; } .> .FormalParameter = < = Type id: VariableDeclaratorId { tree := mparameter (NoTree, 0L, Type:tree, id:ident, id:Position, id:tree); } . = final Type id: VariableDeclaratorId { tree := mparameter (NoTree, PAF_FINAL, Type:tree, id:ident, id:Position, id:tree); } .> .ThrowsOpt = < = { tree := dnotype_name; } . = throws ClassTypeList { tree := ReverseTree (ClassTypeList:tree); } .> .ClassTypeList = < = ClassType { tree := mtype_name (dnotype_name, ClassType:tree); } . = ClassTypeList ',' ClassType { tree := mtype_name (ClassTypeList:tree, ClassType:tree); } .> .ClassInitializer = < = Block { tree := minitializer (NoTree, Block:tree); } . = static Block { tree := mstatic_initializer (NoTree, Block:tree); } .> .ConstructorDeclaration = < = id: ConstructorDeclarator ThrowsOpt ConstructorBody { => { if (hl >= 0) { current_ident = GetCStr (id:ident); to_types (id:tree, arg_types_buffer); to_names (id:tree, args_buffer); current_attr = PAF_PRIVATE; put_symbol (PAF_MBR_FUNC_DEF, current_class, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) ConstructorBody:epos.Line, (int) ConstructorBody:epos.Column, current_attr | PAF_CONSTRUCTOR, NIL, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); put_symbol (PAF_MBR_FUNC_DCL, current_class, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) ConstructorBody:epos.Line, (int) ConstructorBody:epos.Column, current_attr | PAF_CONSTRUCTOR, NIL, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); } }; tree := mconstructor (NoTree, 0L, id:ident, id:Position, id:tree, ThrowsOpt:tree, mcompound_stmt (ConstructorBody:tree)); } . = Modifiers id: ConstructorDeclarator ThrowsOpt ConstructorBody { => { if (hl >= 0) { current_ident = GetCStr (id:ident); to_types (id:tree, arg_types_buffer); to_names (id:tree, args_buffer); current_attr = Modifiers:attr; if ((current_attr & (PAF_PRIVATE | PAF_PROTECTED | PAF_PUBLIC)) == 0L) current_attr |= PAF_PRIVATE; put_symbol (PAF_MBR_FUNC_DEF, current_class, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) ConstructorBody:epos.Line, (int) ConstructorBody:epos.Column, current_attr | PAF_CONSTRUCTOR, NIL, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); put_symbol (PAF_MBR_FUNC_DCL, current_class, current_ident, current_file, (int) id:Position.Line, (int) id:Position.Column - 1, (int) ConstructorBody:epos.Line, (int) ConstructorBody:epos.Column, current_attr | PAF_CONSTRUCTOR, NIL, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); } }; tree := mconstructor (NoTree, Modifiers:attr, id:ident, id:Position, id:tree, ThrowsOpt:tree, mcompound_stmt (ConstructorBody:tree)); } .> .ConstructorDeclarator = SimpleName: Identifier '(' FormalParameterListOpt ')' { Position := SimpleName:Position; } .ConstructorBody = < = '{' '}' { tree := dnostatement; epos := '}':Position; } . = '{' BlockStatements '}' { tree := ReverseTree (BlockStatements:tree); epos := '}':Position; } . = '{' ExplicitConstructorInvocation '}' { tree := { tree = ExplicitConstructorInvocation:tree; tree->statement.next = dnostatement; }; epos := '}':Position; } . = '{' ExplicitConstructorInvocation BlockStatements '}' { tree := { tree = ExplicitConstructorInvocation:tree; tree->statement.next = ReverseTree (BlockStatements:tree); }; epos := '}':Position; } .> .ExplicitConstructorInvocation = < = super '(' ArgumentListOpt ')' ';' { tree := mstatement (dnostatement, mexpression_stmt (mcall ('(':Position, msuper (super:Position), ArgumentListOpt:tree))); } . = this '(' ArgumentListOpt ')' ';' { tree := mstatement (dnostatement, mexpression_stmt (mcall ('(':Position, mthis (this:Position), ArgumentListOpt:tree))); } .> .InterfaceDeclaration = < = interface Identifier { => if (hl >= 0) push (Identifier:ident); } ExtendsInterfacesOpt InterfaceBody { => { if (hl >= 0) { current_attr = PAF_PRIVATE; put_symbol (PAF_CLASS_DEF, top (), current_class, current_file, (int) Identifier:Position.Line, (int) Identifier:Position.Column - 1, (int) InterfaceBody:epos.Line, (int) InterfaceBody:epos.Column, current_attr | PAF_INTERFACE, NIL, NIL, NIL, NIL, 0, 0, 0, 0); pop (); } }; tree := minterface (NoTree, 0L, Identifier:ident, Identifier:Position, InterfaceBody:tree, ExtendsInterfacesOpt:tree); } . = Modifiers interface Identifier { => if (hl >= 0) push (Identifier:ident); } ExtendsInterfacesOpt InterfaceBody { => { if (hl >= 0) { current_attr = Modifiers:attr; if ((current_attr & (PAF_PRIVATE | PAF_PROTECTED | PAF_PUBLIC)) == 0L) current_attr |= PAF_PRIVATE; put_symbol (PAF_CLASS_DEF, top (), current_class, current_file, (int) Identifier:Position.Line, (int) Identifier:Position.Column - 1, (int) InterfaceBody:epos.Line, (int) InterfaceBody:epos.Column, current_attr | PAF_INTERFACE, NIL, NIL, NIL, NIL, 0, 0, 0, 0); pop (); } }; tree := minterface (NoTree, Modifiers:attr, Identifier:ident, Identifier:Position, InterfaceBody:tree, ExtendsInterfacesOpt:tree); } .> .ExtendsInterfacesOpt = < = { tree := dnotype_name; } . = extends ExtendsInterfaces { tree := ReverseTree (ExtendsInterfaces:tree); => { if (hl >= 0) put_extends (tree); }; } .> .ExtendsInterfaces = < = InterfaceType { tree := mtype_name (dnotype_name, InterfaceType:tree); } . = ExtendsInterfaces ',' InterfaceType { tree := mtype_name (ExtendsInterfaces:tree, InterfaceType:tree); } .> .InterfaceBody = '{' InterfaceMemberDeclarations '}' { tree := ReverseTree (InterfaceMemberDeclarations:tree); epos := '}':Position; } .InterfaceMemberDeclarations = < = { tree := dnofield; } . = InterfaceMemberDeclarations InterfaceMemberDeclaration { tree := { tree = InterfaceMemberDeclaration:tree; tree->field.next = InterfaceMemberDeclarations:tree; }; } .> .InterfaceMemberDeclaration = < ConstantDeclaration = FieldDeclaration . AbstractMethodDeclaration = MethodHeader ';' { => { if (hl >= 0) { current_ident = GetCStr (MethodHeader:ident); to_types (MethodHeader:type, ret_buffer); to_types (MethodHeader:tree, arg_types_buffer); to_names (MethodHeader:tree, args_buffer); put_symbol (PAF_MBR_FUNC_DEF, current_class, current_ident, current_file, (int) MethodHeader:Position.Line, (int) MethodHeader:Position.Column - 1, (int) ';':Position.Line, (int) ';':Position.Column, current_attr, ret_buffer, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); put_symbol (PAF_MBR_FUNC_DCL, current_class, current_ident, current_file, (int) MethodHeader:Position.Line, (int) MethodHeader:Position.Column - 1, (int) ';':Position.Line, (int) ';':Position.Column, current_attr, ret_buffer, arg_types_buffer, args_buffer, NIL, 0, 0, 0, 0); } }; tree := mmethod (NoTree, MethodHeader:attr, MethodHeader:ident, MethodHeader:Position, MethodHeader:tree, MethodHeader:throws, dnostatement, MethodHeader:type, MethodHeader:array); } . = ClassDeclaration . = InterfaceDeclaration .> .VariableInitializerOpt = < = { tree := dnoexpression; } . = '=' VariableInitializer .> .VariableInitializer = < = Expression . ArrayInitializer = '{' VariableInitializersOpt '}' { tree := maggregate ('{':Position, VariableInitializersOpt:tree); } .> .VariableInitializersOpt = < = CommaOpt { tree := dnoexpression_l; } . = VariableInitializers CommaOpt { tree := ReverseTree (VariableInitializers:tree); } .> .VariableInitializers = < = VariableInitializer { tree := mexpression (dnoexpression_l, VariableInitializer:tree); } . = VariableInitializers ',' VariableInitializer { tree := mexpression (VariableInitializers:tree, VariableInitializer:tree); } .> .CommaOpt = < = . = ',' .> .ArrayInitializerOpt = < = { tree := dnoexpression; } . = ArrayInitializer .> .Block = < = '{' '}' { tree := mcompound_stmt (dnostatement); epos := '}':Position; } . = '{' BlockStatements '}' { tree := mcompound_stmt (ReverseTree (BlockStatements:tree)); epos := '}':Position; } .> .BlockStatements = < = BlockStatement { tree := mstatement (dnostatement, BlockStatement:tree); } . = BlockStatements BlockStatement { tree := mstatement (BlockStatements:tree, BlockStatement:tree); } .> .BlockStatement = < LocalVariableDeclarationStatement = LocalVariableDeclaration ';' . = ClassDeclaration { tree := { tree = mtype_decl_stmt (ClassDeclaration:tree); ClassDeclaration:tree->type_decl.next = dnofield; }; } . = InterfaceDeclaration { tree := { tree = mtype_decl_stmt (InterfaceDeclaration:tree); InterfaceDeclaration:tree->type_decl.next = dnofield; }; } . Statement = < = StatementWithoutTrailingSubstatement . LabeledStatement = Identifier ':' Statement { tree := mlabeled_stmt (Identifier:ident, Identifier:Position, Statement:tree); } . IfThenStatement = if '(' Expression ')' Statement { tree := mif_stmt (Expression:tree, Statement:tree); } . IfThenElseStatement = if '(' Expression ')' StatementNoShortIf else s2: Statement { tree := mif_else_stmt (Expression:tree, StatementNoShortIf:tree, s2: tree); } . WhileStatement = while '(' Expression ')' Statement { tree := mwhile_stmt (Expression:tree, Statement:tree); } . ForStatement = for '(' ForInit ';' ExpressionOpt ';' ForUpdate ')' Statement { tree := mfor_stmt (ForInit:tree, ExpressionOpt:tree, ForUpdate:tree, Statement:tree); } . > .> .StatementNoShortIf = < = StatementWithoutTrailingSubstatement . LabeledStatementNoShortIf = Identifier ':' StatementNoShortIf { tree := mlabeled_stmt (Identifier:ident, Identifier:Position, StatementNoShortIf:tree); } . IfThenElseStatementNoShortIf = if '(' Expression ')' StatementNoShortIf else s2: StatementNoShortIf { tree := mif_else_stmt (Expression:tree, StatementNoShortIf:tree, s2: tree); } . WhileStatementNoShortIf = while '(' Expression ')' StatementNoShortIf { tree := mwhile_stmt (Expression:tree, StatementNoShortIf:tree); } . ForStatementNoShortIf= for '(' ForInit ';' ExpressionOpt ';' ForUpdate ')' StatementNoShortIf { tree := mfor_stmt (ForInit:tree, ExpressionOpt:tree, ForUpdate:tree, StatementNoShortIf:tree); } .> .StatementWithoutTrailingSubstatement = < = Block . EmtpyStatement = ';' { tree := mnull_stmt (); } . ExpressionStatement = StatementExpression ';' { tree := mexpression_stmt (StatementExpression:tree); } . SwitchStatement = switch '(' Expression ')' SwitchBlock { tree := mswitch_stmt (Expression:tree, SwitchBlock:tree); } . DoStatement = do Statement while '(' Expression ')' ';' { tree := mdo_stmt (Statement:tree, Expression:tree); } . BreakStatement = < = break ';' { tree := mbreak_stmt (); } . = break Identifier ';' { tree := mbreak_id_stmt (mident (Identifier:Position, Identifier:ident)); } . > . ContinueStatement = < = continue ';' { tree := mcontinue_stmt (); } . = continue Identifier ';' { tree := mcontinue_id_stmt (mident (Identifier:Position, Identifier:ident)); } . > . ReturnStatement = < = return ';' { tree := mreturn_stmt (); } . = return Expression ';' { tree := mreturn_expr_stmt (Expression:tree); } . > . ThrowStatement = throw Expression ';' { tree := mthrow_stmt (Expression:tree); } . SynchronizedStatement= synchronized '(' Expression ')' Block { tree := msynchronized_stmt (Expression:tree, Block:tree); } . TryStatement = < = try Block Catches { tree := mtry_stmt (Block:tree, ReverseTree (Catches:tree), mnull_stmt ()); } . = try Block CatchesOpt Finally { tree := mtry_stmt (Block:tree, CatchesOpt:tree, Finally:tree); } . > .> .StatementExpression = < = Assignment . = '++' cExpression { tree := munary ('++':Position, cExpression:tree, pre_incr); } . = '--' cExpression { tree := munary ('--':Position, cExpression:tree, pre_decr); } . = cExpression '++' PREC POST_OP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -