parser

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package parser converts query strings into key-values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// Tokens is the tokens returned from
	// the scanner.Scanner for the string
	// being parsed.
	Tokens []Token

	// Index is the index of the token
	// where the parsing failed.
	Index int

	// Err is the error encountered
	// at the failing token.
	Err error
}

Error represents a problem encountered during parsing. Included with the error is the entire list of tokens returned by the scanner.Scanner and the index of the token which caused the parsing error.

func (*Error) Error

func (x *Error) Error() string

Error returns a string made up of all the tokens with the invalid token marked as such.

type Parser

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

Parser obtains tokens from the given scanner.Scanner and attempts to parse them into a keyval.Query.

func New

func New(s scanner.Scanner) Parser

func (*Parser) Parse

func (x *Parser) Parse() (keyval.Query, error)

Parse consumes all the tokens from the given scanner.Scanner and either returns a keyval.Query or the first error encountered during parsing.

type Token

type Token struct {
	Kind  scanner.TokenKind
	Token string
}

Token is a categorized piece of the query string returned from scanner.Scanner.

Directories

Path Synopsis
Package format converts key-values into query strings.
Package format converts key-values into query strings.
Package scanner tokenizes query strings.
Package scanner tokenizes query strings.

Jump to

Keyboard shortcuts

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