Skip to content

Prototype validators API #27

Closed

Description

@matklad

Implement a tree visitor which can make additional "syntax-like" checks on the tokens and tree produced by the parser.

  • [] tree visitor
  • [] error builder
  • [] testing infrastructure

Activity

  1. aochagavia commented on Oct 25, 2018

    @aochagavia
    Contributor

    Is there anything like this already in place? I am asking because the issue is old and sometimes changes are introduced without referring to the issue.

  2. matklad commented on Oct 30, 2018

    @matklad
    ContributorAuthor

    Nothing is done yet, though we still need to implement this API.

    We have error method here, which returns a Vec<SyntaxError> precisely to allow to compute errors on the fly:

    https://github.com/rust-analyzer/rust-analyzer/blob/bc4de7128f474f75a9eff6591923657025099b74/crates/ra_syntax/src/lib.rs#L98

    So, what we need is to add a private fn validate(file: &File) -> Vec<SyntaxError> method, and append its results to the errors from the parser.

    Here is the subset of things which should be checked by validate:

    • string and char literals have closing quote
    • char literals are one symbol long
    • /* comments have a closing */
    • escapes in strings are valid
    • doc comments are attached to nodes Should DOC_COMMENT be removed? #166
  3. added a commit that references this issue on Nov 4, 2018
  4. aochagavia commented on Nov 9, 2018

    @aochagavia
    Contributor

    Superseded by #223

  5. added a commit that references this issue on Nov 10, 2018
    477de79
  6. added 2 commits that reference this issue on Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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