From 73e40e9c787ae12b1c09a649c9bf999fdab46c6a Mon Sep 17 00:00:00 2001 From: grammarware Date: Tue, 9 Sep 2008 17:57:44 +0000 Subject: [PATCH] starting a Java initiative similar to the FL one git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@240 ab42f6e0-554d-0410-b580-99e487e6eeb2 --- topics/fl/lci/fl.lcf | 15 +- topics/java/Makefile | 9 + topics/java/jls1/syntax.html | 875 +++++++++++++++++++++++++++++++++++ topics/java/jls2/Makefile | 6 + topics/java/jls2/syntax.html | 399 ++++++++++++++++ topics/java/jls3/Makefile | 6 + topics/java/jls3/syntax.html | 541 ++++++++++++++++++++++ 7 files changed, 1845 insertions(+), 6 deletions(-) create mode 100644 topics/java/Makefile create mode 100644 topics/java/jls1/syntax.html create mode 100644 topics/java/jls2/Makefile create mode 100644 topics/java/jls2/syntax.html create mode 100644 topics/java/jls3/Makefile create mode 100644 topics/java/jls3/syntax.html diff --git a/topics/fl/lci/fl.lcf b/topics/fl/lci/fl.lcf index 9c0bbe9f..676164cc 100644 --- a/topics/fl/lci/fl.lcf +++ b/topics/fl/lci/fl.lcf @@ -17,7 +17,7 @@ slps/shared/tools - + wrappers @@ -68,7 +68,7 @@ tools/ldf2set fl/ldf/fl.ldf - + antlr @@ -121,7 +121,10 @@ tools/asfix2btf bgf/sdf.bgf - + + + wrappers/runbtfevaluator + codesamples @@ -169,7 +172,7 @@ - - + java @@ -248,4 +251,4 @@ - + \ No newline at end of file diff --git a/topics/java/Makefile b/topics/java/Makefile new file mode 100644 index 00000000..8cc3c4f5 --- /dev/null +++ b/topics/java/Makefile @@ -0,0 +1,9 @@ +all: + @echo Run 'make rebuild' if you want to renew the sources from their URLs. + @echo NOT recommended UNLESS you really know what you are doing! + +rebuild: + curl -k http://java.sun.com/docs/books/jls/first_edition/html/19.doc.html > jls1/syntax.html + curl -k http://java.sun.com/docs/books/jls/second_edition/html/syntax.doc.html > jls2/syntax.html + curl -k http://java.sun.com/docs/books/jls/third_edition/html/syntax.html > jls3/syntax.html + diff --git a/topics/java/jls1/syntax.html b/topics/java/jls1/syntax.html new file mode 100644 index 00000000..520875a5 --- /dev/null +++ b/topics/java/jls1/syntax.html @@ -0,0 +1,875 @@ + + + + +The Java Language Specification + LALR(1) Grammar + + + + + + +
Contents | Prev | Next | IndexJava Language Specification
+First Edition
+

+ + +

+CHAPTER + 19

+ +

LALR(1) Grammar

+

+ +This chapter presents a grammar for Java. The grammar has been mechanically +checked to insure that it is LALR(1). +

+The grammar for Java presented piecemeal in the preceding chapters is much better for exposition, but it cannot be parsed left-to-right with one token of lookahead because of certain syntactic peculiarities, some of them inherited from C and C++. These problems and the solutions adopted for the LALR(1) grammar are presented below, followed by the grammar itself.

+ +

19.1 Grammatical Difficulties

+ +There are five problems with the grammar presented in preceding chapters. +

+

19.1.1 Problem #1: Names Too Specific

+ +Consider the two groups of productions: +

    +PackageName:
    +
    Identifier
    +
    PackageName . Identifier + +TypeName:
    +
    Identifier
    +
    PackageName . Identifier +
+and: +

    +MethodName:
    +
    Identifier
    +
    AmbiguousName . Identifier + +AmbiguousName:
    +
    Identifier
    +
    AmbiguousName . Identifier +
+Now consider the partial input: +

class Problem1 { int m() { hayden.
+
+When the parser is considering the token hayden, with one-token lookahead to +symbol ".", it cannot yet tell whether hayden should be a PackageName that +qualifies a type name, as in: +

hayden.Dinosaur rex = new hayden.Dinosaur(2);
+
+or an AmbiguousName that qualifies a method name, as in: +

hayden.print("Dinosaur Rex!");
+
+Therefore, the productions shown above result in a grammar that is not LALR(1). +There are also other problems with drawing distinctions among different kinds of +names in the grammar. +

+The solution is to eliminate the nonterminals PackageName, TypeName, ExpressionName, MethodName, and AmbiguousName, replacing them all with a single nonterminal Name:

+

    +Name:
    + SimpleName
    + QualifiedName +
    +SimpleName:
    + Identifier +
    +QualifiedName:
    + Name
    . Identifier +
+A later stage of compiler analysis then sorts out the precise role of each name or +name qualifier. +

+For related reasons, these productions in §4.3:

+

    +ClassOrInterfaceType:
    +
    ClassType
    +
    InterfaceType + +ClassType:
    +
    TypeName + +InterfaceType:
    +
    TypeName +
+were changed to: +

    +ClassOrInterfaceType:
    +
    Name + +ClassType:
    +
    ClassOrInterfaceType + +InterfaceType:
    +
    ClassOrInterfaceType +
+

19.1.2 Problem #2: Modifiers Too Specific

+ +Consider the two groups of productions: +

    +FieldDeclaration:
    + FieldModifiers
    opt Type VariableDeclarators ; + +FieldModifiers:
    +
    FieldModifier
    +
    FieldModifiers FieldModifier + +FieldModifier: one of
    +
    public protected private
    + final static transient volatile +
+and: +

    +MethodHeader:
    +
    MethodModifiersopt ResultType MethodDeclarator Throwsopt + +MethodModifiers:
    +
    MethodModifier
    +
    MethodModifiers MethodModifier + +MethodModifier: one of
    +
    public protected private
    + static
    + abstract final native synchronized +
+Now consider the partial input: +

class Problem2 { public static int
+
+When the parser is considering the token static, with one-token lookahead to +symbol int-or, worse yet, considering the token public with lookahead to +static-it cannot yet tell whether this will be a field declaration such as: +

public static int maddie = 0;
+
+or a method declaration such as: +

public static int maddie(String art) { return art.length(); }
+
+Therefore, the parser cannot tell with only one-token lookahead whether static +(or, similarly, public) should be reduced to FieldModifier or MethodModifier. +Therefore, the productions shown above result in a grammar that is not LALR(1). +There are also other problems with drawing distinctions among different kinds of +modifiers in the grammar. +

+While not all contexts provoke the problem, the simplest solution is to combine all contexts in which such modifiers are used, eliminating all six of the nonterminals ClassModifiers (§8.1.2), FieldModifiers (§8.3.1), MethodModifiers (§8.4.3), ConstructorModifiers (§8.6.3), InterfaceModifiers (§9.1.2), and ConstantModifiers (§9.3) from the grammar, replacing them all with a single nonterminal Modifiers:

+

    +Modifiers:
    + Modifier
    + Modifiers
    Modifier + +Modifier: one of
    +
    public protected private
    + static
    + abstract final native synchronized transient volatile +
+A later stage of compiler analysis then sorts out the precise role of each modifier +and whether it is permitted in a given context. +

+

19.1.3 Problem #3: Field Declaration versus Method Declaration

+ +Consider the two productions (shown after problem #2 has been corrected): +

    +FieldDeclaration:
    + Modifiers
    opt Type VariableDeclarators ; +
+and: +

    +MethodHeader:
    +
    Modifiersopt ResultType MethodDeclarator Throwsopt +
+where ResultType is defined as: +

    +ResultType:
    +
    Type
    +
    void +
+Now consider the partial input: +

class Problem3 { int julie
+
+Note that, in this simple example, no Modifiers are present. When the parser is +considering the token int, with one-token lookahead to symbol julie, it cannot +yet tell whether this will be a field declaration such as: +

int julie = 14;
+
+or a method declaration such as: +

int julie(String art) { return art.length(); }
+
+Therefore, after the parser reduces int to the nonterminal Type, it cannot tell with +only one-token lookahead whether Type should be further reduced to ResultType +(for a method declaration) or left alone (for a field declaration). Therefore, the +productions shown above result in a grammar that is not LALR(1). +

+The solution is to eliminate the ResultType production and to have separate alternatives for MethodHeader:

+

    +MethodHeader:
    +
    Modifiersopt Type MethodDeclarator Throwsopt
    +
    Modifiersopt void MethodDeclarator Throwsopt +
+This allows the parser to reduce int to Type and then leave it as is, delaying the decision as to whether a field declaration or method declaration is in progress.

+ +

19.1.4 Problem #4: Array Type versus Array Access

+ +Consider the productions (shown after problem #1 has been corrected): +

    +ArrayType:
    +
    Type [ ] +
+and: +

    +ArrayAccess:
    +
    Name [ Expression ]
    +
    PrimaryNoNewArray [ Expression ] +
+Now consider the partial input: +

class Problem4 { Problem4() { peter[
+
+When the parser is considering the token peter, with one-token lookahead to +symbol [, it cannot yet tell whether peter will be part of a type name, as in: +

peter[] team;
+
+or part of an array access, as in: +

peter[3] = 12;
+
+Therefore, after the parser reduces peter to the nonterminal Name, it cannot tell +with only one-token lookahead whether Name should be reduced ultimately to +Type (for an array type) or left alone (for an array access). Therefore, the productions +shown above result in a grammar that is not LALR(1). +

+The solution is to have separate alternatives for ArrayType:

+

    +ArrayType:
    +
    PrimitiveType [ ]
    +
    Name [ ]
    +
    ArrayType [ ] +
+This allows the parser to reduce peter to Name and then leave it as is, delaying +the decision as to whether an array type or array access is in progress. +

+

19.1.5 Problem #5: Cast versus Parenthesized Expression

+ +Consider the production: +

    +CastExpression:
    +
    ( PrimitiveType ) UnaryExpression
    +
    ( ReferenceType ) UnaryExpressionNotPlusMinus +
+Now consider the partial input: +

class Problem5 { Problem5() { super((matthew)
+
+When the parser is considering the token matthew, with one-token lookahead to +symbol ), it cannot yet tell whether (matthew) will be a parenthesized expression, +as in: +

super((matthew), 9);
+
+or a cast, as in: +

super((matthew)baz, 9);
+
+Therefore, after the parser reduces matthew to the nonterminal Name, it cannot +tell with only one-token lookahead whether Name should be further reduced to +PostfixExpression and ultimately to Expression (for a parenthesized expression) or +to ClassOrInterfaceType and then to ReferenceType (for a cast). Therefore, the +productions shown above result in a grammar that is not LALR(1). +

+The solution is to eliminate the use of the nonterminal ReferenceType in the definition of CastExpression, which requires some reworking of both alternatives to avoid other ambiguities:

+

    +CastExpression:
    +
    ( PrimitiveType Dimsopt ) UnaryExpression
    +
    ( Expression ) UnaryExpressionNotPlusMinus
    +
    ( Name Dims ) UnaryExpressionNotPlusMinus +
+This allows the parser to reduce matthew to Expression and then leave it there, +delaying the decision as to whether a parenthesized expression or a cast is in +progress. Inappropriate variants such as: +

(int[])+3
+
+and: +

(matthew+1)baz
+
+must then be weeded out and rejected by a later stage of compiler analysis. +

+The remaining sections of this chapter constitute a LALR(1) grammar for Java syntax, in which the five problems described above have been solved.

+ +

19.2 Productions from §2.3: The Syntactic Grammar

+
    +Goal:
    +
    CompilationUnit +
+

19.3 Productions from §3: Lexical Structure

+
    +Literal:
    +
    IntegerLiteral
    +
    FloatingPointLiteral
    +
    BooleanLiteral
    +
    CharacterLiteral
    +
    StringLiteral
    +
    NullLiteral +
+

19.4 Productions from §4: Types, Values, and Variables

+
    +Type:
    +
    PrimitiveType
    +
    ReferenceType + +PrimitiveType:
    + NumericType
    +
    boolean + +NumericType:
    +
    IntegralType
    +
    FloatingPointType + +IntegralType: one of
    +
    byte short int long char + +FloatingPointType: one of
    +
    float double + +ReferenceType:
    +
    ClassOrInterfaceType
    +
    ArrayType + +ClassOrInterfaceType:
    + Name + +ClassType:
    +
    ClassOrInterfaceType + +InterfaceType:
    +
    ClassOrInterfaceType + +ArrayType:
    +
    PrimitiveType [ ]
    +
    Name [ ]
    +
    ArrayType [ ] +
+

19.5 Productions from §6: Names

+
    +Name:
    + SimpleName
    + QualifiedName +
    +SimpleName:
    + Identifier +
    +QualifiedName:
    + Name
    . Identifier +
+

19.6 Productions from §7: Packages

+
    +CompilationUnit:
    + PackageDeclaration
    opt ImportDeclarationsopt TypeDeclarationsopt + +ImportDeclarations:
    +
    ImportDeclaration
    +
    ImportDeclarations ImportDeclaration + +TypeDeclarations:
    +
    TypeDeclaration
    +
    TypeDeclarations TypeDeclaration + +PackageDeclaration:
    +
    package Name ; + +ImportDeclaration:
    +
    SingleTypeImportDeclaration
    +
    TypeImportOnDemandDeclaration + +SingleTypeImportDeclaration:
    +
    import Name ; + +TypeImportOnDemandDeclaration:
    +
    import Name . * ; + +TypeDeclaration:
    +
    ClassDeclaration
    +
    InterfaceDeclaration
    +
    ; +
+

19.7 Productions Used Only in the LALR(1) Grammar

+
    +Modifiers:
    + Modifier
    + Modifiers
    Modifier + +Modifier: one of
    +
    public protected private
    + static
    + abstract final native synchronized transient volatile +
+

19.8 Productions from §8: Classes

+ +

19.8.1 Productions from §8.1: Class Declaration

+
    +ClassDeclaration:
    +
    Modifiersopt class Identifier Superopt Interfacesopt ClassBody + +Super:
    +
    extends ClassType + +Interfaces:
    +
    implements InterfaceTypeList + +InterfaceTypeList:
    +
    InterfaceType
    +
    InterfaceTypeList , InterfaceType + +ClassBody:
    +
    { ClassBodyDeclarationsopt } + +ClassBodyDeclarations:
    +
    ClassBodyDeclaration
    +
    ClassBodyDeclarations ClassBodyDeclaration + +ClassBodyDeclaration:
    + ClassMemberDeclaration
    + StaticInitializer
    + ConstructorDeclaration +
    +ClassMemberDeclaration:
    + FieldDeclaration
    +
    MethodDeclaration +
+

19.8.2 Productions from §8.3: Field Declarations

+
    +FieldDeclaration:
    + Modifiers
    opt Type VariableDeclarators ; + +VariableDeclarators:
    +
    VariableDeclarator
    +
    VariableDeclarators , VariableDeclarator + +VariableDeclarator:
    +
    VariableDeclaratorId
    +
    VariableDeclaratorId = VariableInitializer + +VariableDeclaratorId:
    +
    Identifier
    +
    VariableDeclaratorId [ ] + +VariableInitializer:
    +
    Expression
    +
    ArrayInitializer +
+

19.8.3 Productions from §8.4: Method Declarations

+
    +MethodDeclaration:
    +
    MethodHeader MethodBody + +MethodHeader:
    +
    Modifiersopt Type MethodDeclarator Throwsopt
    +
    Modifiersopt void MethodDeclarator Throwsopt + +MethodDeclarator:
    +
    Identifier ( FormalParameterListopt )
    +
    MethodDeclarator [ ] + +FormalParameterList:
    +
    FormalParameter
    +
    FormalParameterList , FormalParameter + +FormalParameter:
    +
    Type VariableDeclaratorId + +Throws:
    +
    throws ClassTypeList + +ClassTypeList:
    +
    ClassType
    +
    ClassTypeList , ClassType + +MethodBody:
    + Block

    + ; +
+

19.8.4 Productions from §8.5: Static Initializers

+
    +StaticInitializer:
    +
    static Block +
+

19.8.5 Productions from §8.6: Constructor Declarations

+
    +ConstructorDeclaration:
    + Modifiers
    opt ConstructorDeclarator Throwsopt ConstructorBody + +ConstructorDeclarator:
    +
    SimpleName ( FormalParameterListopt ) + +ConstructorBody:
    +
    { ExplicitConstructorInvocationopt BlockStatementsopt } + +ExplicitConstructorInvocation:
    +
    this ( ArgumentListopt ) ;
    +
    super ( ArgumentListopt ) ; +
+

19.9 Productions from §9: Interfaces

+ +

19.9.1 Productions from §9.1: Interface Declarations

+
    +InterfaceDeclaration:
    +
    Modifiersopt interface Identifier ExtendsInterfacesopt InterfaceBody + +ExtendsInterfaces:
    +
    extends InterfaceType
    +
    ExtendsInterfaces , InterfaceType + +InterfaceBody:
    + { InterfaceMemberDeclarationsopt } + +InterfaceMemberDeclarations:
    +
    InterfaceMemberDeclaration
    +
    InterfaceMemberDeclarations InterfaceMemberDeclaration + +InterfaceMemberDeclaration:
    +
    ConstantDeclaration
    +
    AbstractMethodDeclaration + +ConstantDeclaration:
    +
    FieldDeclaration + +AbstractMethodDeclaration:
    +
    MethodHeader ; +
+

19.10 Productions from §10: Arrays

+
    +ArrayInitializer:
    +
    { VariableInitializersopt ,opt } + +VariableInitializers:
    +
    VariableInitializer
    +
    VariableInitializers , VariableInitializer +
+

19.11 Productions from §14: Blocks and Statements

+
    +Block:
    +
    { BlockStatementsopt } + +BlockStatements:
    +
    BlockStatement
    +
    BlockStatements BlockStatement + +BlockStatement:
    +
    LocalVariableDeclarationStatement
    +
    Statement + +LocalVariableDeclarationStatement:
    +
    LocalVariableDeclaration ; + +LocalVariableDeclaration:
    +
    Type VariableDeclarators + +Statement:
    +
    StatementWithoutTrailingSubstatement
    +
    LabeledStatement
    +
    IfThenStatement
    +
    IfThenElseStatement
    +
    WhileStatement
    +
    ForStatement + +StatementNoShortIf:
    +
    StatementWithoutTrailingSubstatement
    +
    LabeledStatementNoShortIf
    +
    IfThenElseStatementNoShortIf
    +
    WhileStatementNoShortIf
    +
    ForStatementNoShortIf + +StatementWithoutTrailingSubstatement:
    + Block
    + EmptyStatement
    + ExpressionStatement
    + SwitchStatement
    + DoStatement
    + BreakStatement
    + ContinueStatement
    + ReturnStatement
    + SynchronizedStatement
    + ThrowStatement
    + TryStatement +
    +EmptyStatement:
    +
    ; + +LabeledStatement:
    +
    Identifier : Statement + +LabeledStatementNoShortIf:
    +
    Identifier : StatementNoShortIf + +ExpressionStatement:
    +
    StatementExpression ; + +StatementExpression:
    +
    Assignment
    + PreIncrementExpression
    + PreDecrementExpression
    + PostIncrementExpression
    + PostDecrementExpression
    + MethodInvocation
    +
    ClassInstanceCreationExpression +
    +IfThenStatement:
    +
    if ( Expression ) Statement + +IfThenElseStatement:
    +
    if ( Expression ) StatementNoShortIf else Statement + +IfThenElseStatementNoShortIf:
    +
    if ( Expression ) StatementNoShortIf else StatementNoShortIf + +SwitchStatement:
    +
    switch ( Expression ) SwitchBlock + +SwitchBlock:
    +
    { SwitchBlockStatementGroupsopt SwitchLabelsopt } + +SwitchBlockStatementGroups:
    +
    SwitchBlockStatementGroup
    +
    SwitchBlockStatementGroups SwitchBlockStatementGroup + +SwitchBlockStatementGroup:
    +
    SwitchLabels BlockStatements + +SwitchLabels:
    +
    SwitchLabel
    +
    SwitchLabels SwitchLabel + +SwitchLabel:
    +
    case ConstantExpression :
    + default : +
    +WhileStatement:
    +
    while ( Expression ) Statement + +WhileStatementNoShortIf:
    +
    while ( Expression ) StatementNoShortIf + +DoStatement:
    +
    do Statement while ( Expression ) ; +
    +ForStatement:
    +
    for ( ForInitopt ; Expressionopt ; ForUpdateopt )
    +
    Statement + +ForStatementNoShortIf:
    +
    for ( ForInitopt ; Expressionopt ; ForUpdateopt )
    +
    StatementNoShortIf + +ForInit:
    +
    StatementExpressionList
    +
    LocalVariableDeclaration + +ForUpdate:
    +
    StatementExpressionList + +StatementExpressionList:
    +
    StatementExpression
    +
    StatementExpressionList , StatementExpression + +BreakStatement:
    +
    break Identifieropt ; + +ContinueStatement:
    +
    continue Identifieropt ; + +ReturnStatement:
    +
    return Expressionopt ; + +ThrowStatement:
    +
    throw Expression ; + +SynchronizedStatement:
    +
    synchronized ( Expression ) Block + +TryStatement:
    +
    try Block Catches
    +
    try Block Catchesopt Finally + +Catches:
    +
    CatchClause
    +
    Catches CatchClause + +CatchClause:
    +
    catch ( FormalParameter ) Block + +Finally:
    +
    finally Block +
+

19.12 Productions from §15: Expressions

+
    +Primary:
    +
    PrimaryNoNewArray
    +
    ArrayCreationExpression + +PrimaryNoNewArray:
    +
    Literal
    +
    this
    +
    ( Expression )
    +
    ClassInstanceCreationExpression
    +
    FieldAccess
    +
    MethodInvocation
    +
    ArrayAccess + +ClassInstanceCreationExpression:
    +
    new ClassType ( ArgumentListopt ) + +ArgumentList:
    +
    Expression
    +
    ArgumentList , Expression + +ArrayCreationExpression:
    +
    new PrimitiveType DimExprs Dimsopt
    +
    new ClassOrInterfaceType DimExprs Dimsopt + +DimExprs:
    +
    DimExpr
    +
    DimExprs DimExpr + +DimExpr:
    +
    [ Expression ] + +Dims:
    +
    [ ]
    +
    Dims [ ] + +FieldAccess:
    +
    Primary . Identifier
    +
    super . Identifier + +MethodInvocation:
    +
    Name ( ArgumentListopt )
    +
    Primary . Identifier ( ArgumentListopt )
    + super .
    Identifier ( ArgumentListopt ) + +ArrayAccess:
    +
    Name [ Expression ]
    +
    PrimaryNoNewArray [ Expression ] + +PostfixExpression:
    + Primary
    + Name
    +
    PostIncrementExpression
    + PostDecrementExpression +
    +PostIncrementExpression:
    +
    PostfixExpression ++ + +PostDecrementExpression:
    +
    PostfixExpression -- + +UnaryExpression:
    + PreIncrementExpression
    +
    PreDecrementExpression
    +
    + UnaryExpression
    +
    - UnaryExpression
    +
    UnaryExpressionNotPlusMinus + +PreIncrementExpression:
    +
    ++ UnaryExpression + +PreDecrementExpression:
    +
    -- UnaryExpression + +UnaryExpressionNotPlusMinus:
    + PostfixExpression
    +
    ~ UnaryExpression
    +
    ! UnaryExpression
    +
    CastExpression + +CastExpression:
    +
    ( PrimitiveType Dimsopt ) UnaryExpression
    +
    ( Expression ) UnaryExpressionNotPlusMinus
    +
    ( Name Dims ) UnaryExpressionNotPlusMinus + +MultiplicativeExpression:
    + UnaryExpression
    +
    MultiplicativeExpression * UnaryExpression
    +
    MultiplicativeExpression / UnaryExpression
    +
    MultiplicativeExpression % UnaryExpression + +AdditiveExpression:
    +
    MultiplicativeExpression
    +
    AdditiveExpression + MultiplicativeExpression
    +
    AdditiveExpression - MultiplicativeExpression + +ShiftExpression:
    +
    AdditiveExpression
    +
    ShiftExpression << AdditiveExpression
    +
    ShiftExpression >> AdditiveExpression
    +
    ShiftExpression >>> AdditiveExpression + +RelationalExpression:
    +
    ShiftExpression
    +
    RelationalExpression < ShiftExpression
    +
    RelationalExpression > ShiftExpression
    +
    RelationalExpression <= ShiftExpression
    +
    RelationalExpression >= ShiftExpression
    +
    RelationalExpression instanceof ReferenceType + +EqualityExpression:
    +
    RelationalExpression
    +
    EqualityExpression == RelationalExpression
    +
    EqualityExpression != RelationalExpression + +AndExpression:
    +
    EqualityExpression
    +
    AndExpression & EqualityExpression + +ExclusiveOrExpression:
    +
    AndExpression
    +
    ExclusiveOrExpression ^ AndExpression + +InclusiveOrExpression:
    +
    ExclusiveOrExpression
    +
    InclusiveOrExpression | ExclusiveOrExpression + +ConditionalAndExpression:
    +
    InclusiveOrExpression
    +
    ConditionalAndExpression && InclusiveOrExpression + +ConditionalOrExpression:
    +
    ConditionalAndExpression
    +
    ConditionalOrExpression || ConditionalAndExpression + +ConditionalExpression:
    +
    ConditionalOrExpression
    +
    ConditionalOrExpression ? Expression : ConditionalExpression + +AssignmentExpression:
    +
    ConditionalExpression
    +
    Assignment + +Assignment:
    +
    LeftHandSide AssignmentOperator AssignmentExpression + +LeftHandSide:
    +
    Name
    +
    FieldAccess
    +
    ArrayAccess + +AssignmentOperator: one of
    +
    = *= /= %= += -= <<= >>= >>>= &= ^= |= + +Expression:
    +
    AssignmentExpression + +ConstantExpression:
    +
    Expression +
+

+ + +


+ + + + +
Contents | Prev | Next | IndexJava Language Specification
+First Edition
+

+Java Language Specification (HTML generated by Suzette Pelouch on April 03, 1998)
+Copyright © 1996 Sun Microsystems, Inc. +All rights reserved +
+Please send any comments or corrections via our feedback form +
+ \ No newline at end of file diff --git a/topics/java/jls2/Makefile b/topics/java/jls2/Makefile new file mode 100644 index 00000000..b2540e77 --- /dev/null +++ b/topics/java/jls2/Makefile @@ -0,0 +1,6 @@ +all: + python ../../extraction/html2bgf/html2bgf.py syntax.html jls2.bgf + ../../../shared/tools/checkxml bgf jls2.bgf + +clean: + rm -f *.bgf diff --git a/topics/java/jls2/syntax.html b/topics/java/jls2/syntax.html new file mode 100644 index 00000000..dc242dc9 --- /dev/null +++ b/topics/java/jls2/syntax.html @@ -0,0 +1,399 @@ + + + Syntax + + + + + + + + +
Contents | Prev | Next | IndexJava Language Specification
+Second Edition
+



+ + +

+CHAPTER + 18

+ +

Syntax

+

+ +This chapter presents a grammar for the Java programming language.

+ +The grammar presented piecemeal in the preceding chapters is much better for exposition, but it is not ideally suited as a basis for a parser. The grammar presented in this chapter is the basis for the reference implementation.

+ +The grammar below uses the following BNF-style conventions:

+

    +
  • [x] denotes zero or one occurrences of x. + +
  • {x} denotes zero or more occurrences of x. + +
  • x | y means one of either x or y. +
+

18.1 The Grammar of the Java Programming Language

+
    +Identifier:
    +	IDENTIFIER
    +
    +QualifiedIdentifier:
    +	Identifier { . Identifier }
    +
    +Literal:
    +	IntegerLiteral 	
    +	FloatingPointLiteral 	
    +	CharacterLiteral 	
    +	StringLiteral 	
    +	BooleanLiteral
    +	NullLiteral
    +
    +Expression: 
    +	Expression1 [AssignmentOperator Expression1]]
    +
    +AssignmentOperator: 
    +	= 
    +	+= 
    +	-= 
    +	*= 
    +	/= 
    +	&= 
    +	|= 
    +	^= 
    +	%= 
    +	<<= 
    +	>>= 
    +	>>>= 
    +
    +Type: 
    +	Identifier {   .   Identifier } BracketsOpt
    +	BasicType
    +
    +StatementExpression: 
    +	Expression
    +
    +ConstantExpression: 
    +	Expression
    +
    +Expression1: 
    +	Expression2 [Expression1Rest]
    +
    +Expression1Rest: 
    +	[  ?   Expression   :   Expression1]
    +
    +Expression2 : 
    +	Expression3 [Expression2Rest]
    +
    +Expression2Rest: 
    +	{Infixop Expression3}
    +	Expression3 instanceof Type
    +
    +Infixop:
    +	|| 
    +	&& 
    +	| 
    +	^ 
    +	& 
    +	== 
    +	!= 
    +	< 
    +	> 
    +	<= 
    +	>= 
    +	<< 
    +	>> 
    +	>>> 
    +	+ 
    +	- 
    +	* 
    +	/ 
    +	% 
    +
    +Expression3: 
    +	PrefixOp Expression3
    +	(   Expr | Type   )   Expression3
    +	Primary {Selector} {PostfixOp}
    +
    +Primary: 
    +	( Expression )
    +	this [Arguments]
    +	super SuperSuffix
    +	Literal
    +	new Creator
    +	Identifier { . Identifier }[ IdentifierSuffix]
    +	BasicType BracketsOpt .class
    +	void.class
    +
    +IdentifierSuffix:
    +	[ ( ] BracketsOpt   .   class | Expression ])
    +	Arguments
    +	.   ( class | this | super Arguments | new InnerCreator )
    +
    +PrefixOp:
    +	++ 
    +	-- 
    +	! 
    +	~ 
    +	+ 
    +	- 
    +
    +PostfixOp: 
    +	++ 
    +	-- 
    +
    +Selector: 
    +	. Identifier [Arguments]
    +	. this
    +	. super SuperSuffix
    +	. new InnerCreator
    +	[ Expression ]
    +
    +SuperSuffix: 
    +	Arguments 
    +	. Identifier [Arguments]
    +
    +BasicType: 
    +	byte 
    +	short 
    +	char 
    +	int 
    +	long 
    +	float 
    +	double 
    +	boolean
    +
    +ArgumentsOpt: 
    +	[ Arguments ]
    +
    +Arguments: 
    +	( [Expression { , Expression }] )
    +
    +BracketsOpt: 
    +	{[]}
    +
    +Creator: 
    +	QualifiedIdentifier ( ArrayCreatorRest  | ClassCreatorRest )
    +
    +InnerCreator: 
    +	Identifier ClassCreatorRest
    +
    +ArrayCreatorRest: 
    +	[ ( ] BracketsOpt ArrayInitializer | Expression ] {[ Expression ]} 
    +BracketsOpt )
    +
    +ClassCreatorRest: 
    +	Arguments [ClassBody]
    +
    +ArrayInitializer: 
    +	{ [VariableInitializer {, VariableInitializer} [,]] }
    +
    +VariableInitializer: 
    +	ArrayInitializer
    +	Expression
    +
    +ParExpression: 
    +	( Expression )
    +
    +Block: 
    +	{ BlockStatements }
    +
    +BlockStatements: 
    +	{ BlockStatement }
    +
    +BlockStatement : 
    +	LocalVariableDeclarationStatement
    +	ClassOrInterfaceDeclaration
    +	[Identifier :] Statement
    +
    +LocalVariableDeclarationStatement:
    +	[final] Type VariableDeclarators   ;  
    +
    +Statement:
    +	Block
    +	if ParExpression Statement [else Statement]
    +	for ( ForInitOpt   ;   [Expression]   ;   ForUpdateOpt ) Statement
    +	while ParExpression Statement
    +	do Statement while ParExpression   ; 
    +	try Block ( Catches | [Catches] finally Block )
    +	switch ParExpression { SwitchBlockStatementGroups }
    +	synchronized ParExpression Block
    +	return [Expression] ; 
    +	throw Expression   ; 
    +	break [Identifier]
    +	continue [Identifier]
    +	; 
    +	ExpressionStatement
    +	Identifier   :   Statement
    +
    +Catches:
    +	CatchClause {CatchClause}
    +
    +CatchClause: 
    +	catch ( FormalParameter ) Block
    +
    +SwitchBlockStatementGroups: 
    +	{ SwitchBlockStatementGroup }
    +
    +SwitchBlockStatementGroup: 
    +	SwitchLabel BlockStatements
    +
    +SwitchLabel: 
    +	case ConstantExpression   :
    +	default:  
    +
    +MoreStatementExpressions: 
    +	{ , StatementExpression }
    +
    +ForInit: 
    +	StatementExpression MoreStatementExpressions
    +	[final] Type VariableDeclarators
    +
    +ForUpdate: 
    +	StatementExpression MoreStatementExpressions
    +
    +ModifiersOpt: 
    +	{ Modifier }
    +
    +Modifier: 
    +	public 
    +	protected 
    +	private 
    +	static 
    +	abstract 
    +	final 
    +	native 
    +	synchronized 
    +	transient 
    +	volatile
    +	strictfp
    +
    +VariableDeclarators: 
    +	VariableDeclarator { ,   VariableDeclarator }
    +
    +VariableDeclaratorsRest: 
    +	VariableDeclaratorRest { ,   VariableDeclarator }
    +
    +ConstantDeclaratorsRest: 
    +	ConstantDeclaratorRest { ,   ConstantDeclarator }
    +
    +VariableDeclarator: 
    +	Identifier VariableDeclaratorRest
    +
    +ConstantDeclarator: 
    +	Identifier ConstantDeclaratorRest
    +
    +VariableDeclaratorRest: 
    +	BracketsOpt [  =   VariableInitializer]
    +
    +ConstantDeclaratorRest: 
    +	BracketsOpt   =   VariableInitializer
    +
    +VariableDeclaratorId: 
    +	Identifier BracketsOpt
    +
    +CompilationUnit: 
    +	[package QualifiedIdentifier   ;  ] {ImportDeclaration} 
    +{TypeDeclaration}
    +
    +ImportDeclaration: 
    +	import Identifier {   .   Identifier } [   .     *   ] ;  
    +
    +TypeDeclaration: 
    +	ClassOrInterfaceDeclaration
    +	;
    +
    +ClassOrInterfaceDeclaration: 
    +	ModifiersOpt (ClassDeclaration | InterfaceDeclaration)
    +
    +ClassDeclaration: 
    +	class Identifier [extends Type] [implements TypeList] ClassBody
    +
    +InterfaceDeclaration: 
    +	interface Identifier [extends TypeList] InterfaceBody
    +
    +TypeList: 
    +	Type {  ,   Type}
    +
    +ClassBody: 
    +	{ {ClassBodyDeclaration} }
    +
    +InterfaceBody: 
    +	{ {InterfaceBodyDeclaration} }
    +
    +ClassBodyDeclaration:
    +	; 
    +	[static] Block
    +	ModifiersOpt MemberDecl
    +
    +MemberDecl:
    +	MethodOrFieldDecl
    +	void Identifier MethodDeclaratorRest
    +	Identifier ConstructorDeclaratorRest
    +	ClassOrInterfaceDeclaration
    +
    +MethodOrFieldDecl:
    +	Type Identifier MethodOrFieldRest
    +
    +MethodOrFieldRest:
    +	VariableDeclaratorRest
    +	MethodDeclaratorRest
    +
    +InterfaceBodyDeclaration:
    +	; 
    +	ModifiersOpt InterfaceMemberDecl
    +
    +InterfaceMemberDecl:
    +	InterfaceMethodOrFieldDecl
    +	void Identifier VoidInterfaceMethodDeclaratorRest
    +	ClassOrInterfaceDeclaration
    +
    +InterfaceMethodOrFieldDecl:
    +	Type Identifier InterfaceMethodOrFieldRest
    +
    +InterfaceMethodOrFieldRest:
    +	ConstantDeclaratorsRest ;
    +	InterfaceMethodDeclaratorRest
    +
    +MethodDeclaratorRest:
    +		FormalParameters BracketsOpt [throws QualifiedIdentifierList] ( 
    +MethodBody |   ;  )
    +
    +VoidMethodDeclaratorRest:
    +		FormalParameters [throws QualifiedIdentifierList] ( MethodBody |   ;  )
    +
    +InterfaceMethodDeclaratorRest:
    +	FormalParameters BracketsOpt [throws QualifiedIdentifierList]   ;  
    +
    +VoidInterfaceMethodDeclaratorRest:
    +	FormalParameters [throws QualifiedIdentifierList]   ;  
    +
    +ConstructorDeclaratorRest:
    +	FormalParameters [throws QualifiedIdentifierList] MethodBody
    +
    +QualifiedIdentifierList: 
    +	QualifiedIdentifier {  ,   QualifiedIdentifier}
    +
    +FormalParameters: 
    +	( [FormalParameter { , FormalParameter}] )
    +
    +FormalParameter: 
    +	[final] Type VariableDeclaratorId
    +
    +MethodBody:
    +	Block
    +
+ +
+ + + +
Contents | Prev | Next | IndexJava Language Specification
+Second Edition
+Copyright © 2000 Sun Microsystems, Inc. +All rights reserved +
+Please send any comments or corrections via our feedback form + + + diff --git a/topics/java/jls3/Makefile b/topics/java/jls3/Makefile new file mode 100644 index 00000000..01d14906 --- /dev/null +++ b/topics/java/jls3/Makefile @@ -0,0 +1,6 @@ +all: + python ../../extraction/html2bgf/html2bgf.py syntax.html jls3.bgf + ../../../shared/tools/checkxml bgf jls3.bgf + +clean: + rm -f *.bgf diff --git a/topics/java/jls3/syntax.html b/topics/java/jls3/syntax.html new file mode 100644 index 00000000..2494a89c --- /dev/null +++ b/topics/java/jls3/syntax.html @@ -0,0 +1,541 @@ + + + Syntax + + + + + + + +
Contents | Prev | Next | IndexJava Language Specification
+Third Edition
+

+ + +

+CHAPTER + 18

+ +

Syntax

+

+ +This chapter presents a grammar for the Java programming language.

+ +The grammar presented piecemeal in the preceding chapters is much better for exposition, but it is not well suited as a basis for a parser. The grammar presented in this chapter is the basis for the reference implementation. Note that it is not an LL(1) grammar, though in many cases it minimizes the necessary look ahead.

+ +The grammar below uses the following BNF-style conventions:

+

    +
  • [x] denotes zero or one occurrences of x. + +
  • {x} denotes zero or more occurrences of x. +
+x | y means one of either x or y.

+ + +

18.1 The Grammar of the Java Programming Language

+

+Identifier:
+        IDENTIFIER
+
+QualifiedIdentifier:
+        Identifier { . Identifier }
+
+Literal:
+        IntegerLiteral
+        FloatingPointLiteral
+        CharacterLiteral
+        StringLiteral
+        BooleanLiteral
+        NullLiteral
+
+Expression:
+        Expression1 [AssignmentOperator Expression1]]
+
+AssignmentOperator: 
+        =
+        +=
+        -=
+        *=
+        /=
+        &=
+        |=
+        ^=
+        %=
+        <<=
+        >>=
+        >>>=
+
+Type:
+        Identifier [TypeArguments]{   .   Identifier [TypeArguments]} {[]}
+        BasicType
+
+TypeArguments:
+        < TypeArgument {, TypeArgument} >
+
+TypeArgument:
+        Type
+        ? [( extends |super ) Type]
+
+StatementExpression:
+        Expression
+
+ConstantExpression:
+        Expression
+
+Expression1:
+        Expression2 [Expression1Rest]
+
+Expression1Rest:
+        ?   Expression   :   Expression1
+
+Expression2 :
+        Expression3 [Expression2Rest]
+
+Expression2Rest:
+        {InfixOp Expression3}
+        Expression3 instanceof Type
+
+InfixOp:
+        ||
+        &&
+        |
+        ^
+        &
+        ==
+        !=
+        <
+        >
+        <=
+        >=
+        <<
+        >>
+        >>>
+        +
+        -
+        *
+        /
+        %
+
+Expression3:
+        PrefixOp Expression3
+        (   Expression | Type   )   Expression3
+        Primary {Selector} {PostfixOp}
+
+Primary:
+        ParExpression
+        NonWildcardTypeArguments (ExplicitGenericInvocationSuffix | this
+Arguments)
+  this [Arguments]
+  super SuperSuffix
+        Literal
+  new Creator
+        Identifier { . Identifier }[ IdentifierSuffix]
+        BasicType {[]} .class
+   void.class
+
+IdentifierSuffix:
+        [ ( ] {[]} .   class | Expression ])
+        Arguments
+        .   ( class | ExplicitGenericInvocation | this | super Arguments | new
+[NonWildcardTypeArguments] InnerCreator )
+
+ExplicitGenericInvocation:
+        NonWildcardTypeArguments ExplicitGenericInvocationSuffix
+
+NonWildcardTypeArguments:
+        < TypeList >
+
+
+ExplicitGenericInvocationSuffix:
+     super SuperSuffix
+        Identifier Arguments
+
+
+PrefixOp:
+        ++
+        --
+        !
+        ~
+        +
+        -
+
+PostfixOp:
+        ++
+        --
+
+Selector: Selector:
+        . Identifier [Arguments]
+        . ExplicitGenericInvocation
+        . this
+   . super SuperSuffix
+        . new [NonWildcardTypeArguments] InnerCreator
+        [ Expression ]
+
+SuperSuffix:
+        Arguments
+        . Identifier [Arguments]
+
+BasicType:
+  byte
+  short
+  char
+  int
+  long
+  float
+  double
+  boolean
+
+Arguments:
+        ( [Expression { , Expression }] )
+
+Creator:
+        [NonWildcardTypeArguments] CreatedName ( ArrayCreatorRest  |
+ClassCreatorRest )
+
+CreatedName:
+        Identifier [NonWildcardTypeArguments] {. Identifier
+[NonWildcardTypeArguments]}
+
+InnerCreator:
+        Identifier ClassCreatorRest
+
+ArrayCreatorRest:
+        [ ( ] {[]} ArrayInitializer | Expression ] {[ Expression ]} {[]} )
+
+ClassCreatorRest:
+         Arguments [ClassBody]
+
+ArrayInitializer:
+        { [VariableInitializer {, VariableInitializer} [,]] }
+
+VariableInitializer:
+        ArrayInitializer
+        Expression
+
+ParExpression:
+        ( Expression )
+
+Block:
+        { BlockStatements }
+
+BlockStatements:
+        { BlockStatement }
+
+BlockStatement :
+        LocalVariableDeclarationStatement
+        ClassOrInterfaceDeclaration
+        [Identifier :] Statement
+
+LocalVariableDeclarationStatement:
+        [final] Type VariableDeclarators   ;
+
+Statement:
+        Block
+        assert Expression [ : Expression] ;
+     if ParExpression Statement [else Statement]
+     for ( ForControl ) Statement
+     while ParExpression Statement
+     do Statement while ParExpression   ;
+     try Block ( Catches | [Catches] finally Block )
+     switch ParExpression { SwitchBlockStatementGroups }
+     synchronized ParExpression Block
+     return [Expression] ;
+     throw Expression   ;
+     break [Identifier]
+     continue [Identifier]
+        ;
+        StatementExpression ;
+        Identifier   :   Statement
+
+Catches:
+        CatchClause {CatchClause}
+
+CatchClause:
+     catch ( FormalParameter ) Block
+
+SwitchBlockStatementGroups:
+        { SwitchBlockStatementGroup }
+
+SwitchBlockStatementGroup:
+        SwitchLabel BlockStatements
+
+SwitchLabel:
+     case ConstantExpression   :
+        case EnumConstantName :
+        default   :
+
+MoreStatementExpressions:
+        { , StatementExpression }
+
+ForControl:
+        ForVarControl
+        ForInit;   [Expression]   ; [ForUpdate]
+
+ForVarControl
+        [final] [Annotations] Type Identifier ForVarControlRest
+
+Annotations:
+        Annotation [Annotations]
+
+Annotation:
+        @ TypeName [( [Identifier =] ElementValue)]
+
+ElementValue:
+        ConditionalExpression
+        Annotation
+        ElementValueArrayInitializer
+
+ConditionalExpression:
+        Expression2 Expression1Rest
+
+    ElementValueArrayInitializer:
+        { [ElementValues] [,] }
+
+    ElementValues:
+        ElementValue [ElementValues]
+
+ForVarControlRest:
+        VariableDeclaratorsRest;   [Expression]   ;   [ForUpdate]
+        : Expression
+
+ForInit:
+        StatementExpression Expressions
+
+Modifier:
+  Annotation
+  public
+  protected
+  private
+  static
+  abstract
+  final
+  native
+  synchronized
+  transient
+  volatile
+        strictfp
+
+VariableDeclarators:
+        VariableDeclarator { ,   VariableDeclarator }
+
+VariableDeclaratorsRest:
+        VariableDeclaratorRest { ,   VariableDeclarator }
+
+ConstantDeclaratorsRest:
+        ConstantDeclaratorRest { ,   ConstantDeclarator }
+
+VariableDeclarator:
+        Identifier VariableDeclaratorRest
+
+ConstantDeclarator:
+        Identifier ConstantDeclaratorRest
+
+VariableDeclaratorRest:
+        {[]} [  =   VariableInitializer]
+
+ConstantDeclaratorRest:
+        {[]} =   VariableInitializer
+
+VariableDeclaratorId:
+        Identifier {[]}
+
+CompilationUnit:
+        [[Annotations] package QualifiedIdentifier   ;  ] {ImportDeclaration}
+{TypeDeclaration}
+
+ImportDeclaration:
+     import [ static] Identifier {   .   Identifier } [   .     *   ] ;
+
+TypeDeclaration:
+        ClassOrInterfaceDeclaration
+        ;
+
+ClassOrInterfaceDeclaration:
+        {Modifier} (ClassDeclaration | InterfaceDeclaration)
+
+ClassDeclaration:
+        NormalClassDeclaration
+        EnumDeclaration
+
+NormalClassDeclaration:
+     class Identifier [TypeParameters] [extends Type] [implements TypeList]
+ClassBody
+
+TypeParameters:
+        < TypeParameter {, TypeParameter} >
+
+TypeParameter:
+        Identifier [extends Bound]
+
+Bound:
+         Type {& Type}
+
+
+EnumDeclaration:
+        enum Identifier [implements TypeList] EnumBody
+
+EnumBody:
+        { [EnumConstants] [,] [EnumBodyDeclarations] }
+
+EnumConstants:
+        EnumConstant
+        EnumConstants , EnumConstant
+
+EnumConstant:
+        Annotations Identifier [Arguments] [ClassBody]
+
+EnumBodyDeclarations:
+        ; {ClassBodyDeclaration}
+
+InterfaceDeclaration:
+        NormalInterfaceDeclaration
+        AnnotationTypeDeclaration
+
+NormalInterfaceDeclaration:
+     interface Identifier [ TypeParameters] [extends TypeList] InterfaceBody
+
+TypeList:
+        Type {  ,   Type}
+
+AnnotationTypeDeclaration:
+        @ interface Identifier AnnotationTypeBody
+
+    AnnotationTypeBody:
+        { [AnnotationTypeElementDeclarations] }
+
+    AnnotationTypeElementDeclarations:
+        AnnotationTypeElementDeclaration
+        AnnotationTypeElementDeclarations AnnotationTypeElementDeclaration
+
+AnnotationTypeElementDeclaration:
+        {Modifier} AnnotationTypeElementRest
+
+AnnotationTypeElementRest:
+         Type Identifier AnnotationMethodOrConstantRest;
+        ClassDeclaration
+        InterfaceDeclaration
+        EnumDeclaration
+        AnnotationTypeDeclaration
+
+        AnnotationMethodOrConstantRest:
+        AnnotationMethodRest
+        AnnotationConstantRest
+
+AnnotationMethodRest:
+        ( ) [DefaultValue]
+
+AnnotationConstantRest:
+        VariableDeclarators
+
+
+    DefaultValue:
+        default ElementValue
+
+ClassBody:
+        { {ClassBodyDeclaration} }
+
+InterfaceBody:
+        { {InterfaceBodyDeclaration} }
+
+ClassBodyDeclaration:
+        ;
+        [static] Block
+        {Modifier} MemberDecl
+
+MemberDecl:
+        GenericMethodOrConstructorDecl
+        MethodOrFieldDecl
+        void Identifier VoidMethodDeclaratorRest
+        Identifier ConstructorDeclaratorRest
+        InterfaceDeclaration
+        ClassDeclaration
+
+GenericMethodOrConstructorDecl:
+        TypeParameters GenericMethodOrConstructorRest
+
+GenericMethodOrConstructorRest:
+        (Type | void) Identifier MethodDeclaratorRest
+        Identifier ConstructorDeclaratorRest
+
+MethodOrFieldDecl:
+        Type Identifier MethodOrFieldRest
+
+MethodOrFieldRest:
+        VariableDeclaratorRest
+        MethodDeclaratorRest
+
+InterfaceBodyDeclaration:
+        ;
+        {Modifier} InterfaceMemberDecl
+
+InterfaceMemberDecl:
+        InterfaceMethodOrFieldDecl
+        InterfaceGenericMethodDecl
+        void Identifier VoidInterfaceMethodDeclaratorRest
+        InterfaceDeclaration
+        ClassDeclaration
+
+InterfaceMethodOrFieldDecl:
+        Type Identifier InterfaceMethodOrFieldRest
+
+InterfaceMethodOrFieldRest:
+        ConstantDeclaratorsRest ;
+        InterfaceMethodDeclaratorRest
+
+MethodDeclaratorRest:
+        FormalParameters {[]} [throws QualifiedIdentifierList] ( MethodBody |   ;
+)
+
+VoidMethodDeclaratorRest:
+        FormalParameters [throws QualifiedIdentifierList] ( MethodBody |   ;  )
+
+InterfaceMethodDeclaratorRest:
+        FormalParameters {[]} [throws QualifiedIdentifierList]   ;
+
+InterfaceGenericMethodDecl:
+        TypeParameters (Type | void) Identifier InterfaceMethodDeclaratorRest
+
+VoidInterfaceMethodDeclaratorRest:
+        FormalParameters [throws QualifiedIdentifierList]   ;
+
+ConstructorDeclaratorRest:
+        FormalParameters [throws QualifiedIdentifierList] MethodBody
+
+QualifiedIdentifierList:
+        QualifiedIdentifier {  ,   QualifiedIdentifier}
+
+FormalParameters:
+        ( [FormalParameterDecls] )
+
+FormalParameterDecls:
+        [final] [Annotations] Type FormalParameterDeclsRest]
+
+FormalParameterDeclsRest:
+        VariableDeclaratorId [ , FormalParameterDecls]
+        ... VariableDeclaratorId
+
+MethodBody:
+        Block
+
+EnumConstantName:
+        Identifier
+
+

+ + +


+

+ + + +
Contents | Prev | Next | IndexJava Language Specification
+Third Edition
+

+ +Copyright © 1996-2005 Sun Microsystems, Inc. +All rights reserved +
+Please send any comments or corrections via our feedback form +
+ \ No newline at end of file