A Universal Abstract Syntax Tree (UAST) is a normalized form of Abstract Syntax Tree (AST). By definition, the UAST representation does not depend on the language of the parser for source files.
UAST is defined by three separate specifications:
-
Node representation - defines a common transport format for the UAST.
-
UAST binary encoding - defines UAST binary encoding.
-
Semantic UAST - defines UAST node types that are independent of the programming language.
Visualizing the structure of the UAST is very simple: YAML output of bblfsh-cli
can be read by the bblfhs-sdk ast2gv
command that outputs UAST representation using GraphVis.
PNG and SVG output is supported for convenience but requires a graphviz binary to be installed on your system.
go get github.com/bblfsh/go-client/v4/cmd/bblfsh-cli/...
bblfsh-cli client.go > client.uast.yml
go get github.com/bblfsh/sdk/v3/cmd/bblfsh-sdk/...
bblfsh-sdk ast2gv -o png client.uast.yml
open client.uast.yml.png