Skip to main content
your code.

Sylver is a language-agnostic tool for source code exploration and analysis.

Using the SYLQ query language REPL, you can perform syntax-aware search on your codebase to find style issues and potential bugs.

Interesting queries can be packaged into a ruleset to be executed in a linter-like fashion.

There is no first-class support for any specific language: to use sylver, you need a language spec for your language.

Install the CLI

curl -s https://sylver.dev/install.sh | bash

On macOS, Linux and WSL, Sylver can be installed through the install script. This script will download the binary from Github and extract it to a suitable location.

Run queries in the REPL

To start the sylver REPL, invoke the following command at the root of your Golang project:

sylver query --files="**/*.go" --spec=https://github.com/sylver-dev/golang.git#golang.yaml

You can exit the REPL by entering the following command at the prompt :quit

The parse tree for a given file can be displayed by using the following command
:print_ast FILE

To execute a query, type the query followed by a semicolon. Here are some examples:

match _;
Match all the parse tree nodes.

See the documentation to learn more about SYLQ queries.

Create and evaluate SYLQ-based rulesets

id: customStyleRules language: "https://github.com/sylver-dev/golang.git#golang.yaml" rules: - id: largeStruct message: struct has many fields severity: warning query: match StructType s when s.fields.children.length > 10 - id: assignOp message: assignment should use an assignment operator severity: error note: According to our style guide, assignment operators should be preferred. query: > match AssignStmt a when a.lhs.length == 1 && a.rhs[0] is { BinOp b when b.left.text == a.lhs[0].text }

This YAML document describes a SYLQ-based ruleset. Assuming it is stored at the root of your project in a file called style_ruleset.yaml, your can run it by invoking the following command:

sylver ruleset run --files="**/*.go" --rulesets=style_ruleset.yaml