# Quick start on ANTLR4 in Rust - part1

This is my note in adopting and learning ANTLR4Rust

Series

Install nightly version of Rust (and make it default if you want for convenience).

Get ANTLR4 runtime for Rust from here:

Prepare a grammar. I will use an example grammar: https://raw.githubusercontent.com/antlr/grammars-v4/master/csv/CSV.g4

Generate a parser:

You will get csvlexer.rs, csvlistener.rs , csvparser.rs . Place them into your project src directory.

Add dependencies in Cargo.toml:

Add a feature and import lazy_static macros to the root module:

Import common and essential things:

Import grammar-specific things:

Implement ParseTreeListener, a supertraint of CSVListener:

Implement CSVListener:

Read and parse an input. Note that csvFile in the last line is a rule name in CSV.g4:

The minimal working example can be found here.