Rename To -> T

pull/53/head
rwxrob 2 years ago
parent 1763b79d16
commit c6460984ce
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

@ -103,12 +103,12 @@ type In []any
// found the scan is advanced (unlike is.It, which does not advance).
type O []any
// To is a set of advancing expressions that mark an exclusive boundary
// at which the scan should stop returning a cursor just before the
// boundary.
type To []any
// T ("to") is a set of advancing expressions that mark an exclusive
// boundary at which the scan should stop returning a cursor just before
// the boundary.
type T []any
// Ti ("to inclusive") is an inclusive version of is.To returning
// Ti ("to inclusive") is an inclusive version of z.T returning
// a cursor that points to the last rune of the boundary itself.
type Ti []any

@ -334,7 +334,7 @@ func (s *R) Expect(expr any) (*Cur, error) {
s.Jump(back)
return nil, s.ErrorExpected(v)
case z.To: // -----------------------------------------------------
case z.T: // -----------------------------------------------------
m := s.Mark()
b4 := s.Mark()
for s.Cur.Rune != tk.EOD {
@ -551,7 +551,7 @@ func (s *R) ErrorExpected(this any, args ...any) error {
str = `none of %q found`
}
msg = fmt.Sprintf(str, v)
case z.To:
case z.T:
msg = fmt.Sprintf(`none of %q found`, v)
default:
msg = fmt.Sprintf(`expected %T %q`, v, v)

@ -306,7 +306,7 @@ func ExampleExpect_not_X_Success() {
func ExampleExpect_to_Success_Mid() {
s, _ := scan.New("some thing wonderful")
c, _ := s.Expect(z.To{"wo"})
c, _ := s.Expect(z.T{"wo"})
c.Print() // "wo" not inc, same as "some thing ", so ' '
s.Print() // advances to 'w'
// Output:
@ -531,7 +531,7 @@ func ExampleExpect_hook() {
func ExampleExpect_to_Success() {
s, _ := scan.New("some thing")
c, _ := s.Expect(z.To{'e'})
c, _ := s.Expect(z.T{'e'})
c.Print() // same as "som", points to 'm'
s.Print() // scanned next after ('e')
// Output:

Loading…
Cancel
Save