Example extended.

This commit is contained in:
Maurice Makaay 2019-05-24 23:55:10 +00:00
parent e9c618580d
commit 8a6815332e
1 changed files with 8 additions and 0 deletions

View File

@ -119,6 +119,14 @@ func Example_minimalAnnotated() {
} }
func Example_minimal() { func Example_minimal() {
// Let's write a small example for parsing a really basic calculator.
// The calculator understands input that looks like:
//
// 10 + 20 - 8+4
//
// So positive numbers that can be either added or substracted, with
// optional whitespace around the operators.
var c, a, m = parsekit.C, parsekit.A, parsekit.M var c, a, m = parsekit.C, parsekit.A, parsekit.M
var number = c.OneOrMore(a.Digit) var number = c.OneOrMore(a.Digit)