From 2ae3898baefe44c6eace5eb3a47833ede2c12226 Mon Sep 17 00:00:00 2001 From: Roman Sharkov Date: Sun, 1 Sep 2019 16:37:58 +0200 Subject: [PATCH] Add new pattern "Lexed" to README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a753a9..a733b24 100644 --- a/README.md +++ b/README.md @@ -95,10 +95,27 @@ Pattern: llparser.TermExact{ ```go Pattern: llparser.Checked{ Designation: "some checked terminal", - Fn: func(str string) bool { return len(str) > 5 }, + Fn: func(str string) bool { return len(str) > 5 }, }, ``` +#### Pattern: Lexed +`Lexed` tries to lex an arbitrary sequence of characters according to `Fn`: + +```go +Pattern: llparser.Lexed{ + Designation: "some lexed terminal", + Kind: SomeKindConstant, + Fn: func(crs llparser.Cursor) uint { + if crs.File.Src[crs.Index] == '|' { + return 0 + } + return 1 + }, +}, +``` +`Fn` returns either `0` for ending the sequence, `1` for advancing for 1 rune or any positive integer _n_ to advance for _n_ runes. + ### Combinators #### Pattern: Optional