Rename MMx to MM

pull/53/head
rwxrob 2 years ago
parent 605bb28021
commit 52bb09eacb
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

@ -104,25 +104,19 @@ type In []any
type O []any
// To is a set of advancing expressions that mark an exclusive boundary
// at which the scan should stop. The matching expression itself will
// not be advanced.
//
// In order to work with escaped boundaries use a negative
// look-ahead sequence combined with the boundary:
//
// is.To{s.X{is.Not{`\\`,`"`}}}
//
// at which the scan should stop returning a cursor just before the
// boundary.
type To []any
// Toi is an inclusive version of is.To.
// Toi is an inclusive version of is.To returning a cursor that points
// to the last rune of the boundary itself.
type Toi []any
// --------------------------- parameterized --------------------------
// MMx is a parameterized advancing expression that matches an inclusive
// minimum and maximum count of the given expression (This). Use within
// is.is.It to disable advancement.
type MMx struct {
// MM is a parameterized advancing expression that matches an inclusive
// minimum and maximum count of the given expression (This).
type MM struct {
Min int
Max int
This any

@ -394,7 +394,7 @@ func (s *R) Expect(expr any) (*Cur, error) {
}
return m, nil
case z.MMx: // ----------------------------------------------------
case z.MM: // ----------------------------------------------------
c := 0
last := s.Mark()
var err error
@ -448,7 +448,7 @@ func (s *R) Expect(expr any) (*Cur, error) {
case z.C: // ------------------------------------------------------
b := s.Mark()
m, err := s.Expect(z.MMx{v.N, v.N, v.This})
m, err := s.Expect(z.MM{v.N, v.N, v.This})
if err != nil {
s.Jump(b)
return nil, s.ErrorExpected(v)
@ -536,7 +536,7 @@ func (s *R) ErrorExpected(this any, args ...any) error {
case z.Min:
str := `expected min %v of %q`
msg = fmt.Sprintf(str, v.Min, v.This)
case z.MMx:
case z.MM:
str := `expected min %v, max %v of %q`
msg = fmt.Sprintf(str, v.Min, v.Max, v.This)
case z.C:

@ -450,12 +450,12 @@ func ExampleExpect_mMx() {
s.Snap()
s.ScanN(2)
s.Print()
s.Expect(z.MMx{1, 3, 'm'}) // goggles up all three
s.Expect(z.MM{1, 3, 'm'}) // goggles up all three
s.Print()
s.Back()
s.Expect(z.MMx{1, 3, 's'}) // yep, at least one
s.Expect(z.MM{1, 3, 's'}) // yep, at least one
s.Print()
_, err := s.Expect(z.MMx{1, 3, 'X'}) // nope
_, err := s.Expect(z.MM{1, 3, 'X'}) // nope
fmt.Println(err)
// Output:
// U+006D 'm' 1,3-3 (3-3)

Loading…
Cancel
Save