scanner

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeLength

func ComputeLength(s *Scanner)

ComputeLength switch scanner in length computing mode. Scanner in this mode shouldn't be used for parsing.

Types

type Option

type Option func(*Scanner)

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner represents a scanner is a JSchema scanning state machine. Callers call scan.reset() and then pass bytes in one at a time by calling scan.step(&scan, c) for each byte. The return value, referred to as an opcode, tells the caller about significant parsing events like beginning and ending literals, objects, and arrays, so that the caller can follow along if it wishes. The return value scanEnd indicates that a single top-level JSON value has been completed, *before* the byte that just got passed in. (The indication must be delayed in order to recognize the end of numbers: is 123 a whole value or the beginning of 12345e+6?).

func New

func New(file *fs.File, oo ...Option) *Scanner

func (*Scanner) Length

func (s *Scanner) Length() uint

func (*Scanner) Next

func (s *Scanner) Next() (lexeme.LexEvent, bool)

Next reads schema byte by byte. Panic if an invalid jSchema structure is found. Stops if it detects lexical events. Returns pointer to found lexeme event, or nil if you have complete reading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL