From fcdcf73508c145595fc76d82d31b79b3577cc3ed Mon Sep 17 00:00:00 2001 From: Marco Molteni Date: Sun, 12 Jun 2022 15:33:26 +0200 Subject: [PATCH] tutorial: make it work with the default lexer (parse integers) Closes: #231 Signed-off-by: Marco Molteni --- TUTORIAL.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 82a03f4..90a9810 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -58,7 +58,7 @@ working towards. Read on below for details. type Value struct { String *string ` @String` - Number *float64 `| @Float` + Number *float64 `| (@Float | @Int)` } ``` @@ -147,6 +147,16 @@ type Value struct { } ``` +Since we want to parse also integers and the default lexer makes a difference, +we need to be explicit: + +```go +type Value struct { + String *string ` @String` + Number *float64 `| (@Float | @Int)` +} +``` + > Note: the grammar can cross fields. Next, we'll match values and capture them into the `Property`. To recursively @@ -189,7 +199,7 @@ type Property struct { type Value struct { String *string ` @String` - Number *float64 `| @Float` + Number *float64 `| (@Float | @Int)` } ``` @@ -229,7 +239,7 @@ If a grammar node includes a field with the name `Pos` and type `lexer.Position` type Value struct { Pos lexer.Position String *string ` @String` - Number *float64 `| @Float` + Number *float64 `| (@Float | @Int)` } ```