Skip to content

[rust] Rust grammar not in target agnostic format, unclear readme information. #4675

@kaby76

Description

@kaby76
  • The comment 'Python version uses different language files due to semantic predicates.' doesn't provide useful information. Providing target-specific base classes for a port is not unique to the Python3 target. The same can be said about all the other targets. The comment should be removed.
  • This grammar is not in target agnostic format. Antlr4 grammar actions ({ ... } or { ... }?) cannot contain literals, expressions, etc., because they are in a syntax that does not span different target languages. Only the syntax for a function call does.
  • The semantic predicates for the parser are wrong, not only because they are not in target-agnostic format, but because the predicates implement a faulty comparison: LA() in the lexer is a character; LA() in the parser is a token type. The semantic predicate {this.next('<')}? calls a function in the parser base class, but uses LA() and compares that to the character, not the token type LT. It also defines the next() method in the lexer base class, but it is not used! All this code is just wrong.
  • The Python3 port contains a test driver. It should be removed because it offers nothing over trgen testing, and is just another thing that needs to be supported.
  • The code for the Go port exists, but it does not work.
  • There are missing ports for other targets. Dart and Rust are typically the two fastest targets, but they are missing. Update: The Rust target cannot be implemented yet because the Rust target does not generated code that contains references to the recognizer in semantic predicates. (It does for non-predicates "actions.") This is a requirement of many grammars-v4 repo. See Grammar actions can reference the recognizer, semantic predicates can't!! antlr4rust/antlr4#23.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions