syntax

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInsufficient = errors.New("insufficient input")

ErrInsufficient represents an error which is raised when the given input is insufficient for a term.

Functions

func IsExtendedGraphic

func IsExtendedGraphic(r rune) bool

IsExtendedGraphic checks if the rune is a graphic token, comma, or semicolon.

Types

type Lexer

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

Lexer turns bytes into tokens.

func NewLexer

func NewLexer(input *bufio.Reader, charConversions map[rune]rune) *Lexer

NewLexer create a lexer with an input and char conversions.

func (*Lexer) Next

func (l *Lexer) Next(hint TokenKind) (Token, error)

Next returns the next token.

type Token

type Token struct {
	Kind TokenKind
	Val  string
}

Token is a smallest meaningful unit of prolog program.

func (Token) String

func (t Token) String() string

type TokenKind

type TokenKind byte

TokenKind is a type of Token.

const (
	// TokenEOS represents an end of token stream.
	TokenEOS TokenKind = iota

	// TokenVariable represents a variable token.
	TokenVariable

	// TokenFloat represents a floating-point token.
	TokenFloat

	// TokenInteger represents an integer token.
	TokenInteger

	// TokenAtom represents an atom token.
	TokenAtom

	// TokenComma represents a comma.
	TokenComma

	// TokenPeriod represents a period.
	TokenPeriod

	// TokenBar represents a bar.
	TokenBar

	// TokenParenL represents an open parenthesis.
	TokenParenL

	// TokenParenR represents a close parenthesis.
	TokenParenR

	// TokenBracketL represents an open bracket.
	TokenBracketL

	// TokenBracketR represents a close bracket.
	TokenBracketR

	// TokenBraceL represents an open brace.
	TokenBraceL

	// TokenBraceR represents a close brace.
	TokenBraceR
)

func (TokenKind) String

func (k TokenKind) String() string

type UnexpectedRuneError

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

UnexpectedRuneError represents an error which is raised when the given input contains an unexpected rune.

func (UnexpectedRuneError) Error

func (e UnexpectedRuneError) Error() string

Jump to

Keyboard shortcuts

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