Skip to content

Compliance

Matheus Dias de Souza edited this page May 11, 2024 · 2 revisions

The parser parses not only common constructs of ActionScript 3, but fully complies to the ActionScript 3.0 specification and also supports syntactic constructs from the ASC 2.0 and Flex compiler which are not included in the ActionScript 3.0 specification.

Meta-data

Meta-data are translated from certain array literals and computed members ([...][...]).

Certain meta-data such as Event and SkinPart may be preceded by their own ASDoc comment.

In the case of conditional compilation, meta-data may be preceded by a constant such as CONFIG::DEBUG (more formally, NS::NAME), always handling ASDoc comments correctly.

ASDoc

ASDoc comments precede packages, properties, classes, and certain meta-data.

For most meta-data, the respective ASDoc comment propagates to the respective property or class.

For all ASDoc comments, full locations are available:

  • For tags, any text sections have the source location spanning from the @ tag character to the last non-whitespace.
  • For the main body, the text section has the source location spanning from the first non-whitespace to the last non-whitespace.
  • For tags containing ActionScript references, the expression nodes have the source location where they appeared in the ASDoc comment relative to the enclosing compilation unit.
  • Tags such as @copy and @see support a reference with an optional instance property fragment (#x or #q::x), which is composed of a qualified identifier located in the enclosing compilation unit.

Attribute combination

The attributes before a definition such as var or class are complex compared to these in other languages:

  • Any Identifier followed by zero or more PropertyOperator are "expression" attributes indicating a namespace as an access modifier.
  • Attributes may be in any order.

An attribute combination is ambiguous with a directive in certain ways:

  • Use of identifier as attributes that are context keywords
  • Use of array initializer and brackets expressions as meta-data

An attribute combination may only be valid when it meets one of the following conditions:

  • It includes two or more attributes that are not meta-data
  • It is followed by the context keyword of an annotatable directive
  • It is followed by the reserved word of an annotatable directive.

Meta-data always appear in the beginning of the attribute combination.

Full source locations are retained for each attribute. For meta-data, the brackets are excluded from the location.

Conditional compilation

A NS::NAME followed by either an annotatable directive or a block, is parsed as a NormalConfigurationDirective.

It is called "normal" because there is another directive for conditional compilation, configuration { ... }, introduced by this parser, which supports if-else branches and specific conditional expressions.

E4X

Ambiguities are properly resolved between qualified identifiers (q::x) and the filter operator.

E4X is properly parsed, including the InputElementXMLTag and InputElementXMLContent input goals.

ECMAScript 4

Most additional syntactic forms in the parser are ECMAScript 4 features:

  • Destructuring patterns (in variable bindings and assignment left-hand sides, such as const { x } = o)
  • switch type
  • Function type (function(T1, T2=, ...[T]): T)

They are fully documented in the "New Syntax" document of this repository.