Rename In -> I

This commit is contained in:
rwxrob 2022-03-04 16:56:50 -05:00
parent 87071b28b0
commit 7bf4c9b80a
No known key found for this signature in database
GPG Key ID: 2B9111F33082AE77
4 changed files with 14 additions and 14 deletions

View File

@ -2,5 +2,5 @@ package z
// keep only compound expressions here
var WS = In{' ', '\n', '\t', '\r'}
var WS = I{' ', '\n', '\t', '\r'}
var Digit = R{0, 9}

View File

@ -93,13 +93,13 @@ type P []any
// point (!) in PEGN.)
type N []any
// In is a set of advancing expressions. If any expression in the slice
// is found the scan advances to the end of that expression and
// continues. If none of the expressions is found the scan fails.
// Evaluation of expressions is always left to right allowing
// parser developers to prioritize common expressions at the beginning
// of the slice.
type In []any
// I ("in","include") is a set of advancing expressions. If any
// expression in the slice is found the scan advances to the end of that
// expression and continues. If none of the expressions is found the
// scan fails. Evaluation of expressions is always left to right
// allowing parser developers to prioritize common expressions at the
// beginning of the slice.
type I []any
// O is a set of optional advancing expressions. If any expression is
// found the scan is advanced (unlike is.It, which does not advance).

View File

@ -378,7 +378,7 @@ func (s *R) Expect(expr any) (*Cur, error) {
}
return m, nil
case z.In: // -----------------------------------------------------
case z.I: // -----------------------------------------------------
var m *Cur
for _, i := range v {
var err error
@ -519,7 +519,7 @@ func (s *R) ErrorExpected(this any, args ...any) error {
}
case z.N:
msg = fmt.Sprintf(`unexpected %q`, args[0])
case z.In:
case z.I:
str := `expected one of %q`
msg = fmt.Sprintf(str, v)
case z.X:

View File

@ -296,7 +296,7 @@ func ExampleExpect_not_X_Fail() {
func ExampleExpect_not_X_Success() {
s, _ := scan.New("some thing wonderful")
c, _ := s.Expect(z.X{z.N{`n`}, z.In{`som`}})
c, _ := s.Expect(z.X{z.N{`n`}, z.I{`som`}})
c.Print() // pointing to last in match 'm'
s.Print() // advanced to next after match 'e'
// Output:
@ -317,10 +317,10 @@ func ExampleExpect_to_Success_Mid() {
func ExampleExpect_in() {
s, _ := scan.New("some thing")
s.Scan()
c, _ := s.Expect(z.In{'O', 'o', "ome"})
c, _ := s.Expect(z.I{'O', 'o', "ome"})
c.Print()
s.Print()
_, err := s.Expect(z.In{'x', 'y', "zee"})
_, err := s.Expect(z.I{'x', 'y', "zee"})
fmt.Println(err)
// Output:
// U+006F 'o' 1,2-2 (2-2)
@ -331,7 +331,7 @@ func ExampleExpect_in() {
func ExampleExpect_avoid_Not_with_In() {
s, _ := scan.New("some thing")
s.Snap()
c, _ := s.Expect(z.In{z.N{'s'}, z.R{'a', 'z'}})
c, _ := s.Expect(z.I{z.N{'s'}, z.R{'a', 'z'}})
c.Print() // unexpected success
s.Print() // advanced to 'o'
s.Back()