syntax

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, doc *Document, fm FormatMode) error

Write the content to the document

Types

type CommentLine

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

Represents a line of comments

func NewCommentsLine

func NewCommentsLine(commentText string) *CommentLine

func (*CommentLine) CommentText

func (el *CommentLine) CommentText() string

func (*CommentLine) HasPreformattedText

func (el *CommentLine) HasPreformattedText() bool

Returns true if the element has original text

func (*CommentLine) OriginalLineIndex

func (el *CommentLine) OriginalLineIndex() int

func (*CommentLine) PreformattedLineText

func (el *CommentLine) PreformattedLineText() string

func (*CommentLine) Type

func (*CommentLine) Type() ElementType

type Document

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

func NewDocument

func NewDocument(elements []Element) *Document

Creates new documen based on the passed data

func Read

func Read(r io.Reader) (*Document, error)

Parses the content and returns parsed document

func (*Document) Elements

func (doc *Document) Elements() []Element

type Element

type Element interface {
	Type() ElementType
	OriginalLineIndex() int
	HasPreformattedText() bool
	PreformattedLineText() string
	// contains filtered or unexported methods
}

Shared syntax element interface

type ElementType

type ElementType int
const (
	Unknown ElementType = iota
	IPMapping
	Comment
	Empty
)

type EmptyLine

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

Represents an empty line

func NewEmptyLine

func NewEmptyLine() *EmptyLine

func (*EmptyLine) HasPreformattedText

func (el *EmptyLine) HasPreformattedText() bool

Returns true if the element has original text

func (*EmptyLine) OriginalLineIndex

func (el *EmptyLine) OriginalLineIndex() int

func (*EmptyLine) PreformattedLineText

func (el *EmptyLine) PreformattedLineText() string

func (*EmptyLine) Type

func (*EmptyLine) Type() ElementType

type FormatMode

type FormatMode int
const (
	FmtKeep     FormatMode = iota    // Keep original formatting where possible
	FmtReFormat FormatMode = iota    // Re-format document
	FmtDefault             = FmtKeep // Same as FmtKeep
)

type IPMappingLine

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

Represents a line of IP to domain name mapping

func NewIPMappingLine

func NewIPMappingLine(ip string, domainNames []string, comment string) *IPMappingLine

func (*IPMappingLine) CommentText

func (el *IPMappingLine) CommentText() string

func (*IPMappingLine) DomainNames

func (el *IPMappingLine) DomainNames() []string

func (*IPMappingLine) HasPreformattedText

func (el *IPMappingLine) HasPreformattedText() bool

Returns true if the element has original text

func (*IPMappingLine) IPAddress

func (el *IPMappingLine) IPAddress() string

func (*IPMappingLine) OriginalLineIndex

func (el *IPMappingLine) OriginalLineIndex() int

func (*IPMappingLine) PreformattedLineText

func (el *IPMappingLine) PreformattedLineText() string

func (*IPMappingLine) Type

func (*IPMappingLine) Type() ElementType

type UnrecognizedLine

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

func (*UnrecognizedLine) HasPreformattedText

func (el *UnrecognizedLine) HasPreformattedText() bool

Returns true if the element has original text

func (*UnrecognizedLine) OriginalLineIndex

func (el *UnrecognizedLine) OriginalLineIndex() int

func (*UnrecognizedLine) PreformattedLineText

func (el *UnrecognizedLine) PreformattedLineText() string

func (*UnrecognizedLine) Type

func (*UnrecognizedLine) Type() ElementType

Jump to

Keyboard shortcuts

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