1// Copyright (c) 2021 Couchbase, Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package segment 16 17// Automaton represents the general contract of a byte-based finite automaton 18type Automaton interface { 19 20 // Start returns the start state 21 Start() int 22 23 // IsMatch returns true if and only if the state is a match 24 IsMatch(int) bool 25 26 // CanMatch returns true if and only if it is possible to reach a match 27 // in zero or more steps 28 CanMatch(int) bool 29 30 // WillAlwaysMatch returns true if and only if the current state matches 31 // and will always match no matter what steps are taken 32 WillAlwaysMatch(int) bool 33 34 // Accept returns the next state given the input to the specified state 35 Accept(int, byte) int 36} 37