diff --git a/translated/issues-4.html b/translated/issues-4.html new file mode 100644 index 00000000000..11b190f0b11 --- /dev/null +++ b/translated/issues-4.html @@ -0,0 +1,12 @@ + +

Overview

+

This section contains a non-normative overview of the ECMAScript language.

+

ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the computational environment of an ECMAScript program will provide not only the objects and other facilities described in this specification but also certain environment-specific objects, whose description and behaviour are beyond the scope of this specification except to indicate that they may provide certain properties that can be accessed and certain functions that can be called from an ECMAScript program.

+

ECMAScript was originally designed to be used as a scripting language, but has become widely used as a general-purpose programming language. A scripting language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. In such systems, useful functionality is already available through a user interface, and the scripting language is a mechanism for exposing that functionality to program control. In this way, the existing system is said to provide a host environment of objects and facilities, which completes the capabilities of the scripting language. A scripting language is intended for use by both professional and non-professional programmers.

+

ECMAScript was originally designed to be a Web scripting language, providing a mechanism to enliven Web pages in browsers and to perform server computation as part of a Web-based client-server architecture. ECMAScript is now used to provide core scripting capabilities for a variety of host environments. Therefore the core language is specified in this document apart from any particular host environment.

+

ECMAScript usage has moved beyond simple scripting and it is now used for the full spectrum of programming tasks in many different environments and scales. As the usage of ECMAScript has expanded, so has the features and facilities it provides. ECMAScript is now a fully featured general-purpose programming language.

+

Some of the facilities of ECMAScript are similar to those used in other programming languages; in particular C, Java™, Self, and Scheme as described in:

+

ISO/IEC 9899:1996, Programming Languages – C.

+

Gosling, James, Bill Joy and Guy Steele. The Java Language Specification. Addison Wesley Publishing Co., 1996.

+

Ungar, David, and Smith, Randall B. Self: The Power of Simplicity. OOPSLA '87 Conference Proceedings, pp. 227-241, Orlando, FL, October 1987.

+

IEEE Standard for the Scheme Programming Language. IEEE Std 1178-1990.

\ No newline at end of file diff --git a/translated/issues-5.html b/translated/issues-5.html new file mode 100644 index 00000000000..1d38a58d0b8 --- /dev/null +++ b/translated/issues-5.html @@ -0,0 +1,40 @@ + +

Web Scripting

+

A web browser provides an ECMAScript host environment for client-side computation including, for instance, objects that represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output. Further, the host environment provides a means to attach scripting code to events such as change of focus, page and image loading, unloading, error and abort, selection, form submission, and mouse actions. Scripting code appears within the HTML and the displayed page is a combination of user interface elements and fixed and computed text and images. The scripting code is reactive to user interaction, and there is no need for a main program.

+

A web server provides a different host environment for server-side computation including objects representing requests, clients, and files; and mechanisms to lock and share data. By using browser-side and server-side scripting together, it is possible to distribute computation between the client and server while providing a customized user interface for a Web-based application.

+

Each Web browser and server that supports ECMAScript supplies its own host environment, completing the ECMAScript execution environment.

+
+ + + +

ECMAScript Overview

+

The following is an informal overview of ECMAScript—not all parts of the language are described. This overview is not part of the standard proper.

+

ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a cluster of communicating objects. In ECMAScript, an object is a collection of zero or more properties each with attributes that determine how each property can be used—for example, when the Writable attribute for a property is set to *false*, any attempt by executed ECMAScript code to assign a different value to the property fails. Properties are containers that hold other objects, primitive values, or functions. A primitive value is a member of one of the following built-in types: Undefined, Null, Boolean, Number, String, and Symbol; an object is a member of the built-in type Object; and a function is a callable object. A function that is associated with an object via a property is called a method.

+

ECMAScript defines a collection of built-in objects that round out the definition of ECMAScript entities. These built-in objects include the global object; objects that are fundamental to the runtime semantics of the language including `Object`, `Function`, `Boolean`, `Symbol`, and various `Error` objects; objects that represent and manipulate numeric values including `Math`, `Number`, and `Date`; the text processing objects `String` and `RegExp`; objects that are indexed collections of values including `Array` and nine different kinds of Typed Arrays whose elements all have a specific numeric data representation; keyed collections including `Map` and `Set` objects; objects supporting structured data including the `JSON` object, `ArrayBuffer`, `SharedArrayBuffer`, and `DataView`; objects supporting control abstractions including generator functions and `Promise` objects; and reflection objects including `Proxy` and `Reflect`.

+

ECMAScript also defines a set of built-in operators. ECMAScript operators include various unary operations, multiplicative operators, additive operators, bitwise shift operators, relational operators, equality operators, binary bitwise operators, binary logical operators, assignment operators, and the comma operator.

+

Large ECMAScript programs are supported by modules which allow a program to be divided into multiple sequences of statements and declarations. Each module explicitly identifies declarations it uses that need to be provided by other modules and which of its declarations are available for use by other modules.

+

ECMAScript syntax intentionally resembles Java syntax. ECMAScript syntax is relaxed to enable it to serve as an easy-to-use scripting language. For example, a variable is not required to have its type declared nor are types associated with properties, and defined functions are not required to have their declarations appear textually before calls to them.

+ + + +

Objects

+

Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via constructors which create objects and then execute code that initializes all or part of them by assigning initial values to their properties. Each constructor is a function that has a property named `"prototype"` that is used to implement prototype-based inheritance and shared properties. Objects are created by using constructors in new expressions; for example, `new Date(2009,11)` creates a new Date object. Invoking a constructor without using new has consequences that depend on the constructor. For example, `Date()` produces a string representation of the current date and time rather than an object.

+

Every object created by a constructor has an implicit reference (called the object's prototype) to the value of its constructor's `"prototype"` property. Furthermore, a prototype may have a non-null implicit reference to its prototype, and so on; this is called the prototype chain. When a reference is made to a property in an object, that reference is to the property of that name in the first object in the prototype chain that contains a property of that name. In other words, first the object mentioned directly is examined for such a property; if that object contains the named property, that is the property to which the reference refers; if that object does not contain the named property, the prototype for that object is examined next; and so on.

+ + An image of lots of boxes and arrows. + +

In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and inheritance is only of structure and behaviour. In ECMAScript, the state and methods are carried by objects, while structure, behaviour, and state are all inherited.

+

All objects that do not directly contain a particular property that their prototype contains share that property and its value. Figure 1 illustrates this:

+

CF is a constructor (and also an object). Five objects have been created by using `new` expressions: cf1, cf2, cf3, cf4, and cf5. Each of these objects contains properties named `q1` and `q2`. The dashed lines represent the implicit prototype relationship; so, for example, cf3's prototype is CFp. The constructor, CF, has two properties itself, named `P1` and `P2`, which are not visible to CFp, cf1, cf2, cf3, cf4, or cf5. The property named `CFP1` in CFp is shared by cf1, cf2, cf3, cf4, and cf5 (but not by CF), as are any properties found in CFp's implicit prototype chain that are not named `q1`, `q2`, or `CFP1`. Notice that there is no implicit prototype link between CF and CFp.

+

Unlike most class-based object languages, properties can be added to objects dynamically by assigning values to them. That is, constructors are not required to name or assign values to all or any of the constructed object's properties. In the above diagram, one could add a new shared property for cf1, cf2, cf3, cf4, and cf5 by assigning a new value to the property in CFp.

+

Although ECMAScript objects are not inherently class-based, it is often convenient to define class-like abstractions based upon a common pattern of constructor functions, prototype objects, and methods. The ECMAScript built-in objects themselves follow such a class-like pattern. Beginning with ECMAScript 2015, the ECMAScript language includes syntactic class definitions that permit programmers to concisely define objects that conform to the same class-like abstraction pattern used by the built-in objects.

+
+ + + +

The Strict Variant of ECMAScript

+

The ECMAScript Language recognizes the possibility that some users of the language may wish to restrict their usage of some features available in the language. They might do so in the interests of security, to avoid what they consider to be error-prone features, to get enhanced error checking, or for other reasons of their choosing. In support of this possibility, ECMAScript defines a strict variant of the language. The strict variant of the language excludes some specific syntactic and semantic features of the regular ECMAScript language and modifies the detailed semantics of some features. The strict variant also specifies additional error conditions that must be reported by throwing error exceptions in situations that are not specified as errors by the non-strict form of the language.

+

The strict variant of ECMAScript is commonly referred to as the strict mode of the language. Strict mode selection and use of the strict mode syntax and semantics of ECMAScript is explicitly made at the level of individual ECMAScript source text units. Because strict mode is selected at the level of a syntactic source text unit, strict mode only imposes restrictions that have local effect within such a source text unit. Strict mode does not restrict or modify any aspect of the ECMAScript semantics that must operate consistently across multiple source text units. A complete ECMAScript program may be composed of both strict mode and non-strict mode ECMAScript source text units. In this case, strict mode only applies when actually executing code that is defined within a strict mode source text unit.

+

In order to conform to this specification, an ECMAScript implementation must implement both the full unrestricted ECMAScript language and the strict variant of the ECMAScript language as defined by this specification. In addition, an implementation must support the combination of unrestricted and strict mode source text units into a single composite program.

+
+
\ No newline at end of file diff --git a/translated/issues-6.html b/translated/issues-6.html new file mode 100644 index 00000000000..b8581ac8f5f --- /dev/null +++ b/translated/issues-6.html @@ -0,0 +1,276 @@ + +

Terms and Definitions

+

For the purposes of this document, the following terms and definitions apply.

+ + + +

type

+

set of data values as defined in clause of this specification

+
+ + + +

primitive value

+

member of one of the types Undefined, Null, Boolean, Number, Symbol, or String as defined in clause

+ +

A primitive value is a datum that is represented directly at the lowest level of the language implementation.

+
+
+ + + +

object

+

member of the type Object

+ +

An object is a collection of properties and has a single prototype object. The prototype may be the null value.

+
+
+ + + +

constructor

+

function object that creates and initializes objects

+ +

The value of a constructor's `prototype` property is a prototype object that is used to implement inheritance and shared properties.

+
+
+ + + +

prototype

+

object that provides shared properties for other objects

+ +

When a constructor creates an object, that object implicitly references the constructor's `prototype` property for the purpose of resolving property references. The constructor's `prototype` property can be referenced by the program expression constructor.prototype, and properties added to an object's prototype are shared, through inheritance, by all objects sharing the prototype. Alternatively, a new object may be created with an explicitly specified prototype by using the `Object.create` built-in function.

+
+
+ + + +

ordinary object

+

object that has the default behaviour for the essential internal methods that must be supported by all objects

+
+ + + +

exotic object

+

object that does not have the default behaviour for one or more of the essential internal methods

+ +

Any object that is not an ordinary object is an exotic object.

+
+
+ + + +

standard object

+

object whose semantics are defined by this specification

+
+ + + +

built-in object

+

object specified and supplied by an ECMAScript implementation

+ +

Standard built-in objects are defined in this specification. An ECMAScript implementation may specify and supply additional kinds of built-in objects. A built-in constructor is a built-in object that is also a constructor.

+
+
+ + + +

undefined value

+

primitive value used when a variable has not been assigned a value

+
+ + + +

Undefined type

+

type whose sole value is the *undefined* value

+
+ + + +

null value

+

primitive value that represents the intentional absence of any object value

+
+ + + +

Null type

+

type whose sole value is the *null* value

+
+ + + +

Boolean value

+

member of the Boolean type

+ +

There are only two Boolean values, *true* and *false*.

+
+
+ + + +

Boolean type

+

type consisting of the primitive values *true* and *false*

+
+ + + +

Boolean object

+

member of the Object type that is an instance of the standard built-in `Boolean` constructor

+ +

A Boolean object is created by using the `Boolean` constructor in a `new` expression, supplying a Boolean value as an argument. The resulting object has an internal slot whose value is the Boolean value. A Boolean object can be coerced to a Boolean value.

+
+
+ + + +

String value

+

primitive value that is a finite ordered sequence of zero or more 16-bit unsigned integer values

+ +

A String value is a member of the String type. Each integer value in the sequence usually represents a single 16-bit unit of UTF-16 text. However, ECMAScript does not place any restrictions or requirements on the values except that they must be 16-bit unsigned integers.

+
+
+ + + +

String type

+

set of all possible String values

+
+ + + +

String object

+

member of the Object type that is an instance of the standard built-in `String` constructor

+ +

A String object is created by using the `String` constructor in a `new` expression, supplying a String value as an argument. The resulting object has an internal slot whose value is the String value. A String object can be coerced to a String value by calling the `String` constructor as a function ().

+
+
+ + + +

Number value

+

primitive value corresponding to a double-precision 64-bit binary format IEEE 754-2008 value

+ +

A Number value is a member of the Number type and is a direct representation of a number.

+
+
+ + + +

Number type

+

set of all possible Number values including the special “Not-a-Number” (NaN) value, positive infinity, and negative infinity

+
+ + + +

Number object

+

member of the Object type that is an instance of the standard built-in `Number` constructor

+ +

A Number object is created by using the `Number` constructor in a `new` expression, supplying a number value as an argument. The resulting object has an internal slot whose value is the number value. A Number object can be coerced to a number value by calling the `Number` constructor as a function ().

+
+
+ + + +

Infinity

+

number value that is the positive infinite number value

+
+ + + +

NaN

+

number value that is an IEEE 754-2008 “Not-a-Number” value

+
+ + + +

Symbol value

+

primitive value that represents a unique, non-String Object property key

+
+ + + +

Symbol type

+

set of all possible Symbol values

+
+ + + +

Symbol object

+

member of the Object type that is an instance of the standard built-in `Symbol` constructor

+
+ + + +

function

+

member of the Object type that may be invoked as a subroutine

+ +

In addition to its properties, a function contains executable code and state that determine how it behaves when invoked. A function's code may or may not be written in ECMAScript.

+
+
+ + + +

built-in function

+

built-in object that is a function

+ +

Examples of built-in functions include `parseInt` and `Math.exp`. An implementation may provide implementation-dependent built-in functions that are not described in this specification.

+
+
+ + + +

property

+

part of an object that associates a key (either a String value or a Symbol value) and a value

+ +

Depending upon the form of the property the value may be represented either directly as a data value (a primitive value, an object, or a function object) or indirectly by a pair of accessor functions.

+
+
+ + + +

method

+

function that is the value of a property

+ +

When a function is called as a method of an object, the object is passed to the function as its *this* value.

+
+
+ + + +

built-in method

+

method that is a built-in function

+ +

Standard built-in methods are defined in this specification, and an ECMAScript implementation may specify and provide other additional built-in methods.

+
+
+ + + +

attribute

+

internal value that defines some characteristic of a property

+
+ + + +

own property

+

property that is directly contained by its object

+
+ + + +

inherited property

+

property of an object that is not an own property but is a property (either own or inherited) of the object's prototype

+
+
+ + + +

Organization of This Specification

+

The remainder of this specification is organized as follows:

+

Clause 5 defines the notational conventions used throughout the specification.

+

Clauses 6-9 define the execution environment within which ECMAScript programs operate.

+

Clauses 10-16 define the actual ECMAScript programming language including its syntactic encoding and the execution semantics of all language features.

+

Clauses 17-26 define the ECMAScript standard library. They include the definitions of all of the standard objects that are available for use by ECMAScript programs as they execute.

+
+
\ No newline at end of file diff --git a/translated/issues-7.html b/translated/issues-7.html new file mode 100644 index 00000000000..172cb8dc9b3 --- /dev/null +++ b/translated/issues-7.html @@ -0,0 +1,266 @@ + +

Notational Conventions

+ + + +

Syntactic and Lexical Grammars

+ + + +

Context-Free Grammars

+

A context-free grammar consists of a number of productions. Each production has an abstract symbol called a nonterminal as its left-hand side, and a sequence of zero or more nonterminal and terminal symbols as its right-hand side. For each grammar, the terminal symbols are drawn from a specified alphabet.

+

A chain production is a production that has exactly one nonterminal symbol on its right-hand side along with zero or more terminal symbols.

+

Starting from a sentence consisting of a single distinguished nonterminal, called the goal symbol, a given context-free grammar specifies a language, namely, the (perhaps infinite) set of possible sequences of terminal symbols that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a production for which the nonterminal is the left-hand side.

+
+ + + +

The Lexical and RegExp Grammars

+

A lexical grammar for ECMAScript is given in clause . This grammar has as its terminal symbols Unicode code points that conform to the rules for |SourceCharacter| defined in . It defines a set of productions, starting from the goal symbol |InputElementDiv|, |InputElementTemplateTail|, or |InputElementRegExp|, or |InputElementRegExpOrTemplateTail|, that describe how sequences of such code points are translated into a sequence of input elements.

+

Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and are called ECMAScript tokens. These tokens are the reserved words, identifiers, literals, and punctuators of the ECMAScript language. Moreover, line terminators, although not considered to be tokens, also become part of the stream of input elements and guide the process of automatic semicolon insertion (). Simple white space and single-line comments are discarded and do not appear in the stream of input elements for the syntactic grammar. A |MultiLineComment| (that is, a comment of the form `/*`…`*/` regardless of whether it spans more than one line) is likewise simply discarded if it contains no line terminator; but if a |MultiLineComment| contains one or more line terminators, then it is replaced by a single line terminator, which becomes part of the stream of input elements for the syntactic grammar.

+

A RegExp grammar for ECMAScript is given in . This grammar also has as its terminal symbols the code points as defined by |SourceCharacter|. It defines a set of productions, starting from the goal symbol |Pattern|, that describe how sequences of code points are translated into regular expression patterns.

+

Productions of the lexical and RegExp grammars are distinguished by having two colons “::” as separating punctuation. The lexical and RegExp grammars share some productions.

+
+ + + +

The Numeric String Grammar

+

Another grammar is used for translating Strings into numeric values. This grammar is similar to the part of the lexical grammar having to do with numeric literals and has as its terminal symbols |SourceCharacter|. This grammar appears in .

+

Productions of the numeric string grammar are distinguished by having three colons “:::” as punctuation.

+
+ + + +

The Syntactic Grammar

+

The syntactic grammar for ECMAScript is given in clauses 11, 12, 13, 14, and 15. This grammar has ECMAScript tokens defined by the lexical grammar as its terminal symbols (). It defines a set of productions, starting from two alternative goal symbols |Script| and |Module|, that describe how sequences of tokens form syntactically correct independent components of ECMAScript programs.

+

When a stream of code points is to be parsed as an ECMAScript |Script| or |Module|, it is first converted to a stream of input elements by repeated application of the lexical grammar; this stream of input elements is then parsed by a single application of the syntactic grammar. The input stream is syntactically in error if the tokens in the stream of input elements cannot be parsed as a single instance of the goal nonterminal (|Script| or |Module|), with no tokens left over.

+

When a parse is successful, it constructs a parse tree, a rooted tree structure in which each node is a Parse Node. Each Parse Node is an instance of a symbol in the grammar; it represents a span of the source text that can be derived from that symbol. The root node of the parse tree, representing the whole of the source text, is an instance of the parse's goal symbol. When a Parse Node is an instance of a nonterminal, it is also an instance of some production that has that nonterminal as its left-hand side. Moreover, it has zero or more children, one for each symbol on the production's right-hand side: each child is a Parse Node that is an instance of the corresponding symbol.

+

Productions of the syntactic grammar are distinguished by having just one colon “:” as punctuation.

+

The syntactic grammar as presented in clauses 12, 13, 14 and 15 is not a complete account of which token sequences are accepted as a correct ECMAScript |Script| or |Module|. Certain additional token sequences are also accepted, namely, those that would be described by the grammar if only semicolons were added to the sequence in certain places (such as before line terminator characters). Furthermore, certain token sequences that are described by the grammar are not considered acceptable if a line terminator character appears in certain “awkward” places.

+

In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized productions that permit token sequences that do not form a valid ECMAScript |Script| or |Module|. For example, this technique is used for object literals and object destructuring patterns. In such cases a more restrictive supplemental grammar is provided that further restricts the acceptable token sequences. Typically, an early error rule will then define an error condition if "_P_ cannot be reparsed as an _N_", where _P_ is a Parse Node (an instance of the generalized production) and _N_ is a nonterminal from the supplemental grammar. Here, the sequence of tokens originally matched by _P_ is parsed again using _N_ as the goal symbol. (If _N_ takes grammatical parameters, then they are set to the same values used when _P_ was originally parsed.) An error occurs if the sequence of tokens cannot be parsed as a single instance of _N_, with no tokens left over. Subsequently, algorithms access the result of the parse using a phrase of the form "the result of reparsing _P_ as an _N_". This will always be a Parse Node (an instance of _N_), since any parsing failure would have been detected by an early error rule.

+
+ + + +

Grammar Notation

+

Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in `fixed width` font, both in the productions of the grammars and throughout this specification whenever the text directly refers to such a terminal symbol. These are to appear in a script exactly as written. All terminal symbol code points specified in this way are to be understood as the appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking code points from other Unicode ranges.

+

Nonterminal symbols are shown in italic type. The definition of a nonterminal (also called a “production”) is introduced by the name of the nonterminal being defined followed by one or more colons. (The number of colons indicates to which grammar the production belongs.) One or more alternative right-hand sides for the nonterminal then follow on succeeding lines. For example, the syntactic definition:

+ + WhileStatement : + `while` `(` Expression `)` Statement + +

states that the nonterminal |WhileStatement| represents the token `while`, followed by a left parenthesis token, followed by an |Expression|, followed by a right parenthesis token, followed by a |Statement|. The occurrences of |Expression| and |Statement| are themselves nonterminals. As another example, the syntactic definition:

+ + ArgumentList : + AssignmentExpression + ArgumentList `,` AssignmentExpression + +

states that an |ArgumentList| may represent either a single |AssignmentExpression| or an |ArgumentList|, followed by a comma, followed by an |AssignmentExpression|. This definition of |ArgumentList| is recursive, that is, it is defined in terms of itself. The result is that an |ArgumentList| may contain any positive number of arguments, separated by commas, where each argument expression is an |AssignmentExpression|. Such recursive definitions of nonterminals are common.

+

The subscripted suffix “opt”, which may appear after a terminal or nonterminal, indicates an optional symbol. The alternative containing the optional symbol actually specifies two right-hand sides, one that omits the optional element and one that includes it. This means that:

+ + VariableDeclaration : + BindingIdentifier Initializer? + +

is a convenient abbreviation for:

+ + VariableDeclaration : + BindingIdentifier + BindingIdentifier Initializer + +

and that:

+ + IterationStatement : + `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement + +

is a convenient abbreviation for:

+ + IterationStatement : + `for` `(` LexicalDeclaration `;` Expression? `)` Statement + `for` `(` LexicalDeclaration Expression `;` Expression? `)` Statement + +

which in turn is an abbreviation for:

+ + IterationStatement : + `for` `(` LexicalDeclaration `;` `)` Statement + `for` `(` LexicalDeclaration `;` Expression `)` Statement + `for` `(` LexicalDeclaration Expression `;` `)` Statement + `for` `(` LexicalDeclaration Expression `;` Expression `)` Statement + +

so, in this example, the nonterminal |IterationStatement| actually has four alternative right-hand sides.

+

A production may be parameterized by a subscripted annotation of the form “[parameters]”, which may appear as a suffix to the nonterminal symbol defined by the production. “parameters” may be either a single name or a comma separated list of names. A parameterized production is shorthand for a set of productions defining all combinations of the parameter names, preceded by an underscore, appended to the parameterized nonterminal symbol. This means that:

+ + StatementList[Return] : + ReturnStatement + ExpressionStatement + +

is a convenient abbreviation for:

+ + StatementList : + ReturnStatement + ExpressionStatement + + StatementList_Return : + ReturnStatement + ExpressionStatement + +

and that:

+ + StatementList[Return, In] : + ReturnStatement + ExpressionStatement + +

is an abbreviation for:

+ + StatementList : + ReturnStatement + ExpressionStatement + + StatementList_Return : + ReturnStatement + ExpressionStatement + + StatementList_In : + ReturnStatement + ExpressionStatement + + StatementList_Return_In : + ReturnStatement + ExpressionStatement + +

Multiple parameters produce a combinatory number of productions, not all of which are necessarily referenced in a complete grammar.

+

References to nonterminals on the right-hand side of a production can also be parameterized. For example:

+ + StatementList : + ReturnStatement + ExpressionStatement[+In] + +

is equivalent to saying:

+ + StatementList : + ReturnStatement + ExpressionStatement_In + +

and:

+ + StatementList : + ReturnStatement + ExpressionStatement[~In] + +

is equivalent to:

+ + StatementList : + ReturnStatement + ExpressionStatement + +

A nonterminal reference may have both a parameter list and an “opt” suffix. For example:

+ + VariableDeclaration : + BindingIdentifier Initializer[+In]? + +

is an abbreviation for:

+ + VariableDeclaration : + BindingIdentifier + BindingIdentifier Initializer_In + +

Prefixing a parameter name with “?” on a right-hand side nonterminal reference makes that parameter value dependent upon the occurrence of the parameter name on the reference to the current production's left-hand side symbol. For example:

+ + VariableDeclaration[In] : + BindingIdentifier Initializer[?In] + +

is an abbreviation for:

+ + VariableDeclaration : + BindingIdentifier Initializer + + VariableDeclaration_In : + BindingIdentifier Initializer_In + +

If a right-hand side alternative is prefixed with “[+parameter]” that alternative is only available if the named parameter was used in referencing the production's nonterminal symbol. If a right-hand side alternative is prefixed with “[\~parameter]” that alternative is only available if the named parameter was not used in referencing the production's nonterminal symbol. This means that:

+ + StatementList[Return] : + [+Return] ReturnStatement + ExpressionStatement + +

is an abbreviation for:

+ + StatementList : + ExpressionStatement + + StatementList_Return : + ReturnStatement + ExpressionStatement + +

and that:

+ + StatementList[Return] : + [~Return] ReturnStatement + ExpressionStatement + +

is an abbreviation for:

+ + StatementList : + ReturnStatement + ExpressionStatement + + StatementList_Return : + ExpressionStatement + +

When the words “one of” follow the colon(s) in a grammar definition, they signify that each of the terminal symbols on the following line or lines is an alternative definition. For example, the lexical grammar for ECMAScript contains the production:

+ + NonZeroDigit :: one of + `1` `2` `3` `4` `5` `6` `7` `8` `9` + +

which is merely a convenient abbreviation for:

+ + NonZeroDigit :: + `1` + `2` + `3` + `4` + `5` + `6` + `7` + `8` + `9` + +

If the phrase “[empty]” appears as the right-hand side of a production, it indicates that the production's right-hand side contains no terminals or nonterminals.

+

If the phrase “[lookahead ∉ _set_]” appears in the right-hand side of a production, it indicates that the production may not be used if the immediately following input token sequence is a member of the given _set_. The _set_ can be written as a comma separated list of one or two element terminal sequences enclosed in curly brackets. For convenience, the set can also be written as a nonterminal, in which case it represents the set of all terminals to which that nonterminal could expand. If the _set_ consists of a single terminal the phrase “[lookahead ≠ _terminal_]” may be used.

+

For example, given the definitions:

+ + DecimalDigit :: one of + `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + + DecimalDigits :: + DecimalDigit + DecimalDigits DecimalDigit + +

the definition:

+ + LookaheadExample :: + `n` [lookahead <! {`1`, `3`, `5`, `7`, `9`}] DecimalDigits + DecimalDigit [lookahead <! DecimalDigit] + +

matches either the letter `n` followed by one or more decimal digits the first of which is even, or a decimal digit not followed by another decimal digit.

+

Similarly, if the phrase “[lookahead ∈ _set_]” appears in the right-hand side of a production, it indicates that the production may only be used if the immediately following input token sequence is a member of the given _set_. If the _set_ consists of a single terminal the phrase “[lookahead = _terminal_]” may be used.

+

If the phrase “[no |LineTerminator| here]” appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is a restricted production: it may not be used if a |LineTerminator| occurs in the input stream at the indicated position. For example, the production:

+ + ThrowStatement : + `throw` [no LineTerminator here] Expression `;` + +

indicates that the production may not be used if a |LineTerminator| occurs in the script between the `throw` token and the |Expression|.

+

Unless the presence of a |LineTerminator| is forbidden by a restricted production, any number of occurrences of |LineTerminator| may appear between any two consecutive tokens in the stream of input elements without affecting the syntactic acceptability of the script.

+

When an alternative in a production of the lexical grammar or the numeric string grammar appears to be a multi-code point token, it represents the sequence of code points that would make up such a token.

+

The right-hand side of a production may specify that certain expansions are not permitted by using the phrase “but not” and then indicating the expansions to be excluded. For example, the production:

+ + Identifier :: + IdentifierName but not ReservedWord + +

means that the nonterminal |Identifier| may be replaced by any sequence of code points that could replace |IdentifierName| provided that the same sequence of code points could not replace |ReservedWord|.

+

Finally, a few nonterminal symbols are described by a descriptive phrase in sans-serif type in cases where it would be impractical to list all the alternatives:

+ + SourceCharacter :: + > any Unicode code point + +
+
\ No newline at end of file diff --git a/translated/issues-8.html b/translated/issues-8.html new file mode 100644 index 00000000000..511872c4a16 --- /dev/null +++ b/translated/issues-8.html @@ -0,0 +1,187 @@ + +

Algorithm Conventions

+

The specification often uses a numbered list to specify steps in an algorithm. These algorithms are used to precisely specify the required semantics of ECMAScript language constructs. The algorithms are not intended to imply the use of any specific implementation technique. In practice, there may be more efficient algorithms available to implement a given feature.

+

Algorithms may be explicitly parameterized, in which case the names and usage of the parameters must be provided as part of the algorithm's definition.

+

Algorithm steps may be subdivided into sequential substeps. Substeps are indented and may themselves be further divided into indented substeps. Outline numbering conventions are used to identify substeps with the first level of substeps labelled with lower case alphabetic characters and the second level of substeps labelled with lower case roman numerals. If more than three levels are required these rules repeat with the fourth level using numeric labels. For example:

+ + 1. Top-level step + 1. Substep. + 1. Substep. + 1. Subsubstep. + 1. Subsubsubstep + 1. Subsubsubsubstep + 1. Subsubsubsubsubstep + +

A step or substep may be written as an “if” predicate that conditions its substeps. In this case, the substeps are only applied if the predicate is true. If a step or substep begins with the word “else”, it is a predicate that is the negation of the preceding “if” predicate step at the same level.

+

A step may specify the iterative application of its substeps.

+

A step that begins with “Assert:” asserts an invariant condition of its algorithm. Such assertions are used to make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements and hence need not be checked by an implementation. They are used simply to clarify algorithms.

+

Algorithm steps may declare named aliases for any value using the form “Let _x_ be _someValue_”. These aliases are reference-like in that both _x_ and _someValue_ refer to the same underlying data and modifications to either are visible to both. Algorithm steps that want to avoid this reference-like behaviour should explicitly make a copy of the right-hand side: “Let _x_ be a copy of _someValue_” creates a shallow copy of _someValue_.

+

Once declared, an alias may be referenced in any subsequent steps and must not be referenced from steps prior to the alias's declaration. Aliases may be modified using the form “Set _x_ to _someOtherValue_”.

+ + +

Abstract Operations

+

In order to facilitate their use in multiple parts of this specification, some algorithms, called abstract operations, are named and written in parameterized functional form so that they may be referenced by name from within other algorithms. Abstract operations are typically referenced using a functional application style such as OperationName(_arg1_, _arg2_). Some abstract operations are treated as polymorphically dispatched methods of class-like specification abstractions. Such method-like abstract operations are typically referenced using a method application style such as _someValue_.OperationName(_arg1_, _arg2_).

+
+ + +

Syntax-Directed Operations

+

A syntax-directed operation is a named operation whose definition consists of algorithms, each of which is associated with one or more productions from one of the ECMAScript grammars. A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative. When an algorithm is associated with a grammar production, it may reference the terminal and nonterminal symbols of the production alternative as if they were parameters of the algorithm. When used in this manner, nonterminal symbols refer to the actual alternative definition that is matched when parsing the source text.

+

When an algorithm is associated with a production alternative, the alternative is typically shown without any “[ ]” grammar annotations. Such annotations should only affect the syntactic recognition of the alternative and have no effect on the associated semantics for the alternative.

+

Syntax-directed operations are invoked with a parse node and, optionally, other parameters by using the conventions on steps 1, 3, and 4 in the following algorithm:

+ + 1. Let _status_ be the result of performing SyntaxDirectedOperation of |SomeNonTerminal|. + 2. Let _someParseNode_ be the parse of some source text. + 2. Perform SyntaxDirectedOperation of _someParseNode_. + 2. Perform SyntaxDirectedOperation of _someParseNode_ passing `"value"` as the argument. + +

Unless explicitly specified otherwise, all chain productions have an implicit definition for every operation that might be applied to that production's left-hand side nonterminal. The implicit definition simply reapplies the same operation with the same parameters, if any, to the chain production's sole right-hand side nonterminal and then returns the result. For example, assume that some algorithm has a step of the form: “Return the result of evaluating |Block|” and that there is a production:

+ + Block : + `{` StatementList `}` + +

but the Evaluation operation does not associate an algorithm with that production. In that case, the Evaluation operation implicitly includes an association of the form:

+

Runtime Semantics: Evaluation

+ Block : `{` StatementList `}` + + 1. Return the result of evaluating |StatementList|. + +
+ + + +

Runtime Semantics

+

Algorithms which specify semantics that must be called at runtime are called runtime semantics. Runtime semantics are defined by abstract operations or syntax-directed operations. Such algorithms always return a completion record.

+ +

Implicit Completion Values

+

The algorithms of this specification often implicitly return Completion Records whose [[Type]] is ~normal~. Unless it is otherwise obvious from the context, an algorithm statement that returns a value that is not a Completion Record, such as:

+ + 1. Return `"Infinity"`. + +

means the same thing as:

+ + 1. Return NormalCompletion(`"Infinity"`). + +

However, if the value expression of a “return” statement is a Completion Record construction literal, the resulting Completion Record is returned. If the value expression is a call to an abstract operation, the “return” statement simply returns the Completion Record produced by the abstract operation.

+

The abstract operation Completion(_completionRecord_) is used to emphasize that a previously computed Completion Record is being returned. The Completion abstract operation takes a single argument, _completionRecord_, and performs the following steps:

+ + 1. Assert: _completionRecord_ is a Completion Record. + 1. Return _completionRecord_ as the Completion Record of this abstract operation. + +

A “return” statement without a value in an algorithm step means the same thing as:

+ + 1. Return NormalCompletion(*undefined*). + +

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

+
+ + + +

Throw an Exception

+

Algorithms steps that say to throw an exception, such as

+ + 1. Throw a *TypeError* exception. + +

mean the same things as:

+ + 1. Return Completion{[[Type]]: ~throw~, [[Value]]: a newly created *TypeError* object, [[Target]]: ~empty~}. + +
+ + + +

ReturnIfAbrupt

+

Algorithms steps that say or are otherwise equivalent to:

+ + 1. ReturnIfAbrupt(_argument_). + +

mean the same thing as:

+ + 1. If _argument_ is an abrupt completion, return _argument_. + 1. Else if _argument_ is a Completion Record, let _argument_ be _argument_.[[Value]]. + +

Algorithms steps that say or are otherwise equivalent to:

+ + 1. ReturnIfAbrupt(AbstractOperation()). + +

mean the same thing as:

+ + 1. Let _hygienicTemp_ be AbstractOperation(). + 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. + 1. Else if _hygienicTemp_ is a Completion Record, let _hygienicTemp_ be _hygienicTemp_.[[Value]]. + +

Where _hygienicTemp_ is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt.

+

Algorithms steps that say or are otherwise equivalent to:

+ + 1. Let _result_ be AbstractOperation(ReturnIfAbrupt(_argument_)). + +

mean the same thing as:

+ + 1. If _argument_ is an abrupt completion, return _argument_. + 1. If _argument_ is a Completion Record, let _argument_ be _argument_.[[Value]]. + 1. Let _result_ be AbstractOperation(_argument_). + +
+ +

ReturnIfAbrupt Shorthands

+

Invocations of abstract operations and syntax-directed operations that are prefixed by `?` indicate that ReturnIfAbrupt should be applied to the resulting Completion Record. For example, the step:

+ + 1. ? OperationName(). + +

is equivalent to the following step:

+ + 1. ReturnIfAbrupt(OperationName()). + +

Similarly, for method application style, the step:

+ + 1. ? _someValue_.OperationName(). + +

is equivalent to:

+ + 1. ReturnIfAbrupt(_someValue_.OperationName()). + +

Similarly, prefix `!` is used to indicate that the following invocation of an abstract or syntax-directed operation will never return an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation. For example, the step:

+ + 1. Let _val_ be ! OperationName(). + +

is equivalent to the following steps:

+ + 1. Let _val_ be OperationName(). + 1. Assert: _val_ is never an abrupt completion. + 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. + +

Syntax-directed operations for runtime semantics make use of this shorthand by placing `!` or `?` before the invocation of the operation:

+ + 1. Perform ! SyntaxDirectedOperation of |NonTerminal|. + +
+
+ + +

Static Semantics

+

Context-free grammars are not sufficiently powerful to express all the rules that define whether a stream of input elements form a valid ECMAScript |Script| or |Module| that may be evaluated. In some situations additional rules are needed that may be expressed using either ECMAScript algorithm conventions or prose requirements. Such rules are always associated with a production of a grammar and are called the static semantics of the production.

+

Static Semantic Rules have names and typically are defined using an algorithm. Named Static Semantic Rules are associated with grammar productions and a production that has multiple alternative definitions will typically have for each alternative a distinct algorithm for each applicable named static semantic rule.

+

Unless otherwise specified every grammar production alternative in this specification implicitly has a definition for a static semantic rule named Contains which takes an argument named _symbol_ whose value is a terminal or nonterminal of the grammar that includes the associated production. The default definition of Contains is:

+ + 1. For each child node _child_ of this Parse Node, do + 1. If _child_ is an instance of _symbol_, return *true*. + 1. If _child_ is an instance of a nonterminal, then + 1. Let _contained_ be the result of _child_ Contains _symbol_. + 1. If _contained_ is *true*, return *true*. + 1. Return *false*. + +

The above definition is explicitly over-ridden for specific productions.

+

A special kind of static semantic rule is an Early Error Rule. Early error rules define early error conditions (see clause ) that are associated with specific grammar productions. Evaluation of most early error rules are not explicitly invoked within the algorithms of this specification. A conforming implementation must, prior to the first evaluation of a |Script| or |Module|, validate all of the early error rules of the productions used to parse that |Script| or |Module|. If any of the early error rules are violated the |Script| or |Module| is invalid and cannot be evaluated.

+
+ +

Mathematical Operations

+

Mathematical operations such as addition, subtraction, negation, multiplication, division, and the mathematical functions defined later in this clause should always be understood as computing exact mathematical results on mathematical real numbers, which unless otherwise noted do not include infinities and do not include a negative zero that is distinguished from positive zero. Algorithms in this standard that model floating-point arithmetic include explicit steps, where necessary, to handle infinities and signed zero and to perform rounding. If a mathematical operation or function is applied to a floating-point number, it should be understood as being applied to the exact mathematical value represented by that floating-point number; such a floating-point number must be finite, and if it is *+0* or *-0* then the corresponding mathematical value is simply 0.

+

The mathematical function abs(_x_) produces the absolute value of _x_, which is -_x_ if _x_ is negative (less than zero) and otherwise is _x_ itself.

+

The mathematical function min(_x1_, _x2_, ..., _xN_) produces the mathematically smallest of _x1_ through _xN_. The mathematical function max(_x1_, _x2_, ..., _xN_) produces the mathematically largest of _x1_ through _xN_. The domain and range of these mathematical functions include *+∞* and *-∞*.

+

The notation “_x_ modulo _y_” (_y_ must be finite and nonzero) computes a value _k_ of the same sign as _y_ (or zero) such that abs(_k_) < abs(_y_) and _x_-_k_ = _q_ × _y_ for some integer _q_.

+

The mathematical function floor(_x_) produces the largest integer (closest to positive infinity) that is not larger than _x_.

+ +

floor(_x_) = _x_-(_x_ modulo 1).

+
+
+
+
\ No newline at end of file