Skip to content

Example of modifying an AST #162

Open
@abhillman

Description

@abhillman

Description

Some basic code that demonstrates modifying an AST.

Considered alternatives

Poking around, playing with various things, reading tests -- currently doing that.

Additional context

An example could look something like this:

fn main() {
    let parse: rnix::Parse<rnix::Root> = rnix::Root::parse("\"hello world!\"");
    if !parse.errors().is_empty() { panic!(); }
    let syntax_node: rnix::SyntaxNode = parse.syntax();
    // modify the ast and call `println!("Modified: {}", syntax_node_modified);`
    println!("Original: {}", syntax_node);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions