diff --git a/lang/spec.yaml b/lang/spec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ed6d000d77269ae6200259f89febe0e9e6ef3f45 --- /dev/null +++ b/lang/spec.yaml @@ -0,0 +1,1343 @@ +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Huawei Technologies Co.,Ltd. + +- name: 1.INTRODUCTION +- name: 2.LEXICAL ELEMENTS + children: + - name: 1.COMMENTS + desc: + - text: > + Line comments can be started with the character + sequence // and a stop symbol at the end of the line. + Multi-line comments start with the character + sequence /* and stop with the first subsequent character + sequence */. Multi-line comments may be nested. + - name: 2.TOKENS + desc: + - text: > + Tokens form the vocabulary of the language. + Four classes exists: + - text: | + - identifiers + - keywords + - operators and punctuation + - literals + - text: > + White space (described below) is ignored unless it + separates tokens that would eventually combine into a + single token. When dividing the input into tokens, the + next token is the longest sequence of characters that + can form a valid token. In many cases line terminators + are treated as white spaces, see “Automatic Semicolon + Insertion” for cases where line terminators have special + meaning. + children: + - name: 1.WHITE SPACES + desc: + - text: > + White space formed from spaces (U+0020), + horizontal tabulations (U+0009), + vertical tabulations (U+000B), form + feeds (U+000C), no-break spaces (U+00A0) + and zero width no-break spaces (0xFEFF). + - name: 2.LINE SEPARATORS + desc: + - text: > + Source code divided into lines using by line + terminators newline (U+000A), carriage + return (U+000D), line separator (U+2028), and + paragraph separator (U+ 2029). Subsequent line + terminators are treated as a single line terminator. + - name: 3.IDENTIFIERS + desc: + - text: > + An identifier is a sequence of one or more valid Unicode + characters. The Unicode Standard specifies the Unicode + identifier grammar based on character properties. + + The first character in an identifier must be + either "$" or "_" or any Unicode code point with the + Unicode property “ID_Start”. Other characters should + be Unicode code points with the Unicode property + “ID_Continue” or one of: + - text: | + - "$" (U+0024) + - "Zero Width Non-Joiner" (U+200C) + - "Zero Width Joiner" (U+200D) + code: | + Identifier: IdentifierStart IdentifierPart*; + IdentifierStart: UnicodeIDStart | '$' | '_' | | '\\' UnicodeEscapeSequence; + IdentifierPart: UnicodeIDContinue | '$' | | | '\\' UnicodeEscapeSequence; + - name: 4.KEYWORDS + desc: + - text: | + The following keywords are reserved and may not be used as identifiers: + - abstract + - as + - assert + - break + - case + - catch + - class + - const + - constructor + - continue + - default + - defer + - do + - else + - enum + - export + - extends + - false + - for + - function + - if + - implements + - import + - interface + - let + - new + - null + - of + - open + - override + - package + - private + - protected + - public + - recover + - rethrows + - return + - static + - super + - switch + - this + - throw + - throws + - trap + - true + - try + - while + The following keywords denote predefined type names: + - integer types: byte, int, long, short + - float types: float, double + - other types: boolean, char, void + The following keywords are reserved for future use (or used in TS): + - async + - await + - debugger + - delete + - finally + - from + - in + - is + - instanceof + - object + - string + - typeof + - var + - yield + - name: 5.OPERATORS AND PUNCTUATION + desc: + - text: | + TBD + - name: 6.LITERALS + children: + - name: 1.INTEGER LITERALS + desc: + - text: > + Integer literals can be written with bases 16, 10, 8, and 2. + code: | + DecimalIntegerLiteral: '0' | [1-9][0-9]*; + HexIntegerLiteral: '0' [xX] HexDigit+; + HexDigit: [0-9a-fA-F]; + OctalIntegerLiteral: '0' [oO] [0-7]+; + BinaryIntegerLiteral: '0' [bB] [01]+; + example: | + 153 // decimal literal + 0xBAD3 // hex literal + 0o777 // octal literal + 0b101 // binary literal + - text: > + Underscores can be used to separate digits denoting + integer literal and underscore cannot be used as very + first symbol of an integer literal. Underscores are + ignored by compiler. Integer literals are of type int, + if the value can be represented by this type (32-bits), + otherwise it is of type long. In variable and constant + declarations, an integer literal can be implicitly + converted to other integer or char type, + see “Type Compatibility with Initializer”. In all other + places an explicit cast should be used, + see “Cast Expressions”. + - name: 2.FLOATING-POINT LITERALS + desc: + - text: > + Floating-point literals are written using decimal numbers. + code: | + FloatLiteral: + "DecimalIntegerLiteral '.' [0-9]* ExponentPart?" + "| '.' [0-9]+ ExponentPart?" + "| DecimalIntegerLiteral ExponentPart" + ";" + ExponentPart: + [eE] [+-]? [0-9]+; + example: | + 3.14 + .5 + 1e10 + - text: > + Underscores can be used to separate digits denoting floating-point + literal and underscore cannot be used as very first symbol of a + floating-point literal. Underscores are ignored by compiler. + A floating-point literal is of type double. In variable and + constant declarations, + a floating-point literal can be implicitly converted to + type float, see “Type Compatibility with Initializer”. + In all other places an explicit cast should be used, + see “Cast Expressions”. + - name: 3.BOOLEAN LITERALS + desc: + - example: | + BooleanLiteral: 'true' | 'false'; + text: > + Boolean literals are of type boolean. + - name: 4.STRING LITERALS + desc: + - code: | + StringLiteral: '"' DoubleStringCharacter* '"'; + DoubleStringCharacter + : ~["\\\r\n] + | '\\' EscapeSequence + | LineContinuation + ; + LineContinuation: '\\' [\r\n\u2028\u2029]; + EscapeSequence + : ['"\\bfnrtv0] + | 'x' HexDigit HexDigit + | 'u' HexDigit HexDigit HexDigit HexDigit + | 'u' '{' HexDigit+ '}' + | ~['"\\bfnrtv0-9xu\r\n] + ; + example: | + "don't do it" + "\" + text: > + String literals are of type String, which is a library class. + - name: 5.CHAR LITERALS + desc: + - code: | + CharLiteral: '\'' Character '\''); + Character + : ~['\\\r\n] + | '\\' EscapeSequence + ; + example: | + 'a' + '\u0000' + text: > + Char literals are of type char. + - name: 6.NULL LITERALS + desc: + - code: | + NullLiteral: 'null'; + text: > + Null literals are of null type, which has no name. + - name: 7.AUTOMATIC SEMICOLON INSERTION + desc: + - link: https://262.ecma-international.org/6.0/#sec-automatic-semicolon-insertion + text: > + Certain declarations and statements (import, + variable and constant declaration, expression statement, + continue, break and return statements) must be terminated + with semicolons. These semicolons may always appear + explicitly in the initial text. Such semicolons may be + neglected from the source text in some situations: + semicolons are automatically inserted into the source + code token stream. Three basic rules of semicolon + insertion exists: + 1. When, as a source code is parsed from left to right, + a token (also called the offending token) is met that is + disallowed any grammar, then a semicolon is automatically + inserted before the offending token in the following cases: + - text: | + - At least one LineTerminator separates offending from the previous token. + - The offending token is "}". + - The previous token is ")" and the inserted semicolon would then be parsed as the terminating semicolon of a do-while statement. + - text: > + 2. When, as the source code is parsed from left to right, + the end of the input stream of tokens is encountered and + the parser is unable to parse the input token stream as + a single complete compilation unit, then a semicolon is + automatically inserted at the end of the input stream. + 3. When, as the source code is parsed from left to right, + a token is encountered that is allowed by some production + of the grammar, but the production is restricted and the + token would be the first token for a terminal or + nonterminal immediately following the annotation + “[no LineTerminator here]” within the restricted + production (and therefore such a token is called + a restricted token), and the restricted token is + separated from the previous token by at least one + LineTerminator, then a semicolon is automatically + inserted before the restricted token. + - text: > + An additional overriding condition on the preceding + rules may be applied: if the semicolon would then be parsed + as an empty statement or if that semicolon would + become one of the two semicolons in the header of + a FOR statement — such semicolon is never inserted + automatically. +- name: 3.TYPES + desc: + - text: > + Static TS is statically typed language, which means, that + any entity in the program has its static type. The type of + entity may be set explicitly by a developer or inferred + implicitly. + - text: | + Types are divided into two groups + - primitive types":"" byte, short, int, long, float, double, boolean, char, and void; + - non-primitive types":" class types, interface types, enumeration types, array types, and type variables. + - text: > + For each primitive type (except void type), the language + defines corresponding non-primitive class type that + wraps the primitive type (so called wrapper classes). + It is necessary, as primitive types cannot be used + in containers. + code: + children: + - name: 1.PRIMITIVE TYPES + desc: + - text: > + Some types are predefined by the language and named + by its reserved keyword":"" byte, short, int, long, + float, double, boolean, char, void. + - text: > + Values of primitive types do not share state with + other values of primitive types. + children: + - name: 1.INTEGRAL TYPES + desc: + - table: | + | Type | The set of values of the type | Non-primitive type | + |---|---|---| + | byte | The set of all signed 8-bit integers (-2^7 to 2^7 - 1) | Byte | + | short | The set of all signed 16-bit integers (-2^15 to 2^15 - 1) | Short | + | int | The set of all signed 32-bit integers (-2^31 to 2^31 - 1) | Integer | + | long | The set of all signed 64-bit integers (-2^63 to 2^63 - 1) | Long | + | char | The set of unsigned integers from '\u0000' to '\uffff' inclusive, that is, from 0 to 65.535 | Character | + - name: 2.INTEGER OPERATIONS + desc: + - text: > + The language provides a number of operators that act on values of integral types: + - text: | + - The comparison operators, which result in a value of type boolean":" + - The numerical comparison operators <, <=, >, and >= + - The numerical equality operators == and != + - The numerical operators, which result in a value of type int or long":" + - The unary plus and minus operators + and - + - The multiplicative operators *, /, and % + - The additive operators + and - + - The increment operator ++, both prefix and postfix + - The decrement operator --, both prefix and postfix + - The signed and unsigned shift operators <<, >>, and >>> + - The bitwise complement operator ~ + - The integer bitwise operators &, ^, and | + - The conditional operator ?":" + - The cast operator, which can convert from an integral value to a value of any specified numeric type + - The string concatenation operator +, which, when given a String operand and an integral operand, will convert the integral operand to a String (the decperand), and then produce a newly created String that is the concatenation of the two strings + - text: > + Other methods, constructors and + constants are predefined in the Short, + Byte, Long, Integer, and Character classes. + The operation is carried out + using 64-bit precision in case if an integer + operator (excluding shift + operator) has at least one operand of type + long. The result + of the numerical operator is of type long. + If the other operand is not long, + it is first widened to type long by + numeric promotion. Otherwise, the + operation is performed using 32-bit + precision, with the result of the numerical + operator of type int. The operand + is first widened to type + int by numeric promotion if it is not int type. + Any value of any integral type may be cast + from or to any numeric type. There are no casts + between type boolean and integral types. + The integer operators do not indicate any + overflows or underflows. + - text: > + An integer operator can throw an exception for the following reasons":" + - text: | + - Any integer operator can throw a NullPointerException if unboxing conversion of a null reference is required. + - The integer division operator / and the integer remainder operator % can throw an ArithmeticException if the right-hand operand is zero. + - The increment and decrement operators ++ and -- can throw an OutOfMemoryError if boxing conversion is required and there is not sufficient memory available to perform the conversion. + - name: 3.FLOAT TYPES + desc: + - table: | + | Type | The set of values of the type | Non-primitive type | + |---|---|---| + | float | The set of all IEEE-754 32-bit floating-point numbers | Float | + | double | The set of all IEEE-754 64-bit floating-point numbers | Double | + - name: 4.FLOATING-POINT OPERATIONS + desc: + - text: > + The language provides a number of operators that act on values of floating-point types: + - text: | + - The comparison operators, with a result of type boolean value: + - The numerical comparison operators <, <=, >, and >= + - The numerical equality operators == and != + - The numerical operators, with a result of type float or double value: + - The unary plus and minus operators + and - + - The multiplicative operators *, /, and % + - The additive operators + and - + - The increment operator ++, both prefix and postfix + - The decrement operator --, both prefix and postfix + - The conditional operator ? : + - The cast operator, which can convert from a floating-point value to a value of any specified numeric type + - The string concatenation operator +, which, when given a String operand and a floating-point operand, will convert the floating-point operand to a String representing its value in decimal form (without information loss), and then produce a newly created String that is the concatenation of the two strings + - text: > + Other methods, constructors, and constants are predefined + in the Double, Math, and Float classes. The operation + is a floating-point operation, even if the other is integral, + If at least one of the operands to a binary operator + is of floating-point type. The operation is carried + out using 64-bit floating-point arithmetic, and the + result of the numerical operator is a value of type + double If at least one of the operands to a numerical + operator is of type double. The other operand is the + first widened to type double by numeric promotion if + it is not a double. Otherwise, the operation is + performed using 32-bit floating-point arithmetic + with a result of the numerical operator of type + float value. (If the other operand is not a float, + it is first widened to type float by numeric promotion.) + Any value of a floating-point type may be cast to or + from any numeric type. No casts exists between type + boolean and floating-point types. IEEE 754 specifies + the behaviour of operators on floating-point numbers + (except the remainder operator). In particular, + the language requires support of IEEE 754 denormalized + floating-point numbers and gradual underflow, + which make it easier to prove desirable properties + of particular numerical algorithms. If the + calculated result is a denormalized number, + then floating-point operations do not turn to zero. + The language requires that floating-point arithmetic + behave as if every floating-point operator rounded + its floating-point result to the nearest precision. + Imprecise results are rounded to the representant + value infinitely nearest to the precise result; + if the two nearest values are equally near, + the one with its least significant bit zero has + the advantage. This "round to nearest" is the default + rounding mode of the IEEE 754 standard default rounding + mode. The language uses rounding to zero to convert a + floating value to an integer, which acts, in this case, + as if the number were truncated by discarding the mantissa + bits. When rounded to zero, its result is the format's value + closest to and no greater in magnitude than the + infinitely precise result. + - text: | + A floating-point operation that overflows produces a signed infinity. + A floating-point operation that underflows produces a denormalized value or a signed zero. + A floating-point operation that has no mathematically definite result produces NaN. + All numeric operations with NaN as an operand produce NaN as a result. + - text: > + A floating-point operator can throw an exception for the following reasons: + - text: | + - Any floating-point operator can throw a NullPointerException if unboxing conversion of a null reference is required. + - The increment and decrement operators ++ and -- can throw an OutOfMemoryError if boxing conversion is required and there is not sufficient memory available to perform the conversion. + - name: 5.BOOLEAN TYPE AND OPERATIONS + desc: + - text: > + The boolean type represents logical values that are either true or false. Corresponding non-primitive type is Boolean. + - text: > + The boolean operators are: + - text: | + - The relational operators == and != + - The logical complement operator ! + - The logical operators &, ^, and | + - The conditional-and and conditional-or operators && and || + - The conditional operator ? : + - The string concatenation operator +, which, when given a String operand and a boolean operand, will convert the boolean operand to a String (either "true" or "false"), and then produce a newly created String that is the concatenation of the two strings + - text: > + An floating-point or integer expression x + can be changed to a boolean value, following + by C convention that any non-zero + value is true, by the expression x != 0. + An object reference obj can be converted + to a boolean value, following by C + convention that any reference other than null + is true, by the expression obj != null. + - name: 6.VOID TYPE + desc: + - text: > + The purpose of void type is to represent that + function or method does not have a return value. + It is not possible to use this type in any + place other than the position of return type. + - name: 7.DEFAULT VALUES FOR PRIMITIVE TYPES + desc: + - table: | + | Data Type | Default Value | + |---|---| + | byte | 0 | + | short | 0 | + | int | 0 | + | long | 0 | + | float | 0.0 | + | double | 0.0 | + | char | '\u0000' | + | boolean | false | + - name: 2.REFERENCE TYPES + desc: + - text: > + There are five kinds of reference types: class + types, interface types, enumeration types, + type variables, and array types. + - children: + - name: 1.OBJECTS + desc: + - text: > + An object is a class instance, enumeration + instance, or an array. The reference values + (or simply references) are pointers to + these objects, and a special null reference, + which does not refer to any object. A class + instance is explicitly created by a class + instance creation expression. An enumeration + instance is explicitly + created by an enumeration instance + creation expression. + An array is explicitly created by an + array creation expression. + Other expressions may implicitly create + a class instance or an array. + - text: > + The operators on references to objects are: + - text: | + - Field access, using either a field access expression or a qualified name + - Method invocation expression + - The cast operator + - The concatenation operator + (string), which, when given a String operand and a reference, will convert the reference to a String by invoking the toString method of the referenced object (using "null" if either the reference or the result of toString is a null reference), and then will produce a newly created String that is the concatenation of the two strings + - The instanceof operator + - The reference equality operators == and != + - The conditional operator ? : + - text: > + The same object may have many references to. + Most objects have state, stored in the fields + of objects that are instances of classes. + It also can be stored in the variables that + are the components of an array object. + If two variables + refers to the same object, the state of + the object can be modified using one variable's + reference to the object, and then the altered + state can be observed through the reference + in the other variable. + - name: 2.NAMED TYPES + desc: + - text: > + Enumerations, classes, and interfaces are + named types that are introduced through + enumeration declarations, class declarations, + and interface declarations. Classes and + interfaces can have type parameters; in that + case they are generic types. At variance with, + named types without type parameters are + called non-generic types. Named types are + referenced by type references that specify + the type name and, if applicable, the type + arguments to be replaced by the named + type parameters. + - name: 3.TYPE REFERENCE + desc: + - text: > + A type reference references a named type + through its name and, in the case of a + generic type, supplies a type argument list. + code: | + - typeReference + : typeReferencePart ('.' typeReferencePart)* + ; + - typeReferencePart + : qualifiedName typeArguments? + ; + - name: 4.OBJECT CLASS + desc: + - text: > + A superclass of all other classes is the class + Object. All enumeration, class, and array + types inherit the methods of class. + - text: > + Object, which are summarized as follows: + - text: | + - Use the clone method to make a duplicate of an object. + - The equals method defines a notion of object equality, + which is based on value (not reference). + - The finalize method is executed immediately before + the object is destroyed. + - The getClass method returns the Class object that represents + the object's class. A Class object exists for each type of + reference type. It can be used, for example, to discover + the full name of a class, its superclass, its members, + and interfaces it implements. + The expression type of the getClass call method is Class, where T is a class or interface searched + for getClass and |T| denotes erasing T. Class method + declared synchronized on the monitor associated with + the Class object. + - The method hashCode is often used with the + method equals, in hashtables such as java.util.HashMap. + - The methods wait, notify, and notifyAll are used in + concurrent programming using threads. + - The method toString returns a String representation + of an object. + - name: 5.STRING CLASS + desc: + - text: > + The String class represents sequences of characters + stored as Unicode UTF-16 code units. All string + literals, such as "abc", are implemented as instances + of String class. A String objects have an immutable + value: their values cannot be changed after they + are created. String objects can be shared are immutable + Because they are immutable. The string concatenation + operator + implicitly creates a new String object + when the result is not a constant expression. + The String class has a special semantics of + equality operators == and !=. + - name: 6.TYPE VARIABLES + desc: + - text: > + A type variable is an unqualified identifier used + as a type in class, interface, method, constructor, + and function bodies. A type variable is introduced + by the declaration of a type parameter of a generic + class, interface, method, constructor, or function. + - text: > + Every declared type variable as a type parameter + has a bound. If no bound is declared — Object is assumed. + If a bound is declared, it consists of the following: + - text: | + - a single type variable T, or + - a class or interface type T possibly followed by interface types I1 & ... & In. + - name: 7.DEFAULT VALUES FOR REFERENCE TYPES + desc: + - text: > + TBD + - name: 3.TYPE ERASURE + desc: + - text: > + Type erasure is a mapping from types (possibly + including type variables and parameterized types) + to types (that are never type variables or + parameterized types). Write |T| for the erasure + of type T. The erasure mapping is defined as follows: + - text: | + - The erasure of a parameterized type G is |G|. + - The erasure of a nested type T.C is |T|.C. + - The erasure of an array type T[] is |T|[]. + - The erasure of a type variable is the erasure of its leftmost bound. + - The erasure of every other type is the type itself. + - text: > + Type erasure also maps the signature of a + constructor, method, or function to a signature + that has no parameterized types or type variables. + The erasure of a constructor, method, or function + signature s is a signature consisting of the same + name as s and the erasures of all the formal + parameter types given in s. The return type + of a method or function and the type parameters + of a generic method, constructor, or function + also undergo erasure if the method, constructor, + or function's signature is erased. + - name: 4.REIFIABLE TYPES + desc: + - text: > + Not all types are available at run time, because + some type information is erased during compilation. + Reifiable — are types that are completely available + at run time. + - text: > + A type is reifiable if and only if one of the following: + - text: | + - It is an array type whose element type is reifiable. + - It is a nested type where, for each type T separated by a ".", T itself is reifiable. + - It refers to a non-generic class, interface, or enumeration type declaration. + - It is a parameterized type in which all type arguments are unbounded wildcards. + - text: > + An intersection type is not reifiable. + - name: 5.INTERSECTION TYPES + desc: + - text: > + An intersection type is a type of the form + T1 & ... & Tn (n > 0), where Ti (1 ≤ i ≤ n) + are a class or an interface types. Intersection + types can be derived from type parameter + bounds and cast expressions; they also + occur within the capture conversion + and least upper bound calculation process. + The values of an intersection + type are those objects that are values of + all of the Ti types for 1 ≤ i ≤ n. + - text: > + Every intersection type T1 & ... & Tn + induces a notional class or interface for + the purpose of identifying the members of + the intersection type, as follows: + - text: | + - For each Ti (1 ≤ i ≤ n), Ci is the most specific class or array type such that Ti <: Ci. Then there must be some Ck such that Ck <: Ci for any i (1 ≤ i ≤ n), or a compile-time error occurs. + - If Tj is a type variable, for 1 ≤ j ≤ n, then let Tj' be an interface whose members are the same as the public members of Tj; otherwise, if Tj is an interface, then let Tj' be Tj. + - If Ck is Object, a notional interface is induced; otherwise, a notional class is induced with direct superclass Ck. This class or interface has direct superinterfaces T1', ..., Tn' and is declared in the package in which the intersection type appears. + - text: > + The elements of an intersection type are + the members of the class or interface it creates. + - name: 6.SUBTYPING + desc: + - text: > + The subtype and supertype relations are + binary relations on types. The supertypes + of a type are obtained by reflexive and + transitive closure over the direct supertype + relation, written S >1 T, which is defined + by rules given in this section. + Write S :> T to indicate that the + supertype relation holds between S and T. + S is a proper supertype of T, written + S > T, if S :> T and S ≠ T. The subtypes + of a type T are all types U such that T + is a supertype of U, and the null type. + Write T <: S to indicate that + the subtype relation holds between types + T and S. T is a proper subtype of S, + written T < S, if T <: S and S ≠ T. + T is a direct subtype of S, written + T <1 S, if S >1 T. Subtyping does + not extend through parameterized + types: T <: S does not imply + that C <: C. + children: + - name: 1.SUBTYPING AMONG PRIMITIVE TYPES + desc: + - text: > + The following rules define the direct supertype relation among the primitive types: + - text: | + - double >1 float + - float >1 long + - long >1 int + - int >1 char + - int >1 short + - short >1 byte + - name: 2.SUBTYPING AMONG CLASS AND INTERFACE TYPES + desc: + - text: > + Given a generic class or interface type declaration + C (n > 0), the direct supertypes of the + generic type C are all of the following: + - text: | + - The direct superclass of C. + - The direct superinterfaces of C. + - The type Object, if C is an interface type with no direct superinterfaces. + - text: > + Given a generic class or interface type declaration + C (n > 0), the direct supertypes of the + generic type C are the following: + - text: | + - The direct superclass of C. + - The direct superinterfaces of C. + - The type Object, if C is a generic interface type with no direct superinterfaces. + - text: > + Given a generic class or interface type + declaration C (n > 0), the + direct supertypes of the parameterized + type C, where Ti (1 ≤ i ≤ n) + is a type, are all of the following: + - text: | + - D, where D is a generic type which is a direct supertype of the generic type C and θ is the substitution [F1:=T1,...,Fn:=Tn]. + - C, where Si contains Ti (1 ≤ i ≤ n). + - The type Object, if C is a generic interface type with no direct superinterfaces. + - text: > + Given a generic class or interface type + declaration C (n > 0), the + direct supertypes of the parameterized + type C, where at least one of + the Ri (1 ≤ i ≤ n) is a wildcard type + argument, are the direct supertypes of + the parameterized type C + which is the result of applying capture + conversion to C. The direct + supertypes of an intersection + type T1 & ... & Tn are Ti (1 ≤ i ≤ n). + The type variable direct supertypes + are the types listed in its bound. + A type variable is a direct supertype + of its lower bound. The direct null type + supertypes are all reference types + other than the null type itself. + - name: 3.SUBTYPING AMONG ARRAY TYPES + desc: + - text: > + The following rules define the direct supertype relation among array types: + - text: | + - If S and T are both reference types, then S[] >1 T[] iff S >1 T. + - Object >1 Object[] + - Cloneable >1 Object[] + - java.io.Serializable >1 Object[] + - If P is a primitive type, then: + - Object >1 P[] + - Cloneable >1 P[] + - java.io.Serializable >1 P[] + - name: 4.SUBTYPING AMONG ENUMERATION TYPES + desc: + - text: > + TBD + - name: 5.LEAST UPPER BOUND + desc: + - text: > + The least upper bound, or "lub", + of a set of reference types is a + shared supertype that is more specific + than any other shared supertype + (that is, no other shared supertype + is a subtype of the least upper bound). + This type, lub(U1, ..., Uk), is + determined as follows. If k = 1, + then the lub is the type itself: lub(U) = U. + - text: > + Otherwise: + - text: | + - For each Ui (1 ≤ i ≤ k): + Let ST(Ui) be the set of supertypes of Ui. + Let EST(Ui), the set of erased supertypes of Ui, be: + EST(Ui) = { |W| | W in ST(Ui) } where |W| is the erasure of W. + - Let EC, the erased candidate set for U1 ... Uk, be the intersection of all the sets EST(Ui) (1 ≤ i ≤ k). + - Let MEC, the minimal erased candidate set for U1 ... Uk, be: + MEC = { V | V in EC, and for all W ≠ V in EC, it is not the case that W <: V } + - For any element G of MEC that is a generic type: + Let the "relevant" parameterizations of G, Relevant(G), be: + Relevant(G) = { V | 1 ≤ i ≤ k: V in ST(Ui) and V = G<...> } + - text: > + Let the "candidate" parameterization of G, + Candidate(G), be the most specific parameterization + of the generic type G that contains all the relevant + parameterizations of G: + - text: > + Candidate(G) = lcp(Relevant(G)), + where lcp(), the least containing + parameterization, is: + - text: | + - lcp(S) = lcp(e1, ..., en) where ei (1 ≤ i ≤ n) in S + - lcp(e1, ..., en) = lcp(lcp(e1, e2), e3, ..., en) + - lcp(G, G) = G + - lcp(G) = G + - text: > + and where lcta(), the least containing type + argument, is: (assuming U and V are types) + - text: | + - lcta(U, V) = U if U = V, otherwise ? extends lub(U, V) + - lcta(U, ? extends V) = ? extends lub(U, V) + - lcta(U, ? super V) = ? super glb(U, V) + - lcta(? extends U, ? extends V) = ? extends lub(U, V) + - lcta(? extends U, ? super V) = ? + - lcta(? super U, ? super V) = ? super glb(U, V) + - lcta(U) = ? if U's upper bound is Object, otherwise ? extends lub(U,Object) + - text: > + - Let lub(U1 ... Uk) be: + - text: > + Best(W1) & ... & Best(Wr), where Wi + (1 ≤ i ≤ r) are the elements of MEC, + the minimal erased candidate set of U1 ... Uk; + and where, if any of these elements are + generic, we use the candidate parameterization + (so as to recover type arguments): + Best(X) = Candidate(X) if X is generic; otherwise X. + - text: > + The lub() function only + approximates a least upper bound. Formally, + there may exist some other type T such + that all of U1 ... Uk are subtypes of T and T is + a subtype of lub(U1, ..., Uk). However, a compiler + for the language must implement lub() + as specified above. + - text: > + It is possible that the lub() function yields + an infinite type. A + compiler for the language must recognize such + situations and represent them correctly + using cyclic data structures. +- name: 4.NAMES, DECLARATIONS AND SCOPES + children: + - name: 1.NAMES + desc: + - text: > + Names are either simple, consisting of a single identifier, or qualified, consisting of + a sequence of identifiers separated by "." tokens. A qualified name N.x may be used to refer + to a member of a package or reference type, where N is a simple or qualified name and x is an identifier. + If N names a package, then x is a member of that package. If N names a reference type or a variable of + a reference type, then x names a member of that type, which is either a class, an interface, a field, + or a method. + code: + - name: 2.DECLARATIONS + desc: + - text: + - name: 3.SCOPES + desc: + - text: + - name: 4.TYPE DECLARATIONS + desc: + - text: + code: + - name: 5.VARIABLE AND CONSTANT DECLARATIONS + children: + - name: 1.VARIABLE DECLARATIONS + desc: + - text: + code: + - text: + example: + - text: + - name: 2.CONSTANT DECLARATIONS + desc: + - text: + code: + - text: + example: + - name: 3.TYPE COMPATIBILITY WITH INITIALIZER + desc: + - text: + table: + - text: + - name: 6.FUNCTION DECLARATIONS + desc: + - text: + code: + - text: +- name: 5.GENERIC AND PARAMETERIZED DECLARATIONS + children: + - name: 1.GENERIC DECLARATIONS + desc: + - text: + code: + - text: + children: + - name: 1.GENERIC CLASSES + desc: + - text: + - name: 2.GENERIC INTERFACES + desc: + - text: + - name: 3.GENERIC METHODS + desc: + - text: + - name: 4.GENERIC CONSTRUCTORS + desc: + - text: + - name: 5.GENERIC FUNCTIONS + desc: + - text: + - name: 2.PARAMETERIZED DECLARATIONS + desc: + - text: + code: + - text: + children: + - name: 1.TYPE ARGUMENTS OF PARAMETERIZED TYPES AND FUNCTIONS + desc: + - text: + code: + - text: + - name: 2.MEMBERS AND CONSTRUCTORS OF PARAMETERIZED TYPES + desc: + - text: +- name: 6.CONVERSIONS AND CONTEXTS + desc: + - text: + children: + - name: 1.KINDS OF CONVERSION + desc: + - text: + children: + - name: 1.IDENTITY CONVERSION + desc: + - text: + - name: 2.WIDENING PRIMITIVE CONVERSION + desc: + - text: + - name: 3.NARROWING PRIMITIVE CONVERSION + desc: + - text: + - name: 4.WIDENING AND NARROWING PRIMITIVE CONVERSION + desc: + - text: + - name: 5.WIDENING REFERENCE CONVERSION + desc: + - text: + - name: 6.NARROWING REFERENCE CONVERSION + desc: + - text: + - name: 7.BOXING CONVERSION + desc: + - text: + - name: 8.UNBOXING CONVERSION + desc: + - text: + - name: 9.CAPTURE CONVERSION + desc: + - text: + - name: 10.STRING CONVERSION + desc: + - text: + - name: 11.FORBIDDEN CONVERSION + desc: + - text: + - name: 2.ASSIGMENT CONTEXTS + desc: + - text: + - name: 3.INVOCATION CONTEXTS + desc: + - text: + - name: 4.STRING CONTEXTS + desc: + - text: + - name: 5.CASTING CONTEXTS + desc: + - text: + table: + - text: + table: + - name: 6.NUMERIC CONTEXTS + desc: + - text: + children: + - name: 1. UNARY NUMERIC PROMOTION + desc: + - text: + - name: 2. BINARY NUMERIC PROMOTION + desc: + - text: +- name: 7.EXPRESSIONS + desc: + - text: + children: + - name: 1.EVALUATION, DENOTATION, AND RESULT + desc: + - text: + - name: 2.FORMS OF EXPRESSIONS + desc: + - text: + - name: 3.TYPE OF AN EXPRESSIONS + desc: + - text: + - name: 4.EXPRESSIONS AND RUN-TIME CHECKS + desc: + - text: + - name: 5.NORMAL AND ABRUPT COMPLETION OF EVALUATION + desc: + - text: + - name: 6.EVALUATION ORDER + desc: + - text: + children: + - name: 1. EVALUATE LEFT-HAND OPERAND FIRST + desc: + - text: + - name: 2. EVALUATE OPERANDS BEFORE OPERATION + desc: + - text: + - name: 3. EVALUATION RESPECTS PARENTHESES AND PRECEDENCE + desc: + - text: + - name: 4. ARGUMENTS LISTS ARE EVALUATED LEFT-TO-RIGHT + desc: + - text: + - name: 5. EVALUATION ORDER FOR OTHER EXPRESSIONS + desc: + - text: + - name: 7.LITERALS + desc: + - text: + table: + - name: 8.CLASS LITERAL + desc: + - text: + code: + - text: + - name: 9.ARRAY LITERAL + desc: + - text: + code: + - text: + - name: 10.PARENTHESIZED LITERAL + desc: + - code: + text: + - name: 11.THIS EXPRESSION + desc: + - text: + children: + - name: 1. QUALIFIED THIS + desc: + - text: + - name: 12.METHOD INVOCATION EXPRESSION + desc: + - text: + code: + - text: + children: + - name: 1.COMPILE-TIME STEP 1:DETERMINE CLASS OR INTERFACE TO SEARCH + desc: + - text: + - name: 2.COMPILE-TIME STEP 2:DETERMINE METHOD SIGNATURE + desc: + - text: + - name: 3.COMPILE-TIME STEP 3:IS THE CHOSEN METHOD APPROPRIATE? + desc: + - text: + - name: 4.RUN-TIME EVALUATION OF METHOD INVOCATION + desc: + - text: + - name: 13.FIELD ACCESS EXPRESSIONS + desc: + - text: + code: + - text: + children: + - name: 1.FIELD ACCESS USING AN EXPRESSION + desc: + - text: + - name: 2.ACCESSING SUPERCLASS MEMBERS USING SUPER OR TYPEREFERENCE + desc: + - text: + - name: 14.ARRAY ACCESS EXPRESSIONS + desc: + - text: + code: + - text: + children: + - name: 1.RUN-TIME EVALUATION OF INDEX EXPRESSIONS + desc: + - text: + - name: 15.FUNCTION INVOCATION EXPRESSION + desc: + - code: + text: + children: + - name: 1.COMPILE-TIME STEP 1:DETERMINE FUNCTION SIGNATURE + desc: + - text: + - name: 2.COMPILE-TIME STEP 2:IS THE CHOSEN FUNCTION APPROPRIATE? + desc: + - text: + - name: 3.COMPILE-TIME STEP 3:RUN-TIME EVALUATION OF CALL EXPRESSION + desc: + - text: + - name: 16.NEW EXPRESSIONS + desc: + - text: + code: + children: + - name: 1.CLASS INSTANCE CREATION EXPRESSIONS + desc: + - text: + code: + - text: + - name: 2.ARRAY CREATION EXPRESSIONS + desc: + - text: + code: + example: + - text: + - name: 17.UNARY OPERATORS + desc: + - code: + text: + children: + - name: 1.POSTFIX INCREMENT OPERATOR + desc: + - text: + - name: 2.POSTFIX DECREMENT OPERATOR + desc: + - text: + - name: 3.PREFIX INCREMENT OPERATOR + desc: + - text: + - name: 4.PREFIX DECREMENT OPERATOR + desc: + - text: + - name: 5.UNARY PLUS OPERATOR + desc: + - text: + - name: 6.UNARY MINUS OPERATOR + desc: + - text: + - name: 7.BITWISE COMPLEMENT OPERATOR + desc: + - text: + - name: 8.LOGICAL COMPLEMENT OPERATOR + desc: + - text: + - name: 18.CAST EXPRESSIONS + desc: + - text: + code: + example: + - text: + - name: 19.MULTIPLICATIVE OPERATORS + desc: + - text: + code: + - text: + children: + - name: 1.MULTIPLICATION OPERATOR "*" + desc: + - text: + - name: 2.DIVISION OPERATOR "/" + desc: + - text: + - name: 3.REMAINDER OPERATOR "%" + desc: + - text: + - name: 20.ADDITIVE OPERATORS + desc: + - text: + code: + - text: + children: + - name: 1.STRING CONCATENATION OPERATOR "+" + desc: + - text: + - name: 2.ADDITIVE OPERATORS ("+" AND "-") FOR NUMERIC TYPES + desc: + - text: + - name: 21.SHIFT OPERATORS + desc: + - text: + code: + - text: + - name: 22.RELATIONAL OPERATORS + desc: + - text: + code: + - text: + children: + - name: 1.NUMERICAL COMPARISON OPERATORS "<", "<=", ">", AND ">=" + desc: + - text: + - name: 23.TYPE COMPARISON OPERATOR "INSTANCEOF" + desc: + - code: + text: + - name: 24.EQUALITY OPERATORS + desc: + - text: + code: + - text: + children: + - name: 1.NUMERICAL EQUALITY OPERATORS + desc: + - text: + - name: 2.BOOLEAN EQUALITY OPERATORS + desc: + - text: + - name: 3.STRING EQUALITY OPERATORS + desc: + - text: + - name: 4.REFERENCE EQUALITY OPERATORS + desc: + - text: + - name: 25.BITWISE AND LOGICAL OPERATORS + desc: + - text: + code: + - text: + children: + - name: 1.INTEGER BITWISE OPERATORS "&", "^", AND "|" + desc: + - text: + - name: 2.BOOLEAN LOGICAL OPERATORS "&", "^", AND "|" + desc: + - text: + - name: 26.CONDITIONAL-AND OPERATOR "&&" + desc: + - text: + code: + - text: + - name: 27.CONDITIONAL-OR OPERATOR "| |" + desc: + - text: + code: + - text: + - name: 28.ASSIGNMENT + desc: + - text: + code: + - text: + children: + - name: 1.SIMPLE ASSIGNMENT OPERATOR + desc: + - text: + - name: 2.COMPOUND ASSIGNMENT OPERATORS + desc: + - text: + - name: 29.CONDITIONAL EXPRESSIONS + desc: + - text: + code: + - text: + children: + - name: 1.BOOLEAN CONDITIONAL EXPRESSIONS + desc: + - text: + - name: 2.NUMERIC CONDITIONAL EXPRESSIONS + desc: + - text: + - name: 3.REFERENCE CONDITIONAL EXPRESSIONS + desc: + - text: + - name: 30.LAMBDA EXPRESSIONS + desc: + - text: + code: + example: + - text: + children: + - name: 1.LAMBDA PARAMETERS + desc: + - text: + - name: 2.LAMBDA BODY + desc: + - text: + - name: 3.TYPE OF A LAMBDA EXPRESSION + desc: + - text: + - name: 4.RUN-TIME EVALUATION OF LAMBDA EXPRESSIONS + desc: + - text: + - name: 31.TRY EXPRESSIONS + desc: + - text: + code: + - text: + - name: 32.CONSTANT EXPRESSIONS + desc: + - code: + text: