parser

package
v0.0.0-...-40e63e7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	S *lexer.Scanner
	// contains filtered or unexported fields
}

Parser represents a parser.

func New

func New(r *lexer.Scanner) *Parser

New returns Parser.

func (*Parser) ParseEnd

func (p *Parser) ParseEnd() error

ParseEnd parses to the end, and returns an error if the end hasn't been reached.

func (*Parser) ParseInt

func (p *Parser) ParseInt() (tok int, lit int, absolute bool, err error)

ParseInt parses the next integer. The integer might be absolute, or a delta value such as -2 or +3.

func (*Parser) ParseUnsignedFloat

func (p *Parser) ParseUnsignedFloat() (float64, error)

func (*Parser) ParseWhitespace

func (p *Parser) ParseWhitespace() error

ParseWhitespace scans a whitespace token returning nil, or error if the next token is not whitespace.

func (*Parser) Scan

func (p *Parser) Scan() (tok int, lit string)

Scan returns the next token from the underlying scanner. If a token has been unscanned then read that instead.

func (*Parser) ScanIgnoreWhitespace

func (p *Parser) ScanIgnoreWhitespace() (tok int, lit string)

ScanIgnoreWhitespace scans the next non-whitespace token.

func (*Parser) ScanRemainderAsIdentifier

func (p *Parser) ScanRemainderAsIdentifier() string

func (*Parser) Scanned

func (p *Parser) Scanned() []Token

Scanned returns all scanned tokens.

func (*Parser) SetScanner

func (p *Parser) SetScanner(s *lexer.Scanner)

SetScanner assigns a scanner object to the parser.

func (*Parser) Unscan

func (p *Parser) Unscan()

Unscan pushes the previously read token back onto the buffer.

type Token

type Token struct {
	Tok int
	Lit string
}

Token represent a token: classification and literal text

Jump to

Keyboard shortcuts

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