Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Add new pattern "Lexed" to README
Browse files Browse the repository at this point in the history
  • Loading branch information
romshark authored Sep 1, 2019
1 parent 1d5c029 commit 2ae3898
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ae3898

Please sign in to comment.