Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS3Parser - proposed new syntax #237

Open
hydroper opened this issue Apr 11, 2024 · 1 comment
Open

AS3Parser - proposed new syntax #237

hydroper opened this issue Apr 11, 2024 · 1 comment

Comments

@hydroper
Copy link

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.

@joshtynjala joshtynjala changed the title AS3Parser AS3Parser - proposed new syntax Apr 11, 2024
@hydroper
Copy link
Author

hydroper commented Apr 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants