mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-16 21:25:44 +00:00
Rename In -> I
This commit is contained in:
parent
87071b28b0
commit
7bf4c9b80a
@ -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}
|
||||
|
@ -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).
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user