parse

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright (c) 2014 Caleb Spare

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FIXME: gen lol

https://github.com/cespare/goclj

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolNode

type BoolNode struct {
	*Pos
	Val bool
}

func (*BoolNode) Children

func (n *BoolNode) Children() []Node

func (*BoolNode) String

func (n *BoolNode) String() string

type CharacterNode

type CharacterNode struct {
	*Pos
	Val  rune
	Text string
}

func (*CharacterNode) Children

func (n *CharacterNode) Children() []Node

func (*CharacterNode) String

func (n *CharacterNode) String() string

type CommentNode

type CommentNode struct {
	*Pos
	Text string
}

func (*CommentNode) Children

func (n *CommentNode) Children() []Node

func (*CommentNode) String

func (n *CommentNode) String() string

type DerefNode

type DerefNode struct {
	*Pos
	Node Node
}

func (*DerefNode) Children

func (n *DerefNode) Children() []Node

func (*DerefNode) String

func (n *DerefNode) String() string

type FnLiteralNode

type FnLiteralNode struct {
	*Pos
	Nodes []Node
}

func (*FnLiteralNode) Children

func (n *FnLiteralNode) Children() []Node

func (*FnLiteralNode) String

func (n *FnLiteralNode) String() string

type KeywordNode

type KeywordNode struct {
	*Pos
	Val string
}

func (*KeywordNode) Children

func (n *KeywordNode) Children() []Node

func (*KeywordNode) String

func (n *KeywordNode) String() string

type ListNode

type ListNode struct {
	*Pos
	Nodes []Node
}

func (*ListNode) Children

func (n *ListNode) Children() []Node

func (*ListNode) String

func (n *ListNode) String() string

type MapNode

type MapNode struct {
	*Pos
	Namespace string // empty unless the map has a namespace: #:ns{:x 1}
	Nodes     []Node
}

func (*MapNode) Children

func (n *MapNode) Children() []Node

func (*MapNode) String

func (n *MapNode) String() string

type MetadataNode

type MetadataNode struct {
	*Pos
	Node Node
}

func (*MetadataNode) Children

func (n *MetadataNode) Children() []Node

func (*MetadataNode) String

func (n *MetadataNode) String() string

type NewlineNode

type NewlineNode struct {
	*Pos
}

func (*NewlineNode) Children

func (n *NewlineNode) Children() []Node

func (*NewlineNode) String

func (n *NewlineNode) String() string

type NilNode

type NilNode struct {
	*Pos
}

func (*NilNode) Children

func (n *NilNode) Children() []Node

func (*NilNode) String

func (n *NilNode) String() string

type Node

type Node interface {
	Position() *Pos
	String() string // A non-recursive string representation
	Children() []Node
}

type NumberNode

type NumberNode struct {
	*Pos
	Val string
}

func (*NumberNode) Children

func (n *NumberNode) Children() []Node

func (*NumberNode) String

func (n *NumberNode) String() string

type ParseOpts

type ParseOpts uint

ParseOpts is a bitset of parsing options for Reader and File.

const (
	// IncludeNonSemantic makes the parser include non-semantic nodes:
	// CommentNodes and NewlineNodes.
	IncludeNonSemantic ParseOpts = 1 << iota
	// IgnoreCommentForm makes the parser ignore (comment ...) forms.
	// This only applies to forms that are semantic comments; a quoted node
	// such as '(comment "foo") would not be ignored.
	IgnoreCommentForm
	// IgnoreReaderDiscard makes the parser ignore forms preceded by #_.
	IgnoreReaderDiscard
)

type Pos

type Pos struct {
	Name   string
	Offset int
	Line   int
	Col    int
}

Pos is a position in source text.

func (*Pos) Copy

func (p *Pos) Copy() *Pos

func (*Pos) FormatError

func (p *Pos) FormatError(tag string, msg string) error

func (*Pos) Position

func (p *Pos) Position() *Pos

func (*Pos) String

func (p *Pos) String() string

type QuoteNode

type QuoteNode struct {
	*Pos
	Node Node
}

func (*QuoteNode) Children

func (n *QuoteNode) Children() []Node

func (*QuoteNode) String

func (n *QuoteNode) String() string

type ReaderCondNode

type ReaderCondNode struct {
	*Pos
	Nodes []Node
}

func (*ReaderCondNode) Children

func (n *ReaderCondNode) Children() []Node

func (*ReaderCondNode) String

func (n *ReaderCondNode) String() string

type ReaderCondSpliceNode

type ReaderCondSpliceNode struct {
	*Pos
	Nodes []Node
}

func (*ReaderCondSpliceNode) Children

func (n *ReaderCondSpliceNode) Children() []Node

func (*ReaderCondSpliceNode) String

func (n *ReaderCondSpliceNode) String() string

type ReaderDiscardNode

type ReaderDiscardNode struct {
	*Pos
	Node Node
}

func (*ReaderDiscardNode) Children

func (n *ReaderDiscardNode) Children() []Node

func (*ReaderDiscardNode) String

func (n *ReaderDiscardNode) String() string

type ReaderEvalNode

type ReaderEvalNode struct {
	*Pos
	Node Node
}

func (*ReaderEvalNode) Children

func (n *ReaderEvalNode) Children() []Node

func (*ReaderEvalNode) String

func (n *ReaderEvalNode) String() string

type RegexNode

type RegexNode struct {
	*Pos
	Val string
}

func (*RegexNode) Children

func (n *RegexNode) Children() []Node

func (*RegexNode) String

func (n *RegexNode) String() string

type SetNode

type SetNode struct {
	*Pos
	Nodes []Node
}

func (*SetNode) Children

func (n *SetNode) Children() []Node

func (*SetNode) String

func (n *SetNode) String() string

type StringNode

type StringNode struct {
	*Pos
	Val string
}

func (*StringNode) Children

func (n *StringNode) Children() []Node

func (*StringNode) String

func (n *StringNode) String() string

type SymbolNode

type SymbolNode struct {
	*Pos
	Val string
}

func (*SymbolNode) Children

func (n *SymbolNode) Children() []Node

func (*SymbolNode) String

func (n *SymbolNode) String() string

type SyntaxQuoteNode

type SyntaxQuoteNode struct {
	*Pos
	Node Node
}

func (*SyntaxQuoteNode) Children

func (n *SyntaxQuoteNode) Children() []Node

func (*SyntaxQuoteNode) String

func (n *SyntaxQuoteNode) String() string

type TagNode

type TagNode struct {
	*Pos
	Val string
}

func (*TagNode) Children

func (n *TagNode) Children() []Node

func (*TagNode) String

func (n *TagNode) String() string

type Tree

type Tree struct {
	Roots []Node
	// contains filtered or unexported fields
}

func File

func File(filename string, opts ParseOpts) (*Tree, error)

func Reader

func Reader(r io.Reader, filename string, opts ParseOpts) (*Tree, error)

func (*Tree) String

func (t *Tree) String() string

String pretty-prints the tree recursively using each Node's String().

type UnquoteNode

type UnquoteNode struct {
	*Pos
	Node Node
}

func (*UnquoteNode) Children

func (n *UnquoteNode) Children() []Node

func (*UnquoteNode) String

func (n *UnquoteNode) String() string

type UnquoteSpliceNode

type UnquoteSpliceNode struct {
	*Pos
	Node Node
}

func (*UnquoteSpliceNode) Children

func (n *UnquoteSpliceNode) Children() []Node

func (*UnquoteSpliceNode) String

func (n *UnquoteSpliceNode) String() string

type VarQuoteNode

type VarQuoteNode struct {
	*Pos
	Val string
}

func (*VarQuoteNode) Children

func (n *VarQuoteNode) Children() []Node

func (*VarQuoteNode) String

func (n *VarQuoteNode) String() string

type VectorNode

type VectorNode struct {
	*Pos
	Nodes []Node
}

func (*VectorNode) Children

func (n *VectorNode) Children() []Node

func (*VectorNode) String

func (n *VectorNode) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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