parse

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOF = &Token{EofTokenKind, "", -1}
View Source
var ErrParse = errors.New("parse error")
View Source
var ErrSyntax = errors.New("syntax error")

Functions

func Errorf

func Errorf(kind error, format string, args ...interface{}) error

Types

type Arg

type Arg struct {
	// The first token for this Arg.
	//
	// This matches the token set on either SExpr or Literal.
	Token *Token

	// Only one of these is set.
	SExpr   *SExpr
	Literal *Literal
}

type Config

type Config struct {
	SExprs []*SExpr
}

func Parse

func Parse(r io.Reader) (*Config, error)

type Literal

type Literal struct {
	Token *Token
}

type Parser

type Parser struct {
	Stderr io.Writer
	// contains filtered or unexported fields
}

func (*Parser) Parse

func (p *Parser) Parse(r io.Reader) (*Config, error)

type SExpr

type SExpr struct {
	Literal *Literal
	Args    []*Arg
}

type Token

type Token struct {
	Kind  TokenKind
	Value string
	Pos   int
}

func (Token) String

func (t Token) String() string

type TokenKind

type TokenKind string
const (
	AttributeTokenKind TokenKind = "Attribute"
	CommentTokenKind   TokenKind = "Comment"
	NumberTokenKind    TokenKind = "Number"
	StringTokenKind    TokenKind = "String"
	LParenTokenKind    TokenKind = "LParen"
	RParenTokenKind    TokenKind = "RParen"
	NewlineTokenKind   TokenKind = "Newline"
	EofTokenKind       TokenKind = "EOF"
	ErrTokenKind       TokenKind = "Error"

	// Keywords
	DirTokenKind  TokenKind = "dir"
	FileTokenKind TokenKind = "file"
)

Jump to

Keyboard shortcuts

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