From 48bad35a6d3a6f5c3bd986467ac656438bd1b9ca Mon Sep 17 00:00:00 2001 From: Per Lindgren <per.lindgren@ltu.se> Date: Fri, 16 Mar 2018 09:28:26 +0100 Subject: [PATCH] readme --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 27fc72c..e200de4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,31 @@ Disclaimer, I'm NOT the author of the `syn` and `nom` parsing frameworks, so no The same goes for all references to supporting crates and references to other Rust libraries, crates and the language itself, so use material at own risk :) +## Build environment + +In order to build custom parsers using `syn` you need to use a nightly compiler to build a library with the following set of dependencies and library definition in the `Cargo.toml`. + +``` toml +[package] +name = "parsetest" +version = "0.1.0" +authors = ["Per Lindgren <per.lindgren@ltu.se>"] + +[dependencies] +quote = "0.4.2" + +[dependencies.syn] +version = "0.12.12" +features = ["full"] + +[dependencies.proc-macro2] +features = ["nightly"] +version = "0.2.2" + +[lib] +proc-macro = true +``` + ## Built in parsers The `syn::parse` function allows to parse any struct that implements the `syn::synom::Synom` trait. The `syn` crate provides a large set of structs which satisfies this requirement, which we can use directly or for building parser combinators. @@ -211,8 +236,9 @@ The description here is the default error, provided by the built in `LitInt` par ## Combining parsers -The real strenght of the `syn` and `nom` frameworks comes from the ability to combine parsers. We will start by looking at the last error, assuming we want to parse something like `(LitInt)` into a plain `LitInt`. +The real strenght of the `syn` and `nom` frameworks comes from the ability to combine parsers. We will start by looking at the last error, assuming we want to parse something like `(LitInt)` into a plain `LitInt`. +``` rust /// MyLit struct MyLit { val: LitInt, -- GitLab