lexer

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TextScannerLexer lexer.Definition = &textScannerLexerDefinition{}

	// DefaultDefinition defines properties for the default lexer.
	DefaultDefinition = TextScannerLexer
)

TextScannerLexer is a lexer that uses the text/scanner module.

Functions

func Lex

func Lex(filename string, r io.Reader) lexer.Lexer

Lex an io.Reader with text/scanner.Scanner.

This provides very fast lexing of source code compatible with Go tokens.

Note that this differs from text/scanner.Scanner in that string tokens will be unquoted.

func LexBytes

func LexBytes(filename string, b []byte) lexer.Lexer

LexBytes returns a new default lexer over bytes.

func LexString

func LexString(filename, s string) lexer.Lexer

LexString returns a new default lexer over a string.

func LexWithScanner

func LexWithScanner(filename string, scan *scanner.Scanner) lexer.Lexer

LexWithScanner creates a Lexer from a user-provided scanner.Scanner.

Useful if you need to customise the Scanner.

func NewCustomTextScannerLexer

func NewCustomTextScannerLexer() lexer.Definition

NewCustomTextScannerLexer constructs a Definition that uses an underlying scanner.Scanner

It's custom because: - string token can have different sets of quotes: single, double, backtick - special token type - JSON

Types

This section is empty.

Directories

Path Synopsis
Package scanner provides a scanner and tokenizer for UTF-8-encoded text.
Package scanner provides a scanner and tokenizer for UTF-8-encoded text.

Jump to

Keyboard shortcuts

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