Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- type LexRule
- type Lexer
- type Scanner
- func And[T any](scanners ...Scanner[T]) Scanner[T]
- func Eof[T any]() Scanner[T]
- func Many[T any](acceptor Scanner[T]) Scanner[T]
- func Not[T comparable](item T) Scanner[T]
- func Or[T any](scanners ...Scanner[T]) Scanner[T]
- func Sequence[T comparable](scanners ...Scanner[T]) Scanner[T]
- func SequenceNullableLast[T comparable](scanners ...Scanner[T]) Scanner[T]
- func String(s string) Scanner[int32]
- func Unit[T comparable](chars ...T) Scanner[T]
- func Until[T comparable](item T) Scanner[T]
- func Within[T cmp.Ordered](lowest T, highest T) Scanner[T]
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LexRule ¶
type LexRule[T any] struct { // contains filtered or unexported fields }
LexRule is simply a rule for associating groups of characters with a given tag.
nolint
type Lexer ¶
type Lexer[T any] struct { // contains filtered or unexported fields }
Lexer provides a top-level construct for tokenising a given input string.
func (*Lexer[T]) Collect ¶
Collect is a convenience function which parses all remaining tokens in one go, producing an array of tokens.
type Scanner ¶
Scanner is a function which accepts a given item or not.
func And ¶
And combines zero or more scanners such that the resulting scanner succeeds if all of the scanners succeed. Observe, however, that there is an implicit left-to-right order of evaluation.
func Or ¶
Or combines zero or more scanners such that the resulting scanner succeeds if any of the scanners succeeds. Observe, however, that there is an implicit left-to-right order of evaluation.
func Sequence ¶
func Sequence[T comparable](scanners ...Scanner[T]) Scanner[T]
Sequence matches all the scanners in order. Each scanner consumes the input right after the previous one ends.
func SequenceNullableLast ¶
func SequenceNullableLast[T comparable](scanners ...Scanner[T]) Scanner[T]
SequenceNullableLast matches all the scanners in order. Each scanner consumes the input right after the previous one ends. Only the final scanner is allowed a match length of 0.
func Unit ¶
func Unit[T comparable](chars ...T) Scanner[T]
Unit accepts a given sequence of characters. That is, for this scanner to match, it must match all the given characters (one after the other) in their given order.
func Until ¶
func Until[T comparable](item T) Scanner[T]
Until matches everything until a particular item is matched.