February 1999 Draft
JavaScript 2.0
upnext

Tuesday, February 16, 1999

Introduction

JavaScript 2.0 is an experimental proposal maintained by waldemar for future changes in the JavaScript language. At this stage the emphasis is on developing the broad concepts of the language; many of the details will be worked out later. The eventual language may differ significantly from this proposal, but the goal is to move in the directions indicated here and do so via a coordinated plan rather than adding miscellaneous features ad hoc on a release-by-release basis.

Notation

Informal Syntax

The main body of this proposal uses an informal syntax to describe language constructs. An example is the following:

VersionsAndRenames 
   [< VersionRange [: Identifier, ... , VersionRange [: Identifier>]
VersionRange 
   Version
|  [Version.. [Version]

VersionsAndRenames and VersionRange are the names of the grammar rules. The black square brackets represent optional items, and the black ... together with its neighbors represents optional repetition of zero or more items, so a VersionsAndRenames can have zero or more sets of VersionRange [: Identifier] separated by commas. A black | indicates that either its left or right alternative may be present, but not both; |'s have the lowest metasymbol precedence. Syntactic tokens to be typed literally are in a bold blue monospaced font. Grammar nonterminals are in green italic and correspond to the nonterminals in the grammar appendix.

The informal syntax descriptions sometimes list only the general or simplified syntax. Please refer to the grammar appendix for the actual syntax.

Grammar Syntax

The LR(1) grammar rules have the format shown below. All of the grammar rules are listed in the grammar appendix.

SampleList 
   «empty»
|  ... Identifier
|  SampleListPrefix
|  SampleListPrefix , ... Identifier

This sample rule states that the nonterminal SampleList can represent one of four kinds of sequences of program tokens:

A number of rules in the grammar occur in groups of analogous rules. Rather than list them individually, these groups have been summarized using the shorthand illustrated by the example below:

Metastatements such as

   {normalinitial}
   {allowInnoIn}

introduce grammar arguments and . If these arguments later parametrize the nonterminal on the left side of a rule, that rule is implicitly replicated into a set of rules in each of which a grammar argument is consistently substituted by one of its variants. For example,

AssignmentExpression, 
   ConditionalExpression,
|  LeftSideExpression = AssignmentExpressionnormal,
|  LeftSideExpression CompoundAssignment AssignmentExpressionnormal,

expands into the following four rules:

AssignmentExpressionnormal,allowIn 
   ConditionalExpressionnormal,allowIn
|  LeftSideExpressionnormal = AssignmentExpressionnormal,allowIn
|  LeftSideExpressionnormal CompoundAssignment AssignmentExpressionnormal,allowIn
AssignmentExpressionnormal,noIn 
   ConditionalExpressionnormal,noIn
|  LeftSideExpressionnormal = AssignmentExpressionnormal,noIn
|  LeftSideExpressionnormal CompoundAssignment AssignmentExpressionnormal,noIn
AssignmentExpressioninitial,allowIn 
   ConditionalExpressioninitial,allowIn
|  LeftSideExpressioninitial = AssignmentExpressionnormal,allowIn
|  LeftSideExpressioninitial CompoundAssignment AssignmentExpressionnormal,allowIn
AssignmentExpressioninitial,noIn 
   ConditionalExpressioninitial,noIn
|  LeftSideExpressioninitial = AssignmentExpressionnormal,noIn
|  LeftSideExpressioninitial CompoundAssignment AssignmentExpressionnormal,noIn

AssignmentExpressionnormal,allowIn is now an unparametrized nonterminal and processed normally by the grammar.

Some of the expanded rules (such as the fourth one in the example above) may be unreachable from the starting nonterminal Program; these are ignored.


Waldemar Horwat
Last modified Tuesday, February 16, 1999
upnext