Rename It -> P

pull/53/head
rwxrob 2 years ago
parent 68f54e7f18
commit 87071b28b0
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77

@ -78,13 +78,13 @@ type X []any
// ------------------------------- sets -------------------------------
// It ("is it") is a set of positive lookahead expressions. If any are
// P ("positive") is a set of positive lookahead expressions. If any are
// seen at the current cursor position the scan will proceed without
// consuming them (unlike is.O and is.In). If none are found the scan
// consuming them (unlike z.O and z.I). If none are found the scan
// fails. This is useful when everything from one expression is wanted
// except for a few positive exceptions. (Equal to ampersand (&) in
// PEGN.)
type It []any
type P []any
// N ("not") is a set of negative lookahead expressions. If any are seen
// at the current cursor position the scan will fail and the scan is

@ -352,7 +352,7 @@ func (s *R) Expect(expr any) (*Cur, error) {
s.Jump(m)
return nil, s.ErrorExpected(v)
case z.It: // ----------------------------------------------------
case z.P: // ----------------------------------------------------
var m *Cur
b := s.Mark()
for _, i := range v {
@ -511,7 +511,7 @@ func (s *R) ErrorExpected(this any, args ...any) error {
switch v := this.(type) {
case rune: // otherwise will use uint32
msg = fmt.Sprintf(`expected rune %q`, v)
case z.It:
case z.P:
if len(v) > 1 {
msg = fmt.Sprintf(`expected one of %q`, v)
} else {

@ -226,7 +226,7 @@ func ExampleExpect_compound_Expr_Rune() {
func ExampleExpect_it_Success() {
s, _ := scan.New("some thing")
c, _ := s.Expect(z.It{"some"})
c, _ := s.Expect(z.P{"some"})
c.Print() // even though true, not moved
s.Print() // scanner also not moved
// Output:
@ -236,7 +236,7 @@ func ExampleExpect_it_Success() {
func ExampleExpect_it_Success_Middle() {
s, _ := scan.New("some thing")
c, _ := s.Expect(z.X{"some", z.It{' '}})
c, _ := s.Expect(z.X{"some", z.P{' '}})
c.Print() // advanced up to (but not including) ' '
s.Print() // scanner also not moved
// Output:
@ -246,7 +246,7 @@ func ExampleExpect_it_Success_Middle() {
func ExampleExpect_it_Fail() {
s, _ := scan.New("some thing")
_, err := s.Expect(z.X{"some", z.It{"thing"}})
_, err := s.Expect(z.X{"some", z.P{"thing"}})
fmt.Println(err)
s.Print() // but scanner did get "some" so advanced
// Output:
@ -256,7 +256,7 @@ func ExampleExpect_it_Fail() {
func ExampleExpect_it_Fail_X() {
s, _ := scan.New("some thing")
_, err := s.Expect(z.X{"some", z.It{"thing"}})
_, err := s.Expect(z.X{"some", z.P{"thing"}})
fmt.Println(err)
s.Print() // but scanner did get "some" so advanced
// Output:

Loading…
Cancel
Save