Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hydroper committed Apr 28, 2024
1 parent 6d53ecc commit 4ab1bc9
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 17 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ActionScript 3 parser in the Rust language.

[Getting started](docs/getting-started.md)

[Working with diagnostics](docs/diagnostics.md)
[Working with Diagnostics](docs/diagnostics.md)

[Working with locations](docs/locations.md)
[Working with Locations](docs/locations.md)

[Working with MXML](docs/working-with-mxml.md)

Expand All @@ -33,20 +33,12 @@ ActionScript 3 parser in the Rust language.

[Processing Deviations](docs/processing-deviations.md)

[Building a Compiler](docs/building-a-compiler.md)

## Wiki

The [wiki](https://github.com/hydroper/as3parser/wiki) of this repository contains other introductory articles.

## Compiler

An ActionScript compiler does more than just parsing, including verification, and SWF and SWC processing.

An ActionScript compiler handles three source file formats: ActionScript 3, MXML, and CSS.

An ActionScript compiler outputs several problems, constructs a flow graph for every activation, and attaches meaning to tree nodes.

This project itself is not a compiler, but it's designated to facilitate writing one, parsing the three file formats mentioned.

## License

Apache License 2.0, copyright 2024 Hydroper
27 changes: 27 additions & 0 deletions docs/building-a-compiler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Building a Compiler

An ActionScript compiler does more than just parsing, including verification, and SWF and SWC processing.

An ActionScript compiler handles three source file formats: ActionScript 3, MXML, and CSS.

An ActionScript compiler outputs several problems, constructs a flow graph for every activation, and attaches meaning to tree nodes.

This project itself is not a compiler, but it's designated to facilitate writing one, parsing the three file formats mentioned.

## SWF

The Ruffle player contains a [`swf` package](https://github.com/ruffle-rs/ruffle/tree/master/swf) that reads and writes SWF from or into structures.

## Domain Memory Operations

Detect [domain memory operations](https://obtw.wordpress.com/2013/04/03/making-bytearray-faster) to generate optimized AVM2 instructions.

## Project Configuration

It is interesting to consider allowing project configurations in a dependency managed manner. Something similiar to `asconfig.json` from the Visual Studio AS&MXML extension, but in a different way to allow dependencies that include their own ActionScript 3 configuration (including options such as `strict`, and `inferTypes`).

## Special Cases

Here is the [Special Cases](compilers/special-cases.md) document.

Here is the [IDE](compilers/ide.md) document.
5 changes: 5 additions & 0 deletions docs/compilers/ide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# IDE

## Verification

If the last verification fails due to any syntax errors, keep the semantic database and node tree from the last verification.
111 changes: 111 additions & 0 deletions docs/compilers/special-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Special cases

## Strict

Strict mode (default) or ECMAScript mode.

## Infer types

Optional infer types option introduced by Apache Royale.

Infers for initializers and method result types.

## Reference lookups in source path list

Similiar to `--source-path` in the MXML compiler, and optional main class file.

This form of reference lookup does not allow zero or more than one package definition in a file, and the definition at the package must match exactly the source path in the source tree.

## Reference lookups in included sources list

Similiar to `--include-sources` (recursive directory or specific file) and `--doc-sources` in the MXML compiler.

This form of reference lookup allows multiple package definitions within a file.

## Embed meta-data

HARMAN introduced additional forms of embedding data with encryption.

## Vector Data Type

[Information](https://github.com/hydroper/as3parser/blob/0.3/docs/verifier/vector.md)

## Namespaces

[Information](https://github.com/hydroper/as3parser/blob/0.3/docs/verifier/Type/kinds/namespace.md)

Remember of `static protected`.

## Event meta-data

Used by MXML components for event handling. For example, consider the `creationComplete="someCall()"` attribute in a XML file, containing zero or more directives.

## Data binding

Certain property attributes in MXML components may have values containing at most one braces group, containing a single expression that locates a bindable property.

Example from Apache Royale:

```xml
<j:TextInput id="databinding_ti">
<j:beads>
<j:TextPrompt prompt="Using databinding"/>
</j:beads>
</j:TextInput>

<j:Label text="The TextInput field text value is: {databinding_ti.text}"/>
```

What about string literals, in case you want to escape the braces? Supporting them might not be an issue.

## Royale meta-data

[See all Royale meta-data here](https://apache.github.io/royale-docs/features/as3/metadata)

## Inline constants

Inline constants are replaced by their compile-time constant value.

```
CONFIG::DEBUG
```

## Scope

```as3
package {
import flash.display.Sprite;
// Definitions may be nested in blocks.
{
public class Main extends Sprite {
{
protected var xy: *
}
}
}
}
var x: Number
{
class Example {
function f(): void {
// "x" is visible at this scope.
x
}
}
}
// "Example" is visible at this scope.
Example
```

## Float class

[Information](https://github.com/airsdk/Adobe-Runtime-Support/discussions/3081#discussioncomment-9091556)

## Package Shadowing

Properties from imported packages, when fully qualified, shadow variable names in scope.

## Importing ActionScript 3 components in MXML

* Use a `xmlns` prefix assigned to the full package name with a trailling `.*` sequence, as in `xmlns:fb="foo.bar.*"`.
* Use the `import` directive in a `fx:Script` tag and refer lexically to a component in the MXML.
6 changes: 1 addition & 5 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ The parser attaches ASDoc comments to supported elements and recognizes tags bef
* Annotatable directives can contain an ASDoc comment
* Package definitions can contain an ASDoc comment

## Building your own compiler

* **Verifier**: the `as3_parser` project is currently not integrated with a verifier, so you would need to build one yourself. A verifier yields verify errors, control flow graphs, and symbols.
* **Reading and writing SWFs**: the Ruffle player contains a [`swf` package](https://github.com/ruffle-rs/ruffle/tree/master/swf) that reads and writes SWF from/into structures.
* Detect [domain memory operations](https://obtw.wordpress.com/2013/04/03/making-bytearray-faster) to generate optimized AVM2 instructions.
Source location is fully available within ASDoc comments. For display texts, the location always ranges from the tag at-character to the last non whitespace character.

0 comments on commit 4ab1bc9

Please sign in to comment.