Skip to content

Create a "correct" SyntaxNode API #432

@Schottkyc137

Description

@Schottkyc137

We currently have the SyntaxNode API in the vhdl-syntax crate.
This API has the disadvantage that every node is optional. Getting nodes is, therefore, a pain point.
We should introduce a "correct" API that enables clean access to the AST.

Example API

struct CorrectArchitectureEpilogue(SyntaxNode);

impl CorrectArchitectureEpilogue {
    // Returns the node, if the passed `SyntaxNode` is correct. Otherwise, returns some result data structure that reports
    // missing and superfluous fields.
    pub fn new(node: SyntaxNode) -> Result< CorrectArchitectureEpilogue, MissingAndSuperfluousFields> {
        // implementation details
    }

   // Not optional, is always present
   pub fn end_keyword() -> SyntaxToken {
       // implementation details
   }

    // optional since this is also optional in the LRM
   pub fn architecture_token() -> Option<SyntaxToken> {
       // implementation details
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    vhdl-syntaxRelevant for the vhdl-syntax crate

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions