/wood

Wood - Tree manipulation library for Ruby

Primary LanguageRubyBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Wood - Tree manipulation library

Wood is a library for creating, manipulating & rewriting trees, in particular Abstract Syntax Trees (ASTs).

Wood was extracted from a source to source compiler I worked on for Marft Inc. in 2013/14. Marft has granted me the rights to this library, so I'm releasing it under the 3-clause BSD license (see LICENSE file).

The compiler that was built using this library (which was then called Forest) translated a subset of ANSI C to multiple target languages, including Java, C# and JavaScript.

Wood provides an easy to use DSL for searching & rewriting whole sub-trees in place, which can be used for things like subsequently translating a parse tree into a target language tree (in the compiler project's case to Java::AST, CSharp::AST and JavaScript::AST trees).

You can find some example tree node definitions & rewriting rules in the examples directory.