Releases: hydroper/as3parser
1.0.0
0.5.28
CSS
The CSS parser is now in place. I ended up handmaking it like the other parsers instead of using a parser generator.
It probably does not parse new features from Apache Royale, but it should be straightforward to support them.
To be honest, CSS is just not properly documented, but it should comply finely with Flex.
Fixed bugs
- The demo was looking to not work okay because I've found out I accidentally caused fatal exceptions in the Rust code due to typos (addition in location offsets). If you perceived something weird, it is probably fixed now, and it should always parse, regardless of incorrectly put characters.
Optionality
Parser methods now always return, therefore not returning a Result<_, ParserError>
variant.
Tokens
Lots of renamings were done and token names are now more beautiful.
Diagnostics
Replaced custom_id
by custom_kind
in diagnostics, holding a Rc<dyn Any>
value, typically an enumeration's variant.
Diagnostic arguments are now much cleaner as well. The diagarg!
literal may be used to insert arbitrary arguments that implement DiagnosticArgument
.
v0.5.13
Error recovery
- Mostly non-greedy expectations
- Subsequent sections of expectation error are ignored
// 1:3: Expecting either a semicolon or a new line here.
aNS aNS
// OK
aNS function f() {}
// 1:5: Duplicate access modifier.
aNS aNS function f() {}
// 2:11: Expecting identifier before close-parenthesis.
// 3:11: Expecting identifier before close-parenthesis.
switch type (v) {
case () {}
case () {}
}
Problem messages
The problem messages and the token names match a bit more of these in ASC 2.0, turning out more elegant.
Function bodies
function
bodies consisting of an expression now have an additional indentation rule for avoiding conflict with expressions not belonging to the body, such as for native
and abstract
methods. The recommendation is for function definitions consisting of an expression body to use a "trailing" semicolon to prevent meta-data mistreated as a computed member.
Location enhancements
- ASDoc comment locations now span from the boundaries of the delimiters.
MXML
- Attributes consisting of more than one colon report an error.
xmlns
andxmlns:
attributes are traversed before all other attributes.
Bug fixes
InputElementXMLTag
was having a possible infinite loop due to not including an end-of-file token.- Processing instruction in MXML was mishandled. It was not reporting errors properly for the attributes.
Forgeries
The following forgeries were resolved:
- The version 0.4 of this parser was a port of another parser of my another project that changed considerably. The same parser of that other project was based on the version 0.3 of this same parser, which changed totally. I had forgot to remove certain things, such as the
@event
ASDoc tag which does not exist (only@eventType
exists). - There was an ASDoc tag (
@eventType
) that receives an ActionScript 3 reference that I forgot to parse correctly.
Rust changes
Now the various static methods of the Attribute
structure that take a list of attributes take them as a &[T]
borrow rather than a &Vec<T>
borrow.
Demo
Now the demo has an "Source Form" option allowing to parse input as either ActionScript 3 or MXML. In the future, CSS may be included.
The MXML tree includes namespace mappings which are hidden in the output tree.
v0.5.1
Specific range of characters
Now, the parser is able to parse a specific range of characters from an existing compilation unit by passing the byte_range
option.
let parser = ParserFacade(&compilation_unit, ParserOptions {
byte_range: Some((first_offset, last_offset)),
..default()
});
if let Some(directives) = parser.parse_directives(context) {
// Action
}
The following restrictions were shifted off thanks to this:
- You had to create a different compilation unit when parsing, for example, ActionScript 3 nested in XML.
- The parser itself used to create different compilation units for parsing ActionScript 3 references inside ASDoc. This is now solved by simply passing the above
byte_range
options.
Structure changes
There were a number of renaming of existing structures and moves across modules to cleanup the parser.
The ParserFacade
is now used just slightly differently from before (now you supply options and then invoke one of its instance methods such as .parse_program()
).
ASDoc locations
- Now, references within ASDoc comments, such as these in
@see
, represent expression nodes containing the correct location at the same enclosing compilation unit. - Now, the
#x
part of an ASDoc reference, such as in@copy
and@see
, contains the source location for thex
name.#q::x
also works.
Tree semantics
The parser now comes with a TreeSemantics
structure that allows efficiently mapping meanings to nodes, usually used by a compiler.
MXML
Average parsing of MXML is integrated within the parser, parsing only UTF-8 and XML version 1.0.
CSS
Support for parsing the CSS3 subset of Flex might be integrated within this project.
0.4.36
Changes
Function type
The function type expression now complies with these in the ES4 overview paper.
- Parameter names are omitted
- Optional parameter is indicated by a
=
suffix instead of?
- The rest parameter does not require a type expression.
function(T1, T2=, ...): T
function(...[T1]): T2
Bug fixes
- Introduction of error recovery was leading to never ending parsing cycles.
- Specific attribute lookup in attribute combination was returning early in all attribute combination's lookup methods, leading to wrong reports.
- Fixed location popping to range starting from the previous token (mostly a typo before).
Enhancements
- The
include
directive may nestpackage
definitions, despite how it is processed. - Malformed destructuring patterns are now reported before verification.
- I was always unsure whether
CONFIG::CONSTANT ...
was part of ActionScript 3 or not, but I added it already:NormalConfigurationDirective
. - Forgot to handle ReservedNamespace qualifiers in expressions not directly at the beginning of a directive or statement. (Which was handled in the previous parser.)
- Type expressions now include qualified identifiers for compliance with ActionScript 3.
API changes
Since this parser update was a copy of my previous parser of another language, I had forgot to rename certain Rust items for more formedness.
as3_parser::ast
>as3_parser::tree
AstAsKey
>NodeAsKey