Crate wdl_ast

source ·
Expand description

An abstract syntax tree for Workflow Description Language (WDL) documents.

The AST implementation is effectively a facade over the concrete syntax tree (CST) implemented by SyntaxTree from wdl-grammar.

An AST is cheap to construct and may be cheaply cloned at any level.

However, an AST (and the underlying CST) are immutable; updating the tree requires replacing a node in the tree to produce a new tree. The unaffected nodes of the replacement are reused from the old tree to the new tree.

§Examples

An example of parsing a WDL document into an AST and validating it:

use wdl_ast::Document;
use wdl_ast::Validator;

let (document, diagnostics) = Document::parse(source);
if !diagnostics.is_empty() {
    // Handle the failure to parse
}

let mut validator = Validator::default();
if let Err(diagnostics) = validator.validate(&document) {
    // Handle the failure to validate
}

Modules§

  • AST representation for a 1.x WDL document.
  • Representation for version definitions.

Structs§

Enums§

Constants§

Traits§

  • The main trait to go from untyped SyntaxNode to a typed AST. The conversion itself has zero runtime cost: AST and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself.
  • An extension trait for AST nodes.
  • The trait implemented on AST tokens to go from untyped SyntaxToken to a typed representation.
  • A trait implemented on types that convert to spans.
  • A trait used to implement an AST visitor.

Type Aliases§

  • Represents an element (node or token) in the concrete syntax tree.
  • Represents a node in the concrete syntax tree.
  • Represents a token in the concrete syntax tree.