royale-compiler icon indicating copy to clipboard operation
royale-compiler copied to clipboard

AS3Parser - proposed new syntax

Open hydroper opened this issue 1 year ago • 1 comments

I've really covered a lot of cases in AS3Parser, fixed a lot of bugs as I could see in demo (mostly related to error recovery), and introduced both CONFIG::X { ... } (parses inner with same parent directive context) and a multiple branching configuration { ... } directive (if-else).

configuration {
    if (FOO::EXAMPLE=bar) {
        /* Action */
    } else if (ANOTHER_CONST) {
        /* Action */
    } else {
        /* Action */
    }
}

Demo

It would be nice if Apache Royale takes into consideration the syntactic features introduced in AS3Parser.

New Syntax

Processing Deviations

In short, I try to introduce solely syntactic features that conform to ECMAScript 4 and Java dialects. The only processing deviation is the include directive which does not concatenate text, but contributes syntactic nodes instead, maintaining lines and columns.

hydroper avatar Apr 11 '24 21:04 hydroper

I've done a few definitive changes so far.

Function bodies

  • Function bodies consisting of an expression: an expression is consumed only if one of the following conditions are met:
    • The offending token is inline.
    • The offending token of the expression is in a line whose indentation is higher than that of the previous token.
    • The offending token of the expression is (.

This is to avoid issues with expressions not belonging to the body of a native or abstract method.

Removed Syntax

I have removed the new embed { ... } expression as it is inconsistent with the Embed meta-data, and it is not very useful in practice, I realize it myself.

Parser Updates

I've finished a CSS parser (I'm backwards to Royale in terms of function calls such as {x}-gradient(...), but I believe it's straightforward to support their syntax).

I've made the diagnostics very flexible as well, taking arbitrary arguments without much cumbersome in Rust (diagarg![...] macro), and approximated them more to Flex messages.

There have been a number of improvements, error recovery reinforcements, bug fixes, interface changes, name changes. A lot of refactoring and lots of weird things have gone off.

v1.0.0 released.

Also, if you want a Rust introduction, I've wrote a detailed quickstart at the wiki.

hydroper avatar Apr 27 '24 16:04 hydroper