Lexer

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstInstanceOfWS added in v0.1.19

func FirstInstanceOfWS(chars []rune, from_idx, to_idx int) int

FirstInstanceOfWS finds the first instance of whitespace in the characters.

Parameters:

  • chars: The characters.
  • from_idx: The starting index. (inclusive)
  • to_idx: The ending index. (exclusive)

Returns:

  • int: The index of the first whitespace character. -1 if not found.

Behaviors:

  • If from_idx < 0, from_idx is set to 0.
  • If to_idx >= len(chars), to_idx is set to len(chars) - 1.
  • If from_idx > to_idx, from_idx and to_idx are swapped.

FIXME: Remove this function once MyGoLib is updated.

func IsDone added in v0.1.18

func IsDone(err error) bool

IsDone checks if an error is a completion error or nil.

Parameters:

  • err: The error to check.

Returns:

  • bool: True if the error is a completion error or nil. False otherwise.

func LastInstanceOfWS added in v0.1.19

func LastInstanceOfWS(chars []rune, from_idx, to_idx int) int

LastInstanceOfWS finds the last instance of whitespace in the characters.

Parameters:

  • chars: The characters.
  • from_idx: The starting index. (inclusive)
  • to_idx: The ending index. (exclusive)

Returns:

  • int: The index of the last whitespace character. -1 if not found.

Behaviors:

  • If from_idx < 0, from_idx is set to 0.
  • If to_idx >= len(chars), to_idx is set to len(chars) - 1.
  • If from_idx > to_idx, from_idx and to_idx are swapped.

FIXME: Remove this function once MyGoLib is updated.

func Lex added in v0.1.8

func Lex[T gr.TokenTyper](s *cds.Stream[byte], productions []*gr.RegProduction[T], v *Verbose) error

func PrintCode added in v0.1.19

func PrintCode[T gr.TokenTyper](data []rune, tokens []*gr.Token[T]) string

PrintCode prints the code but highlights the faulty line.

A faulty line is defined as the line containing the last token as, supposedly, the last token is the one that caused the error.

Parameters:

  • data: The original data read.
  • tokens: The tokens lexed.

Returns:

  • string: The formatted code.

Example:

data := []rune("Hello, word!")
tokens := []*gr.Token{
  {ID: TkWord, Data: "Hello", At: 0},
  {ID: TkComma, Data: ",", At: 6},
  {ID: TkWord, Data: "word", At: 8}, // Invalid token (expected "world")
  {ID: gr.TkEof, Data: nil, At: -1},
}

str := PrintCode(data, tokens)
fmt.Println(str)

Output:

Hello, word!
       ^^^^

Types

type ActiveLexer added in v0.1.19

type ActiveLexer[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

func NewActiveLexer added in v0.1.19

func NewActiveLexer[T gr.TokenTyper]() *ActiveLexer[T]

func (*ActiveLexer[T]) GetTokens added in v0.1.19

func (al *ActiveLexer[T]) GetTokens() ([]*gr.Token[T], SyntaxErrorer)

GetTokens gets the tokens.

Returns:

  • []*gr.Token: The tokens. Nil if lexer has finished.
  • SyntaxErrorer: The syntax error.

type ClosestSyntaxError added in v0.1.19

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

ClosestSyntaxError is a syntax error that represents a syntax error where the closest keyword is suggested.

func NewClosestSyntaxError added in v0.1.19

func NewClosestSyntaxError(reason *ErrUnexpectedChar, closest, actual string, end_idx int) *ClosestSyntaxError

NewClosestSyntaxError creates a new ClosestSyntaxError.

Parameters:

  • unexpected_char: The unexpected character.
  • previous_char: The previous character.
  • got_char: The got character.
  • end_idx: The end index.

Returns:

  • *ClosestSyntaxError: The new ClosestSyntaxError.

func (*ClosestSyntaxError) Display added in v0.1.19

func (cse *ClosestSyntaxError) Display() []string

Display implements the SyntaxErrorer interface.

func (*ClosestSyntaxError) GetPosition added in v0.1.19

func (cse *ClosestSyntaxError) GetPosition() int

GetPosition implements the SyntaxErrorer interface.

type CoreIter added in v0.1.18

type CoreIter[T gr.TokenTyper] struct {

	// Tokens is the list of tokens.
	Tokens []*gr.Token[T]

	// SyntaxError is the syntax error.
	SyntaxError SyntaxErrorer
	// contains filtered or unexported fields
}

func (*CoreIter[T]) Consume added in v0.1.18

func (it *CoreIter[T]) Consume() ([][]*gr.Token[T], error)

func (*CoreIter[T]) Restart added in v0.1.18

func (it *CoreIter[T]) Restart()

func (*CoreIter[T]) Size added in v0.1.18

func (it *CoreIter[T]) Size() (count int)

type ErrAllMatchesFailed added in v0.1.13

type ErrAllMatchesFailed struct{}

ErrAllMatchesFailed is an error that is returned when all matches fail.

func NewErrAllMatchesFailed added in v0.1.13

func NewErrAllMatchesFailed() *ErrAllMatchesFailed

NewErrAllMatchesFailed creates a new error of type *ErrAllMatchesFailed.

Returns:

  • *ErrAllMatchesFailed: The new error.

func (*ErrAllMatchesFailed) Error added in v0.1.13

func (e *ErrAllMatchesFailed) Error() string

Error returns the error message: "all matches failed".

Returns:

  • string: The error message.

type ErrInvalidElement added in v0.1.13

type ErrInvalidElement struct{}

ErrInvalidElement is an error that is returned when an invalid element is found.

func NewErrInvalidElement added in v0.1.13

func NewErrInvalidElement() *ErrInvalidElement

NewErrInvalidElement creates a new error of type *ErrInvalidElement.

Returns:

  • *ErrInvalidElement: The new error.

func (*ErrInvalidElement) Error added in v0.1.13

func (e *ErrInvalidElement) Error() string

Error returns the error message: "invalid element".

Returns:

  • string: The error message.

type ErrLexerError added in v0.1.18

type ErrLexerError[T gr.TokenTyper] struct {
	At   int
	Prev []*gr.Token[T]
}

func NewErrLexerError added in v0.1.18

func NewErrLexerError[T gr.TokenTyper](at int, prev []*gr.Token[T]) *ErrLexerError[T]

func (*ErrLexerError[T]) Error added in v0.1.18

func (e *ErrLexerError[T]) Error() string

type ErrNoMatches added in v0.1.11

type ErrNoMatches struct{}

ErrNoMatches is an error that is returned when there are no matches at a position.

func NewErrNoMatches added in v0.1.11

func NewErrNoMatches() *ErrNoMatches

NewErrNoMatches creates a new error of type *ErrNoMatches.

Returns:

  • *ErrNoMatches: The new error.

func (*ErrNoMatches) Error added in v0.1.11

func (e *ErrNoMatches) Error() string

Error returns the error message: "no matches".

Returns:

  • string: The error message.

type ErrUnexpectedChar added in v0.1.19

type ErrUnexpectedChar struct {
	// Expected is the expected rune.
	Expected rune

	// Previous is the previous rune.
	Previous rune

	// Got is the got rune.
	Got *rune
}

ErrUnexpectedChar is an error that is returned when an unexpected character is found.

func NewErrUnexpectedChar added in v0.1.19

func NewErrUnexpectedChar(expected, previous rune, got *rune) *ErrUnexpectedChar

NewErrUnexpectedChar creates a new ErrUnexpectedChar.

Parameters:

  • expected: The expected rune.
  • previous: The previous rune.
  • got: The got rune.

Returns:

  • *ErrUnexpectedChar: The new ErrUnexpectedChar.

func (*ErrUnexpectedChar) Error added in v0.1.19

func (e *ErrUnexpectedChar) Error() string

Error implements the error interface.

Message: "expected <expected> after <previous>, found <got> instead".

type EvalStatus added in v0.1.13

type EvalStatus int

EvalStatus represents the status of an evaluation.

const (
	// EvalComplete represents a completed evaluation.
	EvalComplete EvalStatus = iota

	// EvalIncomplete represents an incomplete evaluation.
	EvalIncomplete

	// EvalError represents an evaluation that has an error.
	EvalError
)

func (EvalStatus) String added in v0.1.13

func (s EvalStatus) String() string

String implements the fmt.Stringer interface.

type GenericSyntaxError added in v0.1.19

type GenericSyntaxError struct {

	// Message is the error message.
	Message string

	// Suggestion is the suggestion.
	Suggestion string
	// contains filtered or unexported fields
}

GenericSyntaxError is a syntax error that represents a generic syntax error.

func NewGenericSyntaxError added in v0.1.19

func NewGenericSyntaxError(at int, message, suggestion string) *GenericSyntaxError

NewGenericSyntaxError creates a new GenericSyntaxError.

Parameters:

  • at: The position.
  • message: The error message.
  • suggestion: The suggestion.

Returns:

  • *GenericSyntaxError: The new GenericSyntaxError.

func (*GenericSyntaxError) Display added in v0.1.19

func (gse *GenericSyntaxError) Display() []string

Display implements the SyntaxErrorer interface.

func (*GenericSyntaxError) GetPosition added in v0.1.19

func (gse *GenericSyntaxError) GetPosition() int

GetPosition implements the SyntaxErrorer interface.

type Grammar added in v0.1.13

type Grammar[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

Grammar represents a context-free grammar.

func NewGrammar added in v0.1.13

func NewGrammar[T gr.TokenTyper](to_skip []T) *Grammar[T]

NewGrammar is a constructor of an empty LexerGrammar.

A context-free grammar is a set of productions, each of which consists of a non-terminal symbol and a sequence of symbols.

The non-terminal symbol is the left-hand side of the production, and the sequence of symbols is the right-hand side of the production.

The grammar also contains a set of symbols, which are the non-terminal and terminal symbols in the grammar.

Returns:

  • *LexerGrammar: A new empty LexerGrammar.

func (*Grammar[T]) AddRule added in v0.1.19

func (g *Grammar[T]) AddRule(lhs T, regex string) error

AddRule adds a new rule to the grammar.

Parameters:

  • lhs: The left-hand side of the production.
  • regex: The regular expression of the production.

Returns:

  • error: An error if there was a problem adding the rule.

func (*Grammar[T]) Fix added in v0.1.19

func (g *Grammar[T]) Fix() error

Fix implements the object.Fixer interface.

Never errors.

func (*Grammar[T]) GetRegexProds added in v0.1.13

func (g *Grammar[T]) GetRegexProds() []*gr.RegProduction[T]

GetRegexProds returns a slice of RegProduction in the grammar.

Returns:

  • []*RegProduction: A slice of RegProduction in the grammar.

func (*Grammar[T]) GetSymbols added in v0.1.13

func (g *Grammar[T]) GetSymbols() []T

GetSymbols returns a slice of symbols in the grammar.

Returns:

  • []T: A slice of symbols in the grammar.

func (*Grammar[T]) GetToSkip added in v0.1.13

func (g *Grammar[T]) GetToSkip() []T

GetToSkip returns a slice of LHSs to skip.

Returns:

  • []T: A slice of LHSs to skip.

type Lexer

type Lexer[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

Lexer is a lexer that uses a grammar to tokenize a string.

func NewLexer

func NewLexer[T gr.TokenTyper](grammar *Grammar[T]) *Lexer[T]

NewLexer creates a new lexer.

Parameters:

  • grammar: The grammar to use.

Returns:

  • Lexer: The new lexer.

Example:

lexer, err := NewLexer(grammar)
if err != nil {
    // Handle error.
}

iter := lexer.Lex([]byte("1 + 2"))

var branch *cds.Stream[gr.Token]
var err error

for {
    branch, err = iter.Consume()
    if err != nil {
        break
    }

    // Parse the branch.
}

ok := IsDone(err)
if !ok {
    // Handle error.
}

// Finished successfully.

func (*Lexer[T]) Lex

func (l *Lexer[T]) Lex(input []byte, logger *Verbose) *LexerIterator[T]

Lex is the main function of the lexer. This can be parallelized.

Parameters:

  • source: The source to lex.
  • logger: A verbose logger.

Returns:

  • Lexer: The active lexer. Nil if there are no tokens to lex or grammar is invalid.

Errors:

  • *ErrNoTokensToLex: There are no tokens to lex.
  • *ErrNoMatches: No matches are found in the source.
  • *ErrAllMatchesFailed: All matches failed.
  • *gr.ErrNoProductionRulesFound: No production rules are found in the grammar.

type LexerIterator added in v0.1.18

type LexerIterator[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

LexerIterator is an iterator that uses a grammar to tokenize a string.

func FullLexer

func FullLexer[T gr.TokenTyper](grammar *Grammar[T], input []byte, logger *Verbose) *LexerIterator[T]

FullLexer is a convenience function that creates a new lexer, lexes the content, and returns the token streams.

Parameters:

  • grammar: The grammar to use.
  • input: The input to lex.
  • logger: A verbose logger.

Returns:

  • *LexerIterator: The lexer iterator.

func (*LexerIterator[T]) Consume added in v0.1.18

func (li *LexerIterator[T]) Consume() (*cds.Stream[*gr.Token[T]], error)

Consume implements the Iterater interface.

func (*LexerIterator[T]) Restart added in v0.1.18

func (li *LexerIterator[T]) Restart()

Restart implements the Iterater interface.

func (*LexerIterator[T]) Size added in v0.1.18

func (li *LexerIterator[T]) Size() (count int)

Size implements the Iterater interface.

Size is calculated by the number of leaves in the source iterator and the number of completed leaves.

type Printer added in v0.1.18

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

func NewPrinter added in v0.1.18

func NewPrinter() *Printer

func (*Printer) Close added in v0.1.18

func (p *Printer) Close()

func (*Printer) Print added in v0.1.18

func (p *Printer) Print(a ...interface{})

func (*Printer) Printf added in v0.1.18

func (p *Printer) Printf(format string, a ...interface{})

func (*Printer) Start added in v0.1.18

func (p *Printer) Start()

type SolutionIterator added in v0.1.19

type SolutionIterator[T any] struct {
	// contains filtered or unexported fields
}

func NewSolutionIterator added in v0.1.19

func NewSolutionIterator[T any](source uc.Iterater[[]T]) *SolutionIterator[T]

func (*SolutionIterator[T]) Consume added in v0.1.19

func (si *SolutionIterator[T]) Consume() (T, error)

type SourceIterator added in v0.1.18

type SourceIterator[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

SourceIterator is an iterator that uses a grammar to tokenize a string.

func (*SourceIterator[T]) Consume added in v0.1.18

func (si *SourceIterator[T]) Consume() (*leaves_result[T], error)

Consume implements the Iterater interface.

func (*SourceIterator[T]) Restart added in v0.1.18

func (si *SourceIterator[T]) Restart()

Restart implements the Iterater interface.

func (*SourceIterator[T]) Size added in v0.1.18

func (si *SourceIterator[T]) Size() (count int)

Size implements the Iterater interface.

Size is calculated by the number of leaves in the tree. of course, this is just an approximation as, to get the exact size, we would need to traverse the entire tree.

type SyntaxErrorer added in v0.1.19

type SyntaxErrorer interface {
	// Display displays the syntax error.
	//
	// Returns:
	//   - []string: The lines to display.
	Display() []string

	// GetPosition gets the position of the syntax error.
	//
	// Returns:
	//   - int: The position.
	GetPosition() int
}

SyntaxErrorer is an interface that represents a syntax error.

type TokenNode added in v0.1.19

type TokenNode[T gr.TokenTyper] struct {
	Parent, FirstChild, NextSibling, LastChild, PrevSibling *TokenNode[T]
	Status                                                  EvalStatus
	Token                                                   *gr.Token[T]
}

TokenNode is a node in a tree.

func NewTokenNode added in v0.1.19

func NewTokenNode[T gr.TokenTyper](token *gr.Token[T]) *TokenNode[T]

NewTokenNode creates a new node with the given data.

Parameters:

  • token: The Token of the node.

Returns:

  • *TokenNode[T]: A pointer to the newly created node. It is never nil.

func (*TokenNode[T]) AddChild added in v0.1.19

func (tn *TokenNode[T]) AddChild(child treenode.Noder)

AddChild adds a new child to the node. If the child is nil or it is not of type *TokenNode[T], it does nothing.

This function clears the parent and sibling pointers of the child and so, it does not add relatives to the child.

Parameters:

  • child: The child to add.

func (*TokenNode[T]) AddChildren added in v0.1.19

func (tn *TokenNode[T]) AddChildren(children []*TokenNode[T])

AddChildren is a convenience function to add multiple children to the node at once. It is more efficient than adding them one by one. Therefore, the behaviors are the same as the behaviors of the TokenNode.AddChild function.

Parameters:

  • children: The children to add.

func (*TokenNode[T]) Cleanup added in v0.1.19

func (tn *TokenNode[T]) Cleanup()

Cleanup implements the treenode.Noder interface.

This is expensive as it has to traverse the whole tree to clean up the nodes, one by one. While this is useful for freeing up memory, for large enough trees, it is recommended to let the garbage collector handle the cleanup.

Despite the above, this function does not use recursion and is safe to use (but make sure goroutines are not running on the tree while this function is called).

Finally, it also logically removes the node from the siblings and the parent.

func (*TokenNode[T]) Copy added in v0.1.19

func (tn *TokenNode[T]) Copy() common.Copier

Copy implements the treenode.Noder interface.

It never returns nil and it does not copy the parent or the sibling pointers.

func (*TokenNode[T]) DeleteChild added in v0.1.19

func (tn *TokenNode[T]) DeleteChild(target treenode.Noder) []treenode.Noder

DeleteChild implements the treenode.Noder interface.

No nil nodes are returned.

func (*TokenNode[T]) GetAncestors added in v0.1.19

func (tn *TokenNode[T]) GetAncestors() []treenode.Noder

GetAncestors implements the treenode.Noder interface.

This is expensive since ancestors are not stored and so, every time this function is called, it has to traverse the tree to find the ancestors. Thus, it is recommended to call this function once and then store the ancestors somewhere if needed.

Despite the above, this function does not use recursion and is safe to use.

Finally, no nil nodes are returned.

func (*TokenNode[T]) GetChildren added in v0.1.19

func (tn *TokenNode[T]) GetChildren() []treenode.Noder

GetChildren returns the immediate children of the node.

The returned nodes are never nil and are not copied. Thus, modifying the returned nodes will modify the tree.

Returns:

  • []treenode.Noder: A slice of pointers to the children of the node.

func (*TokenNode[T]) GetFirstChild added in v0.1.19

func (tn *TokenNode[T]) GetFirstChild() treenode.Noder

GetFirstChild implements the treenode.Noder interface.

func (*TokenNode[T]) GetFirstSibling added in v0.1.19

func (tn *TokenNode[T]) GetFirstSibling() *TokenNode[T]

GetFirstSibling returns the first sibling of the node. If it has a parent, it returns the first child of the parent. Otherwise, it returns the first sibling of the node.

As an edge case, if the node has no parent and no previous sibling, it returns the node itself. Thus, this function never returns nil.

Returns:

  • *TokenNode[T]: A pointer to the first sibling.

func (*TokenNode[T]) GetLastSibling added in v0.1.19

func (tn *TokenNode[T]) GetLastSibling() *TokenNode[T]

GetLastSibling returns the last sibling of the node. If it has a parent, it returns the last child of the parent. Otherwise, it returns the last sibling of the node.

As an edge case, if the node has no parent and no next sibling, it returns the node itself. Thus, this function never returns nil.

Returns:

  • *TokenNode[T]: A pointer to the last sibling.

func (*TokenNode[T]) GetLeaves added in v0.1.19

func (tn *TokenNode[T]) GetLeaves() []treenode.Noder

GetLeaves implements the treenode.Noder interface.

This is expensive as leaves are not stored and so, every time this function is called, it has to do a DFS traversal to find the leaves. Thus, it is recommended to call this function once and then store the leaves somewhere if needed.

Despite the above, this function does not use recursion and is safe to use.

Finally, no nil nodes are returned.

func (*TokenNode[T]) GetParent added in v0.1.19

func (tn *TokenNode[T]) GetParent() treenode.Noder

GetParent implements the treenode.Noder interface.

func (*TokenNode[T]) HasChild added in v0.1.19

func (tn *TokenNode[T]) HasChild(target *TokenNode[T]) bool

HasChild returns true if the node has the given child.

Because children of a node cannot be nil, a nil target will always return false.

Parameters:

  • target: The child to check for.

Returns:

  • bool: True if the node has the child, false otherwise.

func (*TokenNode[T]) IsChildOf added in v0.1.19

func (tn *TokenNode[T]) IsChildOf(target *TokenNode[T]) bool

IsChildOf returns true if the node is a child of the parent. If target is nil, it returns false.

Parameters:

  • target: The target parent to check for.

Returns:

  • bool: True if the node is a child of the parent, false otherwise.

func (*TokenNode[T]) IsLeaf added in v0.1.19

func (tn *TokenNode[T]) IsLeaf() bool

IsLeaf implements the treenode.Noder interface.

func (*TokenNode[T]) IsRoot added in v0.1.19

func (tn *TokenNode[T]) IsRoot() bool

IsRoot returns true if the node does not have a parent.

Returns:

  • bool: True if the node is the root, false otherwise.

func (*TokenNode[T]) IsSingleton added in v0.1.19

func (tn *TokenNode[T]) IsSingleton() bool

IsSingleton implements the treenode.Noder interface.

func (*TokenNode[T]) Iterator added in v0.1.19

func (tn *TokenNode[T]) Iterator() common.Iterater[treenode.Noder]

Iterator implements the treenode.Noder interface.

This function iterates over the children of the node, it is a pull-based iterator, and never returns nil.

func (*TokenNode[T]) LinkChildren added in v0.1.19

func (tn *TokenNode[T]) LinkChildren(children []treenode.Noder)

LinkWithParent implements the treenode.Noder interface.

Children that are not of type *TokenNode[T] or nil are ignored.

func (*TokenNode[T]) RemoveNode added in v0.1.19

func (tn *TokenNode[T]) RemoveNode() []treenode.Noder

RemoveNode removes the node from the tree while shifting the children up one level to maintain the tree structure.

Also, the returned children can be used to create a forest of trees if the root node is removed.

Returns:

  • []treenode.Noder: A slice of pointers to the children of the node iff the node is the root. Nil otherwise.

Example:

// Given the tree:
1
├── 2
└── 3
	├── 4
	└── 5
└── 6

// The tree after removing node 3:

1
├── 2
└── 4
└── 5
└── 6

func (*TokenNode[T]) SetParent added in v0.1.19

func (tn *TokenNode[T]) SetParent(parent treenode.Noder) bool

SetParent implements the treenode.Noder interface.

func (*TokenNode[T]) Size added in v0.1.19

func (tn *TokenNode[T]) Size() int

Size implements the treenode.Noder interface.

This is expensive as it has to traverse the whole tree to find the size of the tree. Thus, it is recommended to call this function once and then store the size somewhere if needed.

Despite the above, this function does not use recursion and is safe to use.

Finally, the traversal is done in a depth-first manner.

func (*TokenNode[T]) String added in v0.1.19

func (tn *TokenNode[T]) String() string

String implements the treenode.Noder interface.

type TokenNodeIterator added in v0.1.19

type TokenNodeIterator[T gr.TokenTyper] struct {
	// contains filtered or unexported fields
}

TokenNodeIterator is a pull-based iterator that iterates over the children of a TokenNode.

func (*TokenNodeIterator[T]) Consume added in v0.1.19

func (iter *TokenNodeIterator[T]) Consume() (treenode.Noder, error)

Consume implements the common.Iterater interface.

*common.ErrExhaustedIter is the only error returned by this function and the returned node is never nil.

func (*TokenNodeIterator[T]) Restart added in v0.1.19

func (iter *TokenNodeIterator[T]) Restart()

Restart implements the common.Iterater interface.

type UnrecognizedSyntaxError added in v0.1.19

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

UnrecognizedSyntaxError is a syntax error that represents an unrecognized syntax error.

func NewUnrecognizedSyntaxError added in v0.1.19

func NewUnrecognizedSyntaxError(char rune, at int) *UnrecognizedSyntaxError

NewUnrecognizedSyntaxError creates a new UnrecognizedSyntaxError.

Parameters:

  • char: The character.
  • at: The position.

Returns:

  • *UnrecognizedSyntaxError: The new UnrecognizedSyntaxError.

func (*UnrecognizedSyntaxError) Display added in v0.1.19

func (use *UnrecognizedSyntaxError) Display() []string

Display implements the SyntaxErrorer interface.

func (*UnrecognizedSyntaxError) GetPosition added in v0.1.19

func (use *UnrecognizedSyntaxError) GetPosition() int

GetPosition implements the SyntaxErrorer interface.

type Verbose added in v0.1.18

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

func NewVerbose added in v0.1.18

func NewVerbose(active bool) *Verbose

func (*Verbose) Close added in v0.1.18

func (v *Verbose) Close()

func (*Verbose) DoIf added in v0.1.18

func (v *Verbose) DoIf(doFunc func(p *Printer))

Jump to

Keyboard shortcuts

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