Documentation
¶
Index ¶
- Variables
- func CloseAll()
- func OpenFile(path string) (*os.File, error)
- type CallNode
- type CommentNode
- type DirectiveNode
- type ExecNode
- type File
- type LiteralNode
- type Locals
- type Node
- type NodeArgs
- type NodeChildren
- type NodeTree
- type Parser
- type PostProcessor
- type Segment
- type StringFormatter
- type StringModifier
- type StringNode
- type VariableSegment
Constants ¶
This section is empty.
Variables ¶
View Source
var EOF = &liberrors.DetailedError{Name: "EOF"}
View Source
var OpenedFiles = []File{}
Functions ¶
func CloseAll ¶
func CloseAll()
Close all OpenedFiles.
Recommended to be defered in [main], e.g. `defer libparser.CloseAll()`.
Types ¶
type CommentNode ¶
type CommentNode struct {
Contents string
}
Can be used for documentation
func (*CommentNode) Node ¶
func (node *CommentNode) Node() string
type DirectiveNode ¶
type DirectiveNode struct {
Name string
NodeArgs
NodeChildren
}
func (*DirectiveNode) Node ¶
func (node *DirectiveNode) Node() string
type LiteralNode ¶
type LiteralNode struct {
Contents string
}
A literal string does not get modified in any way.
func (*LiteralNode) Node ¶
func (node *LiteralNode) Node() string
type Node ¶
type Node interface {
Node() string
}
func PostExclude ¶
func PostExclude[T Node](node Node) (Node, *liberrors.DetailedError)
Discards nodes of type [T] from the tree
func PostNoShebang ¶
func PostNoShebang(node Node) (Node, *liberrors.DetailedError)
Discards shebang (unix) comment
type NodeChildren ¶
type NodeChildren []Node
type NodeTree ¶
type NodeTree struct {
Tomes map[string]Node
NodeChildren
}
type Parser ¶
type Parser struct {
Name string
PostProcessors []PostProcessor
// contains filtered or unexported fields
}
func (*Parser) With ¶
func (parser *Parser) With(processor PostProcessor) *Parser
Appends the PostProcessor to be applied to every single node before it gets appended to the tree.
NOTE: Order matters (sequentially from first to last)
type PostProcessor ¶
type PostProcessor func(Node) (Node, *liberrors.DetailedError)
type StringFormatter ¶
type StringFormatter struct {
// contains filtered or unexported fields
}
func NewStringFormatter ¶
func NewStringFormatter(input string) *StringFormatter
func (*StringFormatter) Format ¶
func (formatter *StringFormatter) Format() ([]Segment, *liberrors.DetailedError)
type StringModifier ¶
func GetModifier ¶
func GetModifier(name string, args []string) StringModifier
type StringNode ¶
type StringNode struct {
Contents string
// Holds segments generated by [libparser.StringFormatter]
//
// WARN: Parse() does NOT set it by default.
// Used by other libraries such as `lib-validator` as part of post-processing
Segments []Segment
}
A string that can have variable expansions inside. Uses backticks (`) instead of quotes.
func (*StringNode) Node ¶
func (node *StringNode) Node() string
type VariableSegment ¶
type VariableSegment struct {
Name string
Modifier StringModifier
IsOptional bool
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.