lpg2

package
v0.0.0-...-210bc1a Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: EPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package lpg2 Package command provides console operations, like options/arguments reading.

Package lpg2 Package gerror provides simple functions to manipulate errors.

Very note that, this package is quite a base package, which should not import extra packages except standard packages, to avoid cycle imports.

Package lpg2 Package gstr provides functions for string handling.

Index

Constants

View Source
const BEFORE_CODE int = 2
View Source
const BUFF_SIZE int = 32
View Source
const BUFF_UBOUND int = 31
View Source
const (
	CodeNil = -1 // No error code specified.
)
View Source
const DELETION_CODE int = 6
View Source
const END_COLUMN_INDEX int = 5
View Source
const END_LINE_INDEX int = 4
View Source
const EOF int = 0xffff
View Source
const EOF_CODE int = 10
View Source
const ERROR_CODE int = 1
View Source
const ERROR_RULE_ERROR_CODE int = 11
View Source
const ERROR_RULE_WARNING_CODE int = 12
View Source
const INSERTION_CODE int = 3
View Source
const INVALID_CODE int = 4
View Source
const INVALID_TOKEN_CODE int = 11
View Source
const LENGTH_INDEX int = 1
View Source
const LEX_ERROR_CODE int = 0
View Source
const MANUAL_CODE int = 14
View Source
const MAX_DISTANCE int = 30
View Source
const MERGE_CODE int = 7
View Source
const MIN_DISTANCE int = 3
View Source
const MISPLACED_CODE int = 8
View Source
const NIL int = -1
View Source
const NIL_CODE int = -1
View Source
const NO_MESSAGE_CODE int = 13
View Source
const (
	// NotFoundIndex is the position index for string not found in searching functions.
	NotFoundIndex = -1
)
View Source
const OFFSET_INDEX int = 0
View Source
const SCOPE_CODE int = 9
View Source
const SECONDARY_CODE int = 5
View Source
const START_COLUMN_INDEX int = 3
View Source
const START_LINE_INDEX int = 2
View Source
const SUBSTITUTION_CODE int = 5
View Source
const (
	StackFilterKeyForLPG2 = "https://github.com/A-LPG" // Stack filtering key for all GoFrame module paths.
)

Variables

View Source
var (
	// DefaultTrimChars are the characters which are stripped by Trim* functions in default.
	DefaultTrimChars = string([]byte{
		'\t',
		'\v',
		'\n',
		'\r',
		'\f',
		' ',
		0x00,
		0x85,
		0xA0,
	})
)

Functions

func AddSlashes

func AddSlashes(str string) string

AddSlashes quotes chars('"\) with slashes.

func AppendRune

func AppendRune(str string, c rune) string

func Arraycopy

func Arraycopy(src []int, srcPos int,
	dest []int, destPos int, length int) []int

func Cause

func Cause(err error) error

Cause returns the root cause error of <err>.

func CharAt

func CharAt(str string, start int) rune

func Chr

func Chr(ascii int) string

Chr return the ascii string of a number(0-255).

func ChunkSplit

func ChunkSplit(body string, chunkLen int, end string) string

ChunkSplit splits a string into smaller chunks. Can be used to split a string into smaller chunks which is useful for e.g. converting BASE64 string output to match RFC 2045 semantics. It inserts end every chunkLen characters. It considers parameter <body> and <end> as unicode string.

func Code

func Code(err error) int

Code returns the error code of current error. It returns -1 if it has no error code or it does not implements interface Code.

func Compare

func Compare(a, b string) int

Compare returns an integer comparing two strings lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func ContainsOpt

func ContainsOpt(Name string) bool

ContainsOpt checks whether option named `Name` exist in the arguments.

func Count

func Count(s, substr string) int

Count counts the number of <substr> appears in <s>. It returns 0 if no <substr> found in <s>.

func CountChars

func CountChars(str string, noSpace ...bool) map[string]int

CountChars returns information about chars' count used in a string. It considers parameter <str> as unicode string.

func CountI

func CountI(s, substr string) int

CountI counts the number of <substr> appears in <s>, case-insensitively. It returns 0 if no <substr> found in <s>.

func CountWords

func CountWords(str string) map[string]int

CountWords returns information about words' count used in a string. It considers parameter <str> as unicode string.

func Current

func Current(err error) error

Current creates and returns the current level error. It returns nil if current level error is nil.

func Equal

func Equal(a, b string) bool

Equal reports whether <a> and <b>, interpreted as UTF-8 strings, are equal under Unicode case-folding, case-insensitively.

func EqualFoldWithoutChars

func EqualFoldWithoutChars(s1, s2 string) bool

EqualFoldWithoutChars checks string `s1` and `s2` equal case-insensitively, with/without chars '-'/'_'/'.'/' '.

func Explode

func Explode(delimiter, str string) []string

Explode splits string <str> by a string <delimiter>, to an array. See http://php.net/manual/en/function.explode.php.

func Fields

func Fields(str string) []string

Fields returns the words used in a string as slice.

func GetArg

func GetArg(index int, def ...string) string

GetArg returns the argument at `index`.

func GetArgAll

func GetArgAll() []string

GetArgAll returns all parsed arguments.

func GetOpt

func GetOpt(Name string, def ...string) string

GetOpt returns the option value named `Name`.

func GetOptAll

func GetOptAll() map[string]string

GetOptAll returns all parsed options.

func GetOptWithEnv

func GetOptWithEnv(key string, def ...string) string

GetOptWithEnv returns the command line argument of the specified `key`. If the argument does not exist, then it returns the environment variable with specified `key`. It returns the default value `def` if none of them exists.

Fetching Rules: 1. Command line arguments are in lowercase format, eg: gf.<package Name>.<variable Name>; 2. Environment arguments are in uppercase format, eg: GF_<package Name>_<variable Name>;

func HasPrefix

func HasPrefix(s, prefix string) bool

HasPrefix tests whether the string s begins with prefix.

func HasSuffix

func HasSuffix(s, suffix string) bool

HasSuffix tests whether the string s ends with suffix.

func HideStr

func HideStr(str string, percent int, hide string) string

HideStr replaces part of the the string <str> to <hide> by <percentage> from the <middle>. It considers parameter <str> as unicode string.

func Implode

func Implode(glue string, pieces []string) string

Implode joins array elements <pieces> with a string <glue>. http://php.net/manual/en/function.implode.php

func InArray

func InArray(a []string, s string) bool

InArray checks whether string <s> in slice <a>.

func Init

func Init(args ...string)

Init Custom initialization.

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled checks and returns whether debug mode is enabled. The debug mode is enabled when command argument "gf.debug" or environment "GF_DEBUG" is passed.

func IsLetter

func IsLetter(b byte) bool

IsLetter checks whether the given byte b is a letter.

func IsLetterLower

func IsLetterLower(b byte) bool

IsLetterLower checks whether the given byte b is in lower case.

func IsLetterUpper

func IsLetterUpper(b byte) bool

IsLetterUpper checks whether the given byte b is in upper case.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric checks whether the given string s is numeric. Note that float string like "123.456" is also numeric.

func Join

func Join(array []string, sep string) string

Join concatenates the elements of <array> to create a single string. The separator string <sep> is placed between elements in the resulting string.

func LcFirst

func LcFirst(s string) string

LcFirst returns a copy of the string s with the first letter mapped to its lower case.

func LenRune

func LenRune(str string) int

LenRune returns string length of unicode.

func New

func New(text string) error

New creates and returns an error which is formatted from given text.

func NewCode

func NewCode(code int, text string) error

NewCode creates and returns an error that has error code and given text.

func NewCodeSkip

func NewCodeSkip(code, skip int, text string) error

NewCodeSkip creates and returns an error which has error code and is formatted from given text. The parameter <skip> specifies the stack callers skipped amount.

func NewCodeSkipf

func NewCodeSkipf(code, skip int, format string, args ...interface{}) error

NewCodeSkipf returns an error that has error code and formats as the given format and args. The parameter <skip> specifies the stack callers skipped amount.

func NewCodef

func NewCodef(code int, format string, args ...interface{}) error

NewCodef returns an error that has error code and formats as the given format and args.

func NewErr

func NewErr(text string) error

func NewSkip

func NewSkip(skip int, text string) error

NewSkip creates and returns an error which is formatted from given text. The parameter <skip> specifies the stack callers skipped amount.

func NewSkipf

func NewSkipf(skip int, format string, args ...interface{}) error

NewSkipf returns an error that formats as the given format and args. The parameter <skip> specifies the stack callers skipped amount.

func Newf

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

Newf returns an error that formats as the given format and args.

func Next

func Next(err error) error

Next returns the next level error. It returns nil if current level error or the next level error is nil.

func Nl2Br

func Nl2Br(str string, isXhtml ...bool) string

Nl2Br inserts HTML line breaks(<br>|<br />) before all newlines in a string: \n\r, \r\n, \r, \n. It considers parameter <str> as unicode string.

func Now

func Now() int

func NumberFormat

func NumberFormat(number float64, decimals int, decPoint, thousandsSep string) string

NumberFormat formats a number with grouped thousands. <decimals>: Sets the number of decimal points. <decPoint>: Sets the separator for the decimal point. <thousandsSep>: Sets the thousands separator. See http://php.net/manual/en/function.number-format.php.

func ObjectArraycopy

func ObjectArraycopy(src []interface{}, srcPos int,
	dest []interface{}, destPos int, length int) []interface{}

func Ord

func Ord(char string) int

Ord converts the first byte of a string to a value between 0 and 255.

func QuoteMeta

func QuoteMeta(str string, chars ...string) string

QuoteMeta returns a version of str with a backslash character (\) before every character that is among: .\+*?[^]($)

func RemoveSymbols

func RemoveSymbols(s string) string

RemoveSymbols removes all symbols from string and lefts only numbers and letters.

func Repeat

func Repeat(input string, multiplier int) string

Repeat returns a new string consisting of multiplier copies of the string input.

func Replace

func Replace(origin, search, replace string, count ...int) string

Replace returns a copy of the string <origin> in which string <search> replaced by <replace> case-sensitively.

func ReplaceByArray

func ReplaceByArray(origin string, array []string) string

ReplaceByArray returns a copy of <origin>, which is replaced by a slice in order, case-sensitively.

func ReplaceByMap

func ReplaceByMap(origin string, replaces map[string]string) string

ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.

func ReplaceI

func ReplaceI(origin, search, replace string, count ...int) string

ReplaceI Replace returns a copy of the string <origin> in which string <search> replaced by <replace> case-insensitively.

func ReplaceIByArray

func ReplaceIByArray(origin string, array []string) string

ReplaceIByArray returns a copy of <origin>, which is replaced by a slice in order, case-insensitively.

func ReplaceIByMap

func ReplaceIByMap(origin string, replaces map[string]string) string

ReplaceIByMap returns a copy of <origin>, which is replaced by a map in unordered way, case-insensitively.

func Reverse

func Reverse(str string) string

Reverse returns a string which is the reverse of <str>.

func RuneLen

func RuneLen(str string) int

RuneLen returns string length of unicode. Deprecated, use LenRune instead.

func SearchArray

func SearchArray(a []string, s string) int

SearchArray searches string <s> in string slice <a> case-sensitively, returns its index in <a>. If <s> is not found in <a>, it returns -1.

func Split

func Split(str, delimiter string) []string

Split splits string <str> by a string <delimiter>, to an array.

func SplitAndTrim

func SplitAndTrim(str, delimiter string, characterMask ...string) []string

SplitAndTrim splits string <str> by a string <delimiter> to an array, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.

func SplitAndTrimSpace

func SplitAndTrimSpace(str, delimiter string) []string

SplitAndTrimSpace splits string <str> by a string <delimiter> to an array, and calls TrimSpace to every element of this array. Deprecated, use SplitAndTrim instead.

func Stack

func Stack(err error) string

Stack returns the stack callers as string. It returns the error string directly if the <err> does not support stacks.

func Str

func Str(haystack string, needle string) string

Str returns part of <haystack> string starting from and including the first occurrence of <needle> to the end of <haystack>. See http://php.net/manual/en/function.strstr.php.

func StrEx

func StrEx(haystack string, needle string) string

StrEx returns part of <haystack> string starting from and excluding the first occurrence of <needle> to the end of <haystack>.

func StrLimit

func StrLimit(str string, length int, suffix ...string) string

StrLimit returns a portion of string <str> specified by <length> parameters, if the length of <str> is greater than <length>, then the <suffix> will be appended to the result string.

func StrLimitRune

func StrLimitRune(str string, length int, suffix ...string) string

StrLimitRune returns a portion of string <str> specified by <length> parameters, if the length of <str> is greater than <length>, then the <suffix> will be appended to the result string. StrLimitRune considers parameter <str> as unicode string.

func StrTill

func StrTill(haystack string, needle string) string

StrTill returns part of <haystack> string ending to and including the first occurrence of <needle> from the start of <haystack>.

func StrTillEx

func StrTillEx(haystack string, needle string) string

StrTillEx returns part of <haystack> string ending to and excluding the first occurrence of <needle> from the start of <haystack>.

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

func StripSlashes

func StripSlashes(str string) string

StripSlashes un-quotes a quoted string by AddSlashes.

func SubStr

func SubStr(str string, start int, length ...int) string

SubStr returns a portion of string <str> specified by the <start> and <length> parameters.

func SubStrRune

func SubStrRune(str string, start int, length ...int) (substr string)

func SubStrRuneRange

func SubStrRuneRange(str string, start int, length ...int) ([]rune, int, int)

SubStrRune returns a portion of string <str> specified by the <start> and <length> parameters. SubStrRune considers parameter <str> as unicode string.

func ToLower

func ToLower(s string) string

ToLower returns a copy of the string s with all Unicode letters mapped to their lower case.

func ToUpper

func ToUpper(s string) string

ToUpper returns a copy of the string s with all Unicode letters mapped to their upper case.

func Trim

func Trim(str string, characterMask ...string) string

Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter <characterMask> specifies the additional stripped characters.

func UcFirst

func UcFirst(s string) string

UcFirst returns a copy of the string s with the first letter mapped to its upper case.

func UcWords

func UcWords(str string) string

UcWords uppercase the first character of each word in a string.

func WordWrap

func WordWrap(str string, width int, br string) string

WordWrap wraps a string to a given number of characters. TODO: Enable cut parameter, see http://php.net/manual/en/function.wordwrap.php.

func Wrap

func Wrap(err error, text string) error

Wrap wraps error with text. It returns nil if given err is nil.

func WrapCode

func WrapCode(code int, err error, text string) error

WrapCode wraps error with code and text. It returns nil if given err is nil.

func WrapCodeSkip

func WrapCodeSkip(code, skip int, err error, text string) error

WrapCodeSkip wraps error with code and text. It returns nil if given err is nil. The parameter <skip> specifies the stack callers skipped amount.

func WrapCodeSkipf

func WrapCodeSkipf(code, skip int, err error, format string, args ...interface{}) error

WrapCodeSkipf wraps error with code and text that is formatted with given format and args. It returns nil if given err is nil. The parameter <skip> specifies the stack callers skipped amount.

func WrapCodef

func WrapCodef(code int, err error, format string, args ...interface{}) error

WrapCodef wraps error with code and format specifier. It returns nil if given <err> is nil.

func WrapSkip

func WrapSkip(skip int, err error, text string) error

WrapSkip wraps error with text. It returns nil if given err is nil. The parameter <skip> specifies the stack callers skipped amount.

func WrapSkipf

func WrapSkipf(skip int, err error, format string, args ...interface{}) error

WrapSkipf wraps error with text that is formatted with given format and args. It returns nil if given err is nil. The parameter <skip> specifies the stack callers skipped amount.

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. It returns nil if given <err> is nil.

Types

type AbstractToken

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

func NewAbstractToken

func NewAbstractToken(startOffSet int, endOffSet int, kind int,
	iPrsStream IPrsStream) *AbstractToken

func (*AbstractToken) GetAdjunctIndex

func (a *AbstractToken) GetAdjunctIndex() int

func (*AbstractToken) GetColumn

func (a *AbstractToken) GetColumn() int

func (*AbstractToken) GetEndColumn

func (a *AbstractToken) GetEndColumn() int

func (*AbstractToken) GetEndLine

func (a *AbstractToken) GetEndLine() int

func (*AbstractToken) GetEndOffset

func (a *AbstractToken) GetEndOffset() int

func (*AbstractToken) GetFollowingAdjuncts

func (a *AbstractToken) GetFollowingAdjuncts() []IToken

func (*AbstractToken) GetILexStream

func (a *AbstractToken) GetILexStream() ILexStream

func (*AbstractToken) GetIPrsStream

func (a *AbstractToken) GetIPrsStream() IPrsStream

func (*AbstractToken) GetKind

func (a *AbstractToken) GetKind() int

func (*AbstractToken) GetLine

func (a *AbstractToken) GetLine() int

func (*AbstractToken) GetPrecedingAdjuncts

func (a *AbstractToken) GetPrecedingAdjuncts() []IToken

func (*AbstractToken) GetStartOffset

func (a *AbstractToken) GetStartOffset() int

func (*AbstractToken) GetTokenIndex

func (a *AbstractToken) GetTokenIndex() int

func (*AbstractToken) SetAdjunctIndex

func (a *AbstractToken) SetAdjunctIndex(adjunctIndex int)

func (*AbstractToken) SetEndOffset

func (a *AbstractToken) SetEndOffset(endOffSet int)

func (*AbstractToken) SetKind

func (a *AbstractToken) SetKind(kind int)

func (*AbstractToken) SetStartOffset

func (a *AbstractToken) SetStartOffset(startOffSet int)

func (*AbstractToken) SetTokenIndex

func (a *AbstractToken) SetTokenIndex(tokenIndex int)

func (*AbstractToken) ToString

func (a *AbstractToken) ToString() string

type Adjunct

type Adjunct struct {
	*AbstractToken
}

func NewAdjunct

func NewAdjunct(startOffSet int, endOffSet int, kind int, prsStream IPrsStream) *Adjunct

func (*Adjunct) GetFollowingAdjuncts

func (a *Adjunct) GetFollowingAdjuncts() []IToken

func (*Adjunct) GetPrecedingAdjuncts

func (a *Adjunct) GetPrecedingAdjuncts() []IToken

type ArrayList

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

func NewArrayList

func NewArrayList() *ArrayList

func NewArrayListFrom

func NewArrayListFrom(array []interface{}) *ArrayList

func NewArrayListFromCopy

func NewArrayListFromCopy(array []interface{}) *ArrayList

func NewArrayListSize

func NewArrayListSize(size int, cap int) *ArrayList

func (*ArrayList) Add

func (a *ArrayList) Add(elem interface{}) *ArrayList

func (*ArrayList) At

func (a *ArrayList) At(index int) (value interface{})

func (*ArrayList) Clear

func (a *ArrayList) Clear() bool

func (*ArrayList) Clone

func (a *ArrayList) Clone() *ArrayList

func (*ArrayList) Contains

func (a *ArrayList) Contains(val interface{}) bool

func (*ArrayList) Get

func (a *ArrayList) Get(index int) interface{}

func (*ArrayList) IndexOf

func (a *ArrayList) IndexOf(elem interface{}) int

func (*ArrayList) IsEmpty

func (a *ArrayList) IsEmpty() bool

func (*ArrayList) LastIndexOf

func (a *ArrayList) LastIndexOf(elem interface{}) int

func (*ArrayList) Remove

func (a *ArrayList) Remove(value interface{}) bool

func (*ArrayList) RemoveAll

func (a *ArrayList) RemoveAll() bool

func (*ArrayList) RemoveAt

func (a *ArrayList) RemoveAt(index int) (value interface{}, found bool)

func (*ArrayList) Search

func (a *ArrayList) Search(value interface{}) int

func (*ArrayList) Set

func (a *ArrayList) Set(index int, element interface{}) bool

func (*ArrayList) Size

func (a *ArrayList) Size() int

func (*ArrayList) ToArray

func (a *ArrayList) ToArray() []interface{}

type BacktrackingParser

type BacktrackingParser struct {
	*Stacks

	START_STATE     int
	NUM_RULES       int
	NT_OFFSET       int
	LA_STATE_OFFSET int
	EOFT_SYMBOL     int
	ERROR_SYMBOL    int
	ACCEPT_ACTION   int
	ERROR_ACTION    int
	// contains filtered or unexported fields
}

func NewBacktrackingParser

func NewBacktrackingParser(tokStream TokenStream, prs ParseTable,
	ra RuleAction, monitor Monitor) (*BacktrackingParser, error)

func (*BacktrackingParser) BacktrackParse

func (my *BacktrackingParser) BacktrackParse(stack []int, stack_top int, action *IntSegmentedTuple, initial_token int) int

This method is intended to be used by the type RecoveryParser. Note that the action tuple passed here must be the same action tuple that was passed down to RecoveryParser. It is passed back to my method as documention.

func (*BacktrackingParser) BacktrackParseUpToError

func (my *BacktrackingParser) BacktrackParseUpToError(initial_token int, error_token int)

func (*BacktrackingParser) ErrorRepair

func (my *BacktrackingParser) ErrorRepair(stream IPrsStream, recovery_token int, error_token int) int

func (*BacktrackingParser) FindRecoveryStateIndex

func (my *BacktrackingParser) FindRecoveryStateIndex(start_index int) int

func (*BacktrackingParser) FuzzyParse

func (my *BacktrackingParser) FuzzyParse() (interface{}, error)

FuzzyParse Always attempt to recover

func (*BacktrackingParser) FuzzyParseEntry

func (my *BacktrackingParser) FuzzyParseEntry(marker_kind int, max_error_count int) (interface{}, error)

func (*BacktrackingParser) FuzzyParseWithErrorCount

func (my *BacktrackingParser) FuzzyParseWithErrorCount(max_error_count int) (interface{}, error)

FuzzyParseWithErrorCount Recover up to max_error_count times and then quit

func (*BacktrackingParser) GetCurrentRule

func (my *BacktrackingParser) GetCurrentRule() int

func (*BacktrackingParser) GetFirstToken

func (my *BacktrackingParser) GetFirstToken() int

func (*BacktrackingParser) GetFirstTokenAt

func (my *BacktrackingParser) GetFirstTokenAt(i int) int

func (*BacktrackingParser) GetLastToken

func (my *BacktrackingParser) GetLastToken() int

func (*BacktrackingParser) GetLastTokenAt

func (my *BacktrackingParser) GetLastTokenAt(i int) int

func (*BacktrackingParser) GetMarkerToken

func (my *BacktrackingParser) GetMarkerToken(marker_kind int, start_token_index int) (int, error)

A starting marker indicates that we are dealing with an entry point for a given nonterminal. We need to execute a shift action on the marker in order to parse the entry point in question.

func (*BacktrackingParser) GetToken

func (my *BacktrackingParser) GetToken(i int) int

Override the GetToken function in Stacks.

func (*BacktrackingParser) Lookahead

func (my *BacktrackingParser) Lookahead(act int, token int) int

keep looking ahead until we compute a valid action

func (*BacktrackingParser) Parse

func (my *BacktrackingParser) Parse(max_error_count int) (interface{}, error)

Parse input allowing up to max_error_count Error token recoveries. When max_error_count is 0, no Error token recoveries occur. When max_error is > 0, it limits the number of Error token recoveries. When max_error is < 0, the number of error token recoveries is unlimited. Also, such recoveries only require one token to be parsed beyond the recovery point. (normally two tokens beyond the recovery point must be parsed) Thus, a negative max_error_count should be used when error productions are used to skip tokens.

func (*BacktrackingParser) ParseActions

func (my *BacktrackingParser) ParseActions(marker_kind int) (interface{}, error)

Now do the final parse of the input based on the actions in the list "action" and the sequence of tokens in list "tokens".

func (*BacktrackingParser) ParseEntry

func (my *BacktrackingParser) ParseEntry(marker_kind int, max_error_count int) (interface{}, error)

Parse input allowing up to max_error_count Error token recoveries. When max_error_count is 0, no Error token recoveries occur. When max_error is > 0, it limits the int of Error token recoveries. When max_error is < 0, the int of error token recoveries is unlimited. Also, such recoveries only require one token to be parsed beyond the recovery point. (normally two tokens beyond the recovery point must be parsed) Thus, a negative max_error_count should be used when error productions are used to skip tokens.

func (*BacktrackingParser) Process_backtrack_reductions

func (my *BacktrackingParser) Process_backtrack_reductions(act int) int

Process reductions and continue...

func (*BacktrackingParser) Process_reductions

func (my *BacktrackingParser) Process_reductions()

Process reductions and continue...

func (*BacktrackingParser) ReallocateOtherStacks

func (my *BacktrackingParser) ReallocateOtherStacks(startTokenIndex int)

Allocate or reallocate all the stacks. Their sizes should always be the same.

func (*BacktrackingParser) Repairable

func (my *BacktrackingParser) Repairable(error_token int) bool

func (*BacktrackingParser) Reset

func (my *BacktrackingParser) Reset(tokStream TokenStream, prs ParseTable, ra RuleAction, monitor Monitor) error

func (*BacktrackingParser) Reset1

func (my *BacktrackingParser) Reset1() error

func (*BacktrackingParser) Reset2

func (my *BacktrackingParser) Reset2(tokStream TokenStream, monitor Monitor) error

func (*BacktrackingParser) Reset3

func (my *BacktrackingParser) Reset3(tokStream TokenStream, prs ParseTable, ra RuleAction) error

func (*BacktrackingParser) SetMonitor

func (my *BacktrackingParser) SetMonitor(monitor Monitor)

func (*BacktrackingParser) TAction

func (my *BacktrackingParser) TAction(act int, sym int) int

Compute the next action defined on act and sym. If my action requires more Lookahead, these Lookahead symbols are in the token stream beginning at the next token that is yielded by Peek().

type BadParseException

type BadParseException struct {
	ErrorToken int
	// contains filtered or unexported fields
}

func NewBadParseException

func NewBadParseException(errorToken int) *BadParseException

func (*BadParseException) Error

func (a *BadParseException) Error() string

Error implements the interface of Error, it returns all the error as string.

func (*BadParseException) ToString

func (a *BadParseException) ToString() string

type BadParseSymFileException

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

func NewBadParseSymFileException

func NewBadParseSymFileException(info string) *BadParseSymFileException

func (*BadParseSymFileException) Error

func (a *BadParseSymFileException) Error() string

Error implements the interface of Error, it returns all the error as string.

func (*BadParseSymFileException) ToString

func (a *BadParseSymFileException) ToString() string

type ConfigurationElement

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

func NewConfigurationElement

func NewConfigurationElement() *ConfigurationElement

func (*ConfigurationElement) RetrieveStack

func (a *ConfigurationElement) RetrieveStack(stack []int)

type ConfigurationStack

type ConfigurationStack struct {
	TABLE_SIZE int
	// contains filtered or unexported fields
}

func NewConfigurationStack

func NewConfigurationStack(prs ParseTable) *ConfigurationStack

func (*ConfigurationStack) FindConfiguration

func (my *ConfigurationStack) FindConfiguration(stack []int, stack_top int, curtok int) bool

func (*ConfigurationStack) FindOrInsertStack

func (my *ConfigurationStack) FindOrInsertStack(root *StateElement, stack []int, index int, stack_top int) *StateElement

func (*ConfigurationStack) MakeStateList

func (my *ConfigurationStack) MakeStateList(parent *StateElement, stack []int, index int, stack_top int) *StateElement

func (*ConfigurationStack) MaxConfigurationSize

func (my *ConfigurationStack) MaxConfigurationSize() int

func (*ConfigurationStack) NumStateElements

func (my *ConfigurationStack) NumStateElements() int

func (*ConfigurationStack) Pop

func (*ConfigurationStack) Push

func (my *ConfigurationStack) Push(stack []int, stack_top int, conflict_index int, curtok int, action_length int)

func (*ConfigurationStack) StacksSize

func (my *ConfigurationStack) StacksSize() int

func (*ConfigurationStack) Top

type DeterministicParser

type DeterministicParser struct {
	*Stacks

	START_STATE     int
	NUM_RULES       int
	NT_OFFSET       int
	LA_STATE_OFFSET int
	EOFT_SYMBOL     int
	ACCEPT_ACTION   int
	ERROR_ACTION    int
	ERROR_SYMBOL    int
	// contains filtered or unexported fields
}

func NewDeterministicParser

func NewDeterministicParser(tokStream TokenStream, prs ParseTable, ra RuleAction, monitor Monitor) (*DeterministicParser, error)

func (*DeterministicParser) ErrorReset

func (my *DeterministicParser) ErrorReset()

Reset the parser at a point where it can legally process the error token. If we can't do that, Reset it to the beginning.

func (*DeterministicParser) GetCurrentRule

func (my *DeterministicParser) GetCurrentRule() int

The following functions can be invoked only when the parser is processing actions. Thus, they can be invoked when the parser was entered via the main entry point (parse()). When using the incremental parser (via the entry point parse(int [], int)), an Exception is thrown if any of these functions is invoked? However, note that when ParseActions() is invoked after successfully parsing an input with the incremental parser, then they can be invoked.

func (*DeterministicParser) GetFirstToken

func (my *DeterministicParser) GetFirstToken() int

func (*DeterministicParser) GetFirstTokenAt

func (my *DeterministicParser) GetFirstTokenAt(i int) int

func (*DeterministicParser) GetLastToken

func (my *DeterministicParser) GetLastToken() int

func (*DeterministicParser) GetLastTokenAt

func (my *DeterministicParser) GetLastTokenAt(i int) int

func (*DeterministicParser) Lookahead

func (my *DeterministicParser) Lookahead(act int, token int) int

keep looking ahead until we compute a valid action

func (*DeterministicParser) Parse

func (my *DeterministicParser) Parse(sym []int, index int) (int, error)

This is an incremental LALR(k) parser that takes as argument the next k tokens in the input. If these k tokens are valid for the current configuration, it advances past the first of the k tokens and returns either

. the last transition induced by that token
. the Accept action

If the tokens are not valid, the initial configuration remains unchanged and the Error action is returned.

Note that it is the user's responsibility to start the parser in a proper configuration by initially invoking the method ResetParser prior to invoking my function.

func (*DeterministicParser) ParseActions

func (my *DeterministicParser) ParseActions() interface{}

Now do the final parse of the input based on the actions in the list "action" and the sequence of tokens in the token stream.

func (*DeterministicParser) ParseEntry

func (my *DeterministicParser) ParseEntry(marker_kind int) (interface{}, error)

func (*DeterministicParser) ProcessReductions

func (my *DeterministicParser) ProcessReductions()

Process reductions and continue...

func (*DeterministicParser) RecoverableState

func (my *DeterministicParser) RecoverableState(state int) bool

Find a state in the state stack that has a valid action on ERROR token

func (*DeterministicParser) Reset

func (my *DeterministicParser) Reset(tokStream TokenStream, prs ParseTable, ra RuleAction, monitor Monitor) error

func (*DeterministicParser) Reset1

func (my *DeterministicParser) Reset1()

func (*DeterministicParser) Reset2

func (my *DeterministicParser) Reset2(tokStream TokenStream, monitor Monitor)

func (*DeterministicParser) ResetParser

func (my *DeterministicParser) ResetParser()

This method is invoked when using the parser in an incremental mode using the entry point parse(int [], int).

func (*DeterministicParser) ResetParserEntry

func (my *DeterministicParser) ResetParserEntry(marker_kind int)

This method is invoked when using the parser in an incremental mode using the entry point parse(int [], int).

func (*DeterministicParser) SetMonitor

func (my *DeterministicParser) SetMonitor(monitor Monitor)

func (*DeterministicParser) TAction

func (my *DeterministicParser) TAction(act int, sym []int, index int) int

Compute the next action defined on act and the next k tokens whose types are stored in the array sym starting at location index. The array sym is a circular buffer. If we reach the last element of sym and we need more Lookahead, we proceed to the first element.

assert(sym.length == prs.GetMaxLa())

func (*DeterministicParser) TAction1

func (my *DeterministicParser) TAction1(act int, sym int) int

Compute the next action defined on act and sym. If my action requires more Lookahead, these Lookahead symbols are in the token stream beginning at the next token that is yielded by Peek().

type DiagnoseParser

type DiagnoseParser struct {
	ERROR_SYMBOL    int
	SCOPE_SIZE      int
	MAX_NAME_LENGTH int
	NT_OFFSET       int
	LA_STATE_OFFSET int
	NUM_RULES       int
	NUM_SYMBOLS     int
	START_STATE     int
	EOFT_SYMBOL     int
	EOLT_SYMBOL     int
	ACCEPT_ACTION   int
	ERROR_ACTION    int

	STACK_INCREMENT int
	// contains filtered or unexported fields
}

func NewDiagnoseParser

func NewDiagnoseParser(tokStream TokenStream, prs ParseTable, maxErrors int, maxTime int, monitor Monitor) *DiagnoseParser

func NewDiagnoseParserExt

func NewDiagnoseParserExt(dispatch DiagnoseParserBase, tokStream TokenStream, prs ParseTable, maxErrors int, maxTime int, monitor Monitor) *DiagnoseParser

func (*DiagnoseParser) Asb

func (my *DiagnoseParser) Asb(index int) int

func (*DiagnoseParser) Asi

func (my *DiagnoseParser) Asi(state int) int

func (*DiagnoseParser) BaseAction

func (my *DiagnoseParser) BaseAction(index int) int

func (*DiagnoseParser) BaseCheck

func (my *DiagnoseParser) BaseCheck(index int) int

func (*DiagnoseParser) CheckPrimaryDistance

func (my *DiagnoseParser) CheckPrimaryDistance(repair *PrimaryRepairInfo, stck []int, stack_top int)

func (*DiagnoseParser) Diagnose

func (my *DiagnoseParser) Diagnose(error_token int)

func (*DiagnoseParser) DiagnoseEntry

func (my *DiagnoseParser) DiagnoseEntry(marker_kind int, error_token int)

func (*DiagnoseParser) DiagnoseEntryWithMarkerKind

func (my *DiagnoseParser) DiagnoseEntryWithMarkerKind(marker_kind int)

func (*DiagnoseParser) EmitError

func (my *DiagnoseParser) EmitError(msg_code int, name_index int, left_token int, right_token int, scope_name_index int)

func (*DiagnoseParser) ErrorRecovery

func (my *DiagnoseParser) ErrorRecovery(error_token int) *RepairCandidate
This routine is invoked when an error is encountered.  It

tries to Diagnose the error and recover from it. If it is successful, the state stack, the current token and the buffer are readjusted i.e., after a successful recovery, state_stack_top points to the location in the state stack that contains the state on which to recover current_token identifies the symbol on which to recover.

Up to three configurations may be available when my routine is invoked. PREV_STACK may contain the sequence of states preceding any action on prevtok, STACK always contains the sequence of states preceding any action on current_token, and NEXT_STACK may contain the sequence of states preceding any action on the successor of current_token.

func (*DiagnoseParser) GetNtermIndex

func (my *DiagnoseParser) GetNtermIndex(start int, sym int, buffer_position int) int

This function takes as parameter a starting state number: start, a nonterminal symbol, A (candidate), and an integer, buffer_position, which points to the position of the next input token in the BUFFER. It returns the highest level non-terminal B such that B =>*rm A. I.e., there does not exists a nonterminal C such that C =>+rm B. (Recall that for an LALR(k) grammar if C =>+rm B, it cannot be the case that B =>+rm C)

func (*DiagnoseParser) GetTermIndex

func (my *DiagnoseParser) GetTermIndex(stck []int, stack_top int, tok int, buffer_position int) int

This function takes as parameter an integer STACK_TOP that points to a STACK element containing the state on which a primary recovery will be made the terminal candidate on which to recover and an integer: buffer_position, which points to the position of the next input token in the BUFFER. The parser is simulated until a shift (or shift-reduce) action is computed on the candidate. Then we proceed to compute the the Name index of the highest level nonterminal that can directly or indirectly produce the candidate.

func (*DiagnoseParser) InSymb

func (my *DiagnoseParser) InSymb(index int) int

func (*DiagnoseParser) InSymbol

func (my *DiagnoseParser) InSymbol(state int) int

func (*DiagnoseParser) IsNullable

func (my *DiagnoseParser) IsNullable(symbol int) bool

func (*DiagnoseParser) Lhs

func (my *DiagnoseParser) Lhs(index int) int

func (*DiagnoseParser) Lookahead

func (my *DiagnoseParser) Lookahead(act int, token int) int

keep looking ahead until we compute a valid action

func (*DiagnoseParser) MergeCandidate

func (my *DiagnoseParser) MergeCandidate(state int, buffer_position int) int
This function checks whether or not a given state has a

candidate, whose string representaion is a merging of the two tokens at positions buffer_position and buffer_position+1 in the buffer. If so, it returns the candidate in question otherwise it returns 0.

func (*DiagnoseParser) MisplacementRecovery

func (my *DiagnoseParser) MisplacementRecovery(repair *SecondaryRepairInfo, stack []int, stack_top int,
	last_index int, stack_flag bool)

This bool function checks whether or not a given configuration yields a better misplacement recovery than the best misplacement recovery computed previously.

func (*DiagnoseParser) Misspell

func (my *DiagnoseParser) Misspell(sym int, tok int) int
Check whether or not there is a high probability that a

given string is a misspelling of another. Certain singleton symbols (such as ":" and "") are also considered to be misspellings of each other.

func (*DiagnoseParser) Name

func (my *DiagnoseParser) Name(index int) string

func (*DiagnoseParser) Nasb

func (my *DiagnoseParser) Nasb(index int) int

func (*DiagnoseParser) Nasi

func (my *DiagnoseParser) Nasi(state int) int

func (*DiagnoseParser) Nasr

func (my *DiagnoseParser) Nasr(index int) int

func (*DiagnoseParser) NonterminalIndex

func (my *DiagnoseParser) NonterminalIndex(index int) int

func (*DiagnoseParser) NtAction

func (my *DiagnoseParser) NtAction(state int, sym int) int

func (*DiagnoseParser) OriginalState

func (my *DiagnoseParser) OriginalState(state int) int

func (*DiagnoseParser) ParseCheck

func (my *DiagnoseParser) ParseCheck(stack []int, stack_top int, first_symbol int, buffer_position int) int

Try to parse until first_symbol and all tokens in BUFFER have been consumed, or an error is encountered. Return the number of tokens that were expended before the parse blocked.

func (*DiagnoseParser) ParseForError

func (my *DiagnoseParser) ParseForError(current_kind int) int

Given the configuration consisting of the states in tempStack and the sequence of tokens (current_kind, followed by the tokens in tokStream), keep parsing until either the parse completes successfully or it encounters an error. If the parse is not succesful, we return the farthest token on which an error was encountered. Otherwise, we return 0.

func (*DiagnoseParser) ParseUpToError

func (my *DiagnoseParser) ParseUpToError(action *IntTuple, current_kind int, error_token int)

Given the configuration consisting of the states in tempStack and the sequence of tokens (current_kind, followed by the tokens in tokStream), parse up to error_token in the tokStream and store all the parsing actions executed in the "action" tuple.

func (*DiagnoseParser) PrimaryDiagnosis

func (my *DiagnoseParser) PrimaryDiagnosis(repair *PrimaryRepairInfo) *RepairCandidate

This procedure is invoked to issue a diagnostic message and adjust the input buffer. The recovery in question is either the insertion of one or more scopes, the merging of the error token with its successor, the deletion of the error token, the insertion of a single token in front of the error token or the substitution of another token for the error token.

func (*DiagnoseParser) PrimaryPhase

func (my *DiagnoseParser) PrimaryPhase(error_token int) *RepairCandidate

This function tries primary and scope recovery on each available configuration. If a successful recovery is found and no secondary phase recovery can do better, a diagnosis is issued, the configuration is updated and the function returns "true". Otherwise, it returns "false".

func (*DiagnoseParser) ReallocateStacks

func (my *DiagnoseParser) ReallocateStacks()

func (*DiagnoseParser) Rhs

func (my *DiagnoseParser) Rhs(index int) int

func (*DiagnoseParser) ScopeLa

func (my *DiagnoseParser) ScopeLa(index int) int

func (*DiagnoseParser) ScopeLhs

func (my *DiagnoseParser) ScopeLhs(index int) int

func (*DiagnoseParser) ScopePrefix

func (my *DiagnoseParser) ScopePrefix(index int) int

func (*DiagnoseParser) ScopeRhs

func (my *DiagnoseParser) ScopeRhs(index int) int

func (*DiagnoseParser) ScopeState

func (my *DiagnoseParser) ScopeState(index int) int

func (*DiagnoseParser) ScopeStateSet

func (my *DiagnoseParser) ScopeStateSet(index int) int

func (*DiagnoseParser) ScopeSuffix

func (my *DiagnoseParser) ScopeSuffix(index int) int

func (*DiagnoseParser) ScopeTrialCheck

func (my *DiagnoseParser) ScopeTrialCheck(repair *PrimaryRepairInfo, stack []int, stack_top int, indx int)

func (*DiagnoseParser) SecondaryCheck

func (my *DiagnoseParser) SecondaryCheck(stack []int, stack_top int, buffer_position int, distance int) bool

This function computes the ParseCheck distance for the best possible secondary recovery for a given configuration that either deletes none or only one symbol in the forward context. If the recovery found is more effective than the best primary recovery previously computed, then the function returns true. Only misplacement, scope and manual recoveries are attempted simple insertion or substitution of a nonterminal are tried in CHECK_PRIMARY_DISTANCE as part of primary recovery.

func (*DiagnoseParser) SecondaryDiagnosis

func (my *DiagnoseParser) SecondaryDiagnosis(repair *SecondaryRepairInfo)

This procedure is invoked to issue a secondary diagnosis and adjust the input buffer. The recovery in question is either an automatic scope recovery, a manual scope recovery, a secondary substitution or a secondary deletion.

func (*DiagnoseParser) SecondaryPhase

func (my *DiagnoseParser) SecondaryPhase(error_token int) *RepairCandidate

Secondary_phase is a bool function that checks whether or not some form of secondary recovery is applicable to one of the error configurations. First, if "next_stack" is available, misplacement and secondary recoveries are attempted on it. Then, in any case, these recoveries are attempted on "stack". If a successful recovery is found, a diagnosis is issued, the configuration is updated and the function returns "true". Otherwise, the function returns false.

func (*DiagnoseParser) SecondaryRecovery

func (my *DiagnoseParser) SecondaryRecovery(repair *SecondaryRepairInfo, stack []int, stack_top int, last_index int, stack_flag bool)

This function checks whether or not a given configuration yields a better secondary recovery than the best misplacement recovery computed previously.

func (*DiagnoseParser) SetMonitor

func (my *DiagnoseParser) SetMonitor(monitor Monitor)

func (*DiagnoseParser) SymbolIndex

func (my *DiagnoseParser) SymbolIndex(index int) int

func (*DiagnoseParser) TAction

func (my *DiagnoseParser) TAction(act int, sym int) int

Compute the next action defined on act and sym. If my action requires more Lookahead, these Lookahead symbols are in the token stream beginning at the next token that is yielded by Peek().

func (*DiagnoseParser) TermAction

func (my *DiagnoseParser) TermAction(index int) int

func (*DiagnoseParser) TermCheck

func (my *DiagnoseParser) TermCheck(index int) int

func (*DiagnoseParser) TerminalIndex

func (my *DiagnoseParser) TerminalIndex(index int) int

type DiagnoseParserBase

type DiagnoseParserBase interface {
	ReallocateStacks()
}

type Error

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

Error is custom error for additional features.

func (*Error) Cause

func (err *Error) Cause() error

Cause returns the root cause error.

func (*Error) Code

func (err *Error) Code() int

Code returns the error code. It returns -1 if it has no error code.

func (*Error) Current

func (err *Error) Current() error

Current creates and returns the current level error. It returns nil if current level error is nil.

func (*Error) Error

func (err *Error) Error() string

Error implements the interface of Error, it returns all the error as string.

func (*Error) Format

func (err *Error) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%v, %s : Print all the error string; %-v, %-s : Print current level error string; %+s : Print full stack error list; %+v : Print the error string and full stack error list;

func (*Error) MarshalJSON

func (err *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal. Note that do not use pointer as its receiver here.

func (*Error) Next

func (err *Error) Next() error

Next returns the next level error. It returns nil if current level error or the next level error is nil.

func (*Error) Stack

func (err *Error) Stack() string

Stack returns the stack callers as string. It returns an empty string if the <err> does not support stacks.

type ErrorToken

type ErrorToken struct {
	*Token
	// contains filtered or unexported fields
}

func NewErrorToken

func NewErrorToken(firstToken IToken, lastToken IToken, errorToken IToken, startOffSet int, endOffSet int,
	kind int) *ErrorToken

func (*ErrorToken) GetErrorToken

func (a *ErrorToken) GetErrorToken() IToken

func (*ErrorToken) GetFirstRealToken

func (a *ErrorToken) GetFirstRealToken() IToken

func (*ErrorToken) GetFirstToken

func (a *ErrorToken) GetFirstToken() IToken

func (*ErrorToken) GetFollowingAdjuncts

func (a *ErrorToken) GetFollowingAdjuncts() []IToken

func (*ErrorToken) GetLastRealToken

func (a *ErrorToken) GetLastRealToken() IToken

func (*ErrorToken) GetLastToken

func (a *ErrorToken) GetLastToken() IToken

func (*ErrorToken) GetPrecedingAdjuncts

func (a *ErrorToken) GetPrecedingAdjuncts() []IToken

type IAbstractArrayList

type IAbstractArrayList interface {
	Size() int
	GetElementAt(i int) IAst
	GetList() *ArrayList
	Add(elt IAst) bool
}

type IAst

type IAst interface {
	GetNextAst() IAst

	SetParent(IAst)

	GetParent() IAst

	GetLeftIToken() IToken

	GetRightIToken() IToken

	GetPrecedingAdjuncts() []IToken

	GetFollowingAdjuncts() []IToken

	GetChildren() *ArrayList

	GetAllChildren() *ArrayList

	Accept(IAstVisitor)
}

type IAstVisitor

type IAstVisitor interface {
	PreVisit(element IAst) bool
	PostVisit(element IAst)
}

type ILexStream

type ILexStream interface {
	TokenStream

	GetIPrsStream() IPrsStream

	SetPrsStream(stream IPrsStream)

	GetLineCount() int

	OrderedExportedSymbols() []string

	GetLineOffSet(i int) int

	GetLineNumberOfCharAt(i int) int

	GetColumnOfCharAt(i int) int

	GetCharValue(i int) string
	GetInputChars() []rune

	GetIntValue(i int) int

	MakeToken(startLoc int, endLoc int, kind int)

	SetMessageHandler(handler IMessageHandler)

	GetMessageHandler() IMessageHandler

	GetLocation(leftLoc int, rightLoc int) []int
	ReportLexicalErrorPosition(leftLoc int, rightLoc int)
	ReportLexicalError(leftLoc int, rightLoc int,
		errorCode int, errorLeftLoc int, errorRightLoc int, errorInfo []string)

	ToString(startOffSet int, endOffSet int) string
}

type IMessageHandler

type IMessageHandler interface {
	HandleMessage(error_code int, msg_location []int, error_location []int,
		filename string, error_info []string)
}

type IPrsStream

type IPrsStream interface {
	TokenStream

	GetMessageHandler() IMessageHandler

	SetMessageHandler(handler IMessageHandler)

	GetILexStream() ILexStream

	SetLexStream(lexStream ILexStream)

	MakeToken(startLoc int, endLoc int, kind int)

	MakeAdjunct(startLoc int, endLoc int, kind int)

	RemoveLastToken()

	GetLineCount() int

	GetSize() int

	RemapTerminalSymbols(ordered_parser_symbols []string, eof_symbol int) error

	OrderedTerminalSymbols() []string

	MapKind(kind int) int

	ResetTokenStream()

	GetStreamIndex() int

	ResetStreamLength()
	SetStreamIndex(index int)

	SetStreamLength(length int)

	AddToken(token IToken)

	AddAdjunct(adjunct IToken)

	OrderedExportedSymbols() []string

	GetTokens() *TokenArrayList

	GetAdjuncts() *TokenArrayList

	GetFollowingAdjuncts(i int) []IToken

	GetPrecedingAdjuncts(i int) []IToken

	GetIToken(i int) IToken

	GetTokenText(i int) string

	GetStartOffset(i int) int

	GetEndOffSet(i int) int

	GetLineOffSet(i int) int

	GetLineNumberOfCharAt(i int) int

	GetColumnOfCharAt(i int) int

	GetTokenLength(i int) int

	GetLineNumberOfTokenAt(i int) int

	GetEndLineNumberOfTokenAt(i int) int

	GetColumnOfTokenAt(i int) int

	GetEndColumnOfTokenAt(i int) int

	GetInputChars() []rune

	ToStringFromIndex(first_token int, last_token int) string

	ToString(t1 IToken, t2 IToken) string

	GetTokenIndexAtCharacter(offSet int) int

	GetTokenAtCharacter(offSet int) IToken

	GetTokenAt(i int) IToken

	DumpTokens()

	DumpToken(i int)

	MakeErrorToken(first int, last int, error int, kind int) int
}

type IToken

type IToken interface {
	GetKind() int

	SetKind(kind int)

	GetStartOffset() int

	SetStartOffset(startOffset int)

	GetEndOffset() int

	SetEndOffset(endOffset int)

	GetTokenIndex() int

	SetTokenIndex(i int)

	GetAdjunctIndex() int

	SetAdjunctIndex(i int)

	GetPrecedingAdjuncts() []IToken

	GetFollowingAdjuncts() []IToken

	GetILexStream() ILexStream

	GetIPrsStream() IPrsStream

	GetLine() int

	GetColumn() int

	GetEndLine() int

	GetEndColumn() int

	ToString() string
}

type IntArrayList

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

func NewIntArrayList

func NewIntArrayList() *IntArrayList

func NewIntArrayListFrom

func NewIntArrayListFrom(array []int) *IntArrayList

func NewIntArrayListFromCopy

func NewIntArrayListFromCopy(array []int) *IntArrayList

func NewIntArrayListSize

func NewIntArrayListSize(size int, cap int) *IntArrayList

func (*IntArrayList) Add

func (a *IntArrayList) Add(elem int) *IntArrayList

func (*IntArrayList) At

func (a *IntArrayList) At(index int) (value int)

func (*IntArrayList) Clear

func (a *IntArrayList) Clear() bool

func (*IntArrayList) Clone

func (a *IntArrayList) Clone() *IntArrayList

func (*IntArrayList) Contains

func (a *IntArrayList) Contains(val int) bool

func (*IntArrayList) Get

func (a *IntArrayList) Get(index int) int

func (*IntArrayList) IndexOf

func (a *IntArrayList) IndexOf(elem int) int

func (*IntArrayList) IsEmpty

func (a *IntArrayList) IsEmpty() bool

func (*IntArrayList) LastIndexOf

func (a *IntArrayList) LastIndexOf(elem int) int

func (*IntArrayList) Remove

func (a *IntArrayList) Remove(value int) bool

func (*IntArrayList) RemoveAll

func (a *IntArrayList) RemoveAll() bool

func (*IntArrayList) RemoveAt

func (a *IntArrayList) RemoveAt(index int) (value int, found bool)

func (*IntArrayList) Search

func (a *IntArrayList) Search(value int) int

func (*IntArrayList) Set

func (a *IntArrayList) Set(index int, element int) bool

func (*IntArrayList) Size

func (a *IntArrayList) Size() int

func (*IntArrayList) ToArray

func (a *IntArrayList) ToArray() []int

type IntSegmentedTuple

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

func NewIntSegmentedTuple

func NewIntSegmentedTuple(logBlksize int, baseSize int) *IntSegmentedTuple

func NewIntSegmentedTupleDefault

func NewIntSegmentedTupleDefault() *IntSegmentedTuple

func (*IntSegmentedTuple) Add

func (a *IntSegmentedTuple) Add(element int)

Add an element to the dynamic array and return a reference to that element.

func (*IntSegmentedTuple) BinarySearch

func (a *IntSegmentedTuple) BinarySearch(element int) int

If array is sorted, a function will find the index location of a given element if it is contained in the array. Otherwise, it will return the negation of the index of the element prior to which the element would be inserted in the array.

func (*IntSegmentedTuple) Get

func (a *IntSegmentedTuple) Get(i int) int

Return a reference to the ith element of the dynamic array.

Note that no check is made here to ensure that 0 <= i < top. Such a check might be useful for debugging and a range exception should be thrown if it yields true.

func (*IntSegmentedTuple) NextIndex

func (a *IntSegmentedTuple) NextIndex() int

NextIndex Add an element to the dynamic array and return the top index.

func (*IntSegmentedTuple) Reset

func (a *IntSegmentedTuple) Reset()

This function is used to Reset the size of a dynamic array without allocating or deallocting space. It may be invoked with an integer argument n which indicates the size or with no argument which indicates that the size should be Reset to 0.

func (*IntSegmentedTuple) ResetTo

func (a *IntSegmentedTuple) ResetTo(n int)

func (*IntSegmentedTuple) Resize

func (a *IntSegmentedTuple) Resize()

This function is invoked with an integer argument n. It ensures that enough space is allocated for n elements in the dynamic array. I.e., that the array will be indexable in the range (0..n-1){

Note that a function can be used as a garbage collector. When invoked with no argument(or 0){, it frees up all dynamic space that was allocated for the array.

func (*IntSegmentedTuple) ResizeTo

func (a *IntSegmentedTuple) ResizeTo(n int)

func (*IntSegmentedTuple) Set

func (a *IntSegmentedTuple) Set(i int, element int)

Insert an element in the dynamic array at the location indicated.

func (*IntSegmentedTuple) Size

func (a *IntSegmentedTuple) Size() int

type IntTuple

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

func NewIntTuple

func NewIntTuple() *IntTuple

NewIntTuple Constructor of a Tuple

func NewIntTupleWithEstimate

func NewIntTupleWithEstimate(estimate int) *IntTuple

func (*IntTuple) Add

func (a *IntTuple) Add(element int)

Add an element to the dynamic array and return a reference to that element.

func (*IntTuple) Capacity

func (a *IntTuple) Capacity() int

func (*IntTuple) Get

func (a *IntTuple) Get(i int) int

Return a reference to the ith element of the dynamic array.

Note that no check is made here to ensure that 0 <= i < top. Such a check might be useful for debugging and a range exception should be thrown if it yields true.

func (*IntTuple) NextIndex

func (a *IntTuple) NextIndex() int

Add an element to the dynamic array and return the top index.

func (*IntTuple) Reset

func (a *IntTuple) Reset()

func (*IntTuple) ResetTo

func (a *IntTuple) ResetTo(n int)

This function is used to Reset the size of a dynamic array without allocating or deallocting space. It may be invoked with an integer argument n which indicates the size or with no argument which indicates that the size should be Reset to 0.

func (*IntTuple) Set

func (a *IntTuple) Set(index int, value int)

Insert an element in the dynamic array at the location indicated.

func (*IntTuple) Size

func (a *IntTuple) Size() int

Return size of the dynamic array.

type LexParser

type LexParser struct {
	STACK_INCREMENT int
	START_STATE     int
	LA_STATE_OFFSET int
	EOFT_SYMBOL     int
	ACCEPT_ACTION   int
	ERROR_ACTION    int
	START_SYMBOL    int
	NUM_RULES       int
	// contains filtered or unexported fields
}

func NewLexParser

func NewLexParser() *LexParser

func NewLexParserAndInit

func NewLexParserAndInit(tokStream ILexStream, prs ParseTable, ra RuleAction) *LexParser

func (*LexParser) GetCurrentRule

func (my *LexParser) GetCurrentRule() (int, error)

func (*LexParser) GetFirstToken

func (my *LexParser) GetFirstToken() int

func (*LexParser) GetFirstTokenAt

func (my *LexParser) GetFirstTokenAt(i int) int

The following functions can be invoked only when the parser is processing actions. Thus, they can be invoked when the parser was entered via the main entry point (ParseCharacters()). When using the incremental parser (via the entry point ScanNextToken(int [], int)), they always return 0 when invoked. // TODO Should we throw an Exception instead? However, note that when ParseActions() is invoked after successfully parsing an input with the incremental parser, then they can be invoked.

func (*LexParser) GetLastToken

func (my *LexParser) GetLastToken() int

func (*LexParser) GetLastTokenAt

func (my *LexParser) GetLastTokenAt(i int) int

func (*LexParser) GetSym

func (my *LexParser) GetSym(i int) int

func (*LexParser) GetToken

func (my *LexParser) GetToken(i int) int

Given a rule of the form A = x1 x2 ... xn n > 0

the function GetToken(i) yields the symbol xi, if xi is a terminal or ti, if xi is a nonterminal that produced a string of the form xi => ti w. If xi is a nullable nonterminal, then ti is the first

symbol that immediately follows xi in the input (the Lookahead).

func (*LexParser) LexNextCharacter

func (my *LexParser) LexNextCharacter(act int, kind int) int

This function takes as argument a configuration ([my.stack, stackTop], [my.tokStream, my.curtok]) and determines whether or not the reduce my.action the my.curtok can be validly parsed in my configuration.

func (*LexParser) LexNextToken

func (my *LexParser) LexNextToken(end_offSet int) bool

func (*LexParser) Lookahead

func (my *LexParser) Lookahead(act int, token int) int

keep looking ahead until we compute a valid action

func (*LexParser) ParseActions

func (my *LexParser) ParseActions()

Now do the final parse of the input based on the actions in the list "my.action" and the sequence of tokens in the token stream.

func (*LexParser) ParseCharacters

func (my *LexParser) ParseCharacters(start_offSet int, end_offSet int, monitor Monitor)

Parse the input and create a stream of tokens.

func (*LexParser) ParseCharactersWhitMonitor

func (my *LexParser) ParseCharactersWhitMonitor(monitor Monitor)

Parse the input and create a stream of tokens.

func (*LexParser) ParseNextCharacter

func (my *LexParser) ParseNextCharacter(token int, kind int)

This function takes as argument a configuration ([stack, stackTop], [tokStream, curtok]) and determines whether or not curtok can be validly parsed in my configuration. If so, it parses curtok and returns the final shift or shift-reduce action on it. Otherwise, it leaves the configuration unchanged and returns ERROR_ACTION.

func (*LexParser) ReallocateStacks

func (my *LexParser) ReallocateStacks()

func (*LexParser) Reset

func (my *LexParser) Reset(tokStream ILexStream, prs ParseTable, ra RuleAction)

func (*LexParser) ResetTokenStream

func (my *LexParser) ResetTokenStream(i int)

func (*LexParser) ScanNextToken

func (my *LexParser) ScanNextToken() bool

func (*LexParser) ScanNextTokenFromStartOffSet

func (my *LexParser) ScanNextTokenFromStartOffSet(start_offSet int) bool

func (*LexParser) SetSym1

func (my *LexParser) SetSym1(i int)

func (*LexParser) TAction

func (my *LexParser) TAction(act int, sym int) int

Compute the next action defined on act and sym. If my action requires more Lookahead, these Lookahead symbols are in the token stream beginning at the next token that is yielded by Peek().

type LexStream

type LexStream struct {
	DEFAULT_TAB int
	// contains filtered or unexported fields
}

func NewLexStream

func NewLexStream(fileName string, inputChars []rune, tab int, lineOffSets *IntSegmentedTuple) (*LexStream, error)

func NewLexStreamExt

func NewLexStreamExt(dispatch ILexStream, fileName string, inputChars []rune, tab int, lineOffSets *IntSegmentedTuple) (*LexStream, error)

func (*LexStream) AfterEol

func (my *LexStream) AfterEol(i int) bool

func (*LexStream) BadToken

func (my *LexStream) BadToken() int

func (*LexStream) ComputeLineOffSets

func (my *LexStream) ComputeLineOffSets()

func (*LexStream) GetCharValue

func (my *LexStream) GetCharValue(i int) string

func (*LexStream) GetColumn

func (my *LexStream) GetColumn(i int) int

func (*LexStream) GetColumnOfCharAt

func (my *LexStream) GetColumnOfCharAt(i int) int

func (*LexStream) GetEndColumn

func (my *LexStream) GetEndColumn(i int) int

func (*LexStream) GetEndLine

func (my *LexStream) GetEndLine(i int) int

func (*LexStream) GetFileName

func (my *LexStream) GetFileName() string

func (*LexStream) GetFileString

func (my *LexStream) GetFileString(fileName string) (*string, error)

func (*LexStream) GetFirstErrorToken

func (my *LexStream) GetFirstErrorToken(i int) int

func (*LexStream) GetFirstRealToken

func (my *LexStream) GetFirstRealToken(i int) int

func (*LexStream) GetIPrsStream

func (my *LexStream) GetIPrsStream() IPrsStream

func (*LexStream) GetInputChars

func (my *LexStream) GetInputChars() []rune

func (*LexStream) GetIntValue

func (my *LexStream) GetIntValue(i int) int

func (*LexStream) GetKind

func (my *LexStream) GetKind(i int) int

func (*LexStream) GetLastErrorToken

func (my *LexStream) GetLastErrorToken(i int) int

func (*LexStream) GetLastRealToken

func (my *LexStream) GetLastRealToken(i int) int

func (*LexStream) GetLine

func (my *LexStream) GetLine(i int) int

func (*LexStream) GetLineCount

func (my *LexStream) GetLineCount() int

func (*LexStream) GetLineNumberOfCharAt

func (my *LexStream) GetLineNumberOfCharAt(i int) int

func (*LexStream) GetLineOffSet

func (my *LexStream) GetLineOffSet(i int) int

func (*LexStream) GetLineOffSets

func (my *LexStream) GetLineOffSets() *IntSegmentedTuple

func (*LexStream) GetLocation

func (my *LexStream) GetLocation(leftLoc int, rightLoc int) []int

func (*LexStream) GetMessageHandler

func (my *LexStream) GetMessageHandler() IMessageHandler

func (*LexStream) GetName

func (my *LexStream) GetName(i int) string

func (*LexStream) GetNext

func (my *LexStream) GetNext(i int) int

func (*LexStream) GetPrevious

func (my *LexStream) GetPrevious(i int) int

func (*LexStream) GetStreamIndex

func (my *LexStream) GetStreamIndex() int

func (*LexStream) GetStreamLength

func (my *LexStream) GetStreamLength() int

func (*LexStream) GetTab

func (my *LexStream) GetTab() int

func (*LexStream) GetToken

func (my *LexStream) GetToken() int

func (*LexStream) GetTokenFromEndToken

func (my *LexStream) GetTokenFromEndToken(end_token int) int

func (*LexStream) MakeToken

func (my *LexStream) MakeToken(startLoc int, endLoc int, kind int)

func (*LexStream) OrderedExportedSymbols

func (my *LexStream) OrderedExportedSymbols() []string

func (*LexStream) Peek

func (my *LexStream) Peek() int

func (*LexStream) ReportError

func (my *LexStream) ReportError(errorCode int, leftToken int, rightToken int, errorInfo []string, errorToken int)

func (*LexStream) ReportLexicalError

func (my *LexStream) ReportLexicalError(leftLoc int, rightLoc int, errorCode int, errorLeftLoc int,
	errorRightLoc int, errorInfo []string)

func (*LexStream) ReportLexicalErrorPosition

func (my *LexStream) ReportLexicalErrorPosition(leftLoc int, rightLoc int)

func (*LexStream) Reset

func (my *LexStream) Reset()

func (*LexStream) ResetTo

func (my *LexStream) ResetTo(i int)

func (*LexStream) SetFileName

func (my *LexStream) SetFileName(fileName string)

func (*LexStream) SetInputChars

func (my *LexStream) SetInputChars(inputChars []rune)

func (*LexStream) SetLineOffSet

func (my *LexStream) SetLineOffSet(i int)

func (*LexStream) SetLineOffSets

func (my *LexStream) SetLineOffSets(lineOffSets *IntSegmentedTuple)

func (*LexStream) SetMessageHandler

func (my *LexStream) SetMessageHandler(errMsg IMessageHandler)

Here is where we report errors. The default method is simply to print the error message to the console. However, the user may supply an error message handler to process error messages. To support that a message handler interface is provided that has a single method HandleMessage(). The user has his error message handler class implement the IMessageHandler interface and provides an object of this type to the runtime using the SetMessageHandler(errorMsg) method. If the message handler object is Set, the ReportError methods will invoke its HandleMessage() method.

func (*LexStream) SetPrsStream

func (my *LexStream) SetPrsStream(prsStream IPrsStream)

func (*LexStream) SetStreamIndex

func (my *LexStream) SetStreamIndex(index int)

func (*LexStream) SetStreamLength

func (my *LexStream) SetStreamLength(streamLength int)

func (*LexStream) SetTab

func (my *LexStream) SetTab(tab int)

func (*LexStream) ToString

func (my *LexStream) ToString(startOffSet int, endOffSet int) string

type MismatchedInputCharsException

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

func NewMismatchedInputCharsException

func NewMismatchedInputCharsException(info string) *MismatchedInputCharsException

func (*MismatchedInputCharsException) Error

Error implements the interface of Error, it returns all the error as string.

func (*MismatchedInputCharsException) ToString

func (a *MismatchedInputCharsException) ToString() string

type Monitor

type Monitor interface {
	IsCancelled() bool
}

type NotBacktrackParseTableException

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

func NewNotBacktrackParseTableException

func NewNotBacktrackParseTableException(info string) *NotBacktrackParseTableException

func (*NotBacktrackParseTableException) Error

Error implements the interface of Error, it returns all the error as string.

func (*NotBacktrackParseTableException) ToString

type NotDeterministicParseTableException

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

func NewNotDeterministicParseTableException

func NewNotDeterministicParseTableException(info string) *NotDeterministicParseTableException

func (*NotDeterministicParseTableException) Error

Error implements the interface of Error, it returns all the error as string.

func (*NotDeterministicParseTableException) ToString

type NullExportedSymbolsException

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

func NewNullExportedSymbolsException

func NewNullExportedSymbolsException(info string) *NullExportedSymbolsException

func (*NullExportedSymbolsException) Error

Error implements the interface of Error, it returns all the error as string.

func (*NullExportedSymbolsException) ToString

func (a *NullExportedSymbolsException) ToString() string

type NullPointerException

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

func NewNullPointerException

func NewNullPointerException(info string) *NullPointerException

func (*NullPointerException) Error

func (a *NullPointerException) Error() string

Error implements the interface of Error, it returns all the error as string.

func (*NullPointerException) ToString

func (a *NullPointerException) ToString() string

type NullTerminalSymbolsException

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

func NewNullTerminalSymbolsException

func NewNullTerminalSymbolsException(info string) *NullTerminalSymbolsException

func (*NullTerminalSymbolsException) Error

Error implements the interface of Error, it returns all the error as string.

func (*NullTerminalSymbolsException) ToString

func (a *NullTerminalSymbolsException) ToString() string

type ObjectTuple

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

func NewObjectTuple

func NewObjectTuple() *ObjectTuple

NewObjectTuple Constructor of a Tuple

func NewObjectTupleWithEstimate

func NewObjectTupleWithEstimate(estimate int) *ObjectTuple

func (*ObjectTuple) Add

func (my *ObjectTuple) Add(element interface{})

Add an element to the dynamic array and return a reference to that element.

func (*ObjectTuple) Get

func (my *ObjectTuple) Get(i int) interface{}

Return a reference to the ith element of the dynamic array.

Note that no check is made here to ensure that 0 <= i < top. Such a check might be useful for debugging and a range exception should be thrown if it yields true.

func (*ObjectTuple) NextIndex

func (my *ObjectTuple) NextIndex() int

Add an element to the dynamic array and return the top index.

func (*ObjectTuple) Reset

func (my *ObjectTuple) Reset()

func (*ObjectTuple) ResetTo

func (my *ObjectTuple) ResetTo(n int)

This function is used to Reset the size of a dynamic array without allocating or deallocting space. It may be invoked with an integer argument n which indicates the size or with no argument which indicates that the size should be Reset to 0.

func (*ObjectTuple) Set

func (my *ObjectTuple) Set(index int, value interface{})

Insert an element in the dynamic array at the location indicated.

func (*ObjectTuple) Size

func (my *ObjectTuple) Size() int

Return size of the dynamic array.

type ParseTable

type ParseTable interface {
	BaseCheck(index int) int

	Rhs(index int) int

	BaseAction(index int) int

	Lhs(index int) int

	TermCheck(index int) int

	TermAction(index int) int

	Asb(index int) int

	Asr(index int) int

	Nasb(index int) int

	Nasr(index int) int

	TerminalIndex(index int) int

	NonterminalIndex(index int) int

	ScopePrefix(index int) int

	ScopeSuffix(index int) int

	ScopeLhs(index int) int

	ScopeLa(index int) int

	ScopeStateSet(index int) int

	ScopeRhs(index int) int

	ScopeState(index int) int

	InSymb(index int) int

	Name(index int) string

	OriginalState(state int) int

	Asi(state int) int

	Nasi(state int) int

	InSymbol(state int) int

	NtAction(state int, sym int) int

	TAction(act int, sym int) int

	LookAhead(act int, sym int) int

	GetErrorSymbol() int

	GetScopeUbound() int

	GetScopeSize() int

	GetMaxNameLength() int

	GetNumStates() int

	GetNtOffset() int

	GetLaStateOffset() int

	GetMaxLa() int

	GetNumRules() int

	GetNumNonterminals() int

	GetNumSymbols() int

	GetStartState() int

	GetStartSymbol() int

	GetEoftSymbol() int

	GetEoltSymbol() int

	GetAcceptAction() int

	GetErrorAction() int

	IsNullable(symbol int) bool

	IsValidForParser() bool

	GetBacktrack() bool
}

type PrimaryRepairInfo

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

func NewPrimaryRepairInfo

func NewPrimaryRepairInfo() *PrimaryRepairInfo

func NewPrimaryRepairInfoAndClone

func NewPrimaryRepairInfoAndClone(clone *PrimaryRepairInfo) *PrimaryRepairInfo

type PrsStream

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

PrsStream holds an arraylist of tokens "lexed" from the input stream.

func NewPrsStream

func NewPrsStream(iLexStream ILexStream) *PrsStream

func NewPrsStreamExt

func NewPrsStreamExt(dispatch IPrsStream, iLexStream ILexStream) *PrsStream

func (*PrsStream) AddAdjunct

func (my *PrsStream) AddAdjunct(adjunct IToken)

func (*PrsStream) AddToken

func (my *PrsStream) AddToken(token IToken)

func (*PrsStream) AfterEol

func (my *PrsStream) AfterEol(i int) bool

func (*PrsStream) BadToken

func (my *PrsStream) BadToken() int

func (*PrsStream) DumpToken

func (my *PrsStream) DumpToken(i int)

func (*PrsStream) DumpTokens

func (my *PrsStream) DumpTokens()

func (*PrsStream) GetAdjuncts

func (my *PrsStream) GetAdjuncts() *TokenArrayList

func (*PrsStream) GetAdjunctsFromIndex

func (my *PrsStream) GetAdjunctsFromIndex(i int) []IToken

func (*PrsStream) GetColumn

func (my *PrsStream) GetColumn(i int) int

func (*PrsStream) GetColumnOfCharAt

func (my *PrsStream) GetColumnOfCharAt(i int) int

func (*PrsStream) GetColumnOfTokenAt

func (my *PrsStream) GetColumnOfTokenAt(i int) int

func (*PrsStream) GetEndColumn

func (my *PrsStream) GetEndColumn(i int) int

func (*PrsStream) GetEndColumnOfTokenAt

func (my *PrsStream) GetEndColumnOfTokenAt(i int) int

func (*PrsStream) GetEndLine

func (my *PrsStream) GetEndLine(i int) int

func (*PrsStream) GetEndLineNumberOfTokenAt

func (my *PrsStream) GetEndLineNumberOfTokenAt(i int) int

func (*PrsStream) GetEndOffSet

func (my *PrsStream) GetEndOffSet(i int) int

func (*PrsStream) GetFileName

func (my *PrsStream) GetFileName() string

func (*PrsStream) GetFirstErrorToken

func (my *PrsStream) GetFirstErrorToken(i int) int

func (*PrsStream) GetFirstRealToken

func (my *PrsStream) GetFirstRealToken(i int) int

func (*PrsStream) GetFollowingAdjuncts

func (my *PrsStream) GetFollowingAdjuncts(i int) []IToken

func (*PrsStream) GetILexStream

func (my *PrsStream) GetILexStream() ILexStream

func (*PrsStream) GetIToken

func (my *PrsStream) GetIToken(i int) IToken

func (*PrsStream) GetInputChars

func (my *PrsStream) GetInputChars() []rune

func (*PrsStream) GetKind

func (my *PrsStream) GetKind(i int) int

func (*PrsStream) GetLastErrorToken

func (my *PrsStream) GetLastErrorToken(i int) int

func (*PrsStream) GetLastRealToken

func (my *PrsStream) GetLastRealToken(i int) int

func (*PrsStream) GetLexStream

func (my *PrsStream) GetLexStream() ILexStream

func (*PrsStream) GetLine

func (my *PrsStream) GetLine(i int) int

func (*PrsStream) GetLineCount

func (my *PrsStream) GetLineCount() int

func (*PrsStream) GetLineNumberOfCharAt

func (my *PrsStream) GetLineNumberOfCharAt(i int) int

func (*PrsStream) GetLineNumberOfTokenAt

func (my *PrsStream) GetLineNumberOfTokenAt(i int) int

func (*PrsStream) GetLineOffSet

func (my *PrsStream) GetLineOffSet(i int) int

func (*PrsStream) GetMessageHandler

func (my *PrsStream) GetMessageHandler() IMessageHandler

func (*PrsStream) GetName

func (my *PrsStream) GetName(i int) string

func (*PrsStream) GetNext

func (my *PrsStream) GetNext(i int) int

func (*PrsStream) GetPrecedingAdjuncts

func (my *PrsStream) GetPrecedingAdjuncts(i int) []IToken

func (*PrsStream) GetPrevious

func (my *PrsStream) GetPrevious(i int) int

func (*PrsStream) GetSize

func (my *PrsStream) GetSize() int

func (*PrsStream) GetStartOffset

func (my *PrsStream) GetStartOffset(i int) int

func (*PrsStream) GetStreamIndex

func (my *PrsStream) GetStreamIndex() int

func (*PrsStream) GetStreamLength

func (my *PrsStream) GetStreamLength() int

func (*PrsStream) GetToken

func (my *PrsStream) GetToken() int

func (*PrsStream) GetTokenAt

func (my *PrsStream) GetTokenAt(i int) IToken

func (*PrsStream) GetTokenAtCharacter

func (my *PrsStream) GetTokenAtCharacter(offSet int) IToken

func (*PrsStream) GetTokenFromEndToken

func (my *PrsStream) GetTokenFromEndToken(end_token int) int

func (*PrsStream) GetTokenIndexAtCharacter

func (my *PrsStream) GetTokenIndexAtCharacter(offSet int) int

func (*PrsStream) GetTokenLength

func (my *PrsStream) GetTokenLength(i int) int

func (*PrsStream) GetTokenText

func (my *PrsStream) GetTokenText(i int) string

func (*PrsStream) GetTokens

func (my *PrsStream) GetTokens() *TokenArrayList

func (*PrsStream) MakeAdjunct

func (my *PrsStream) MakeAdjunct(startLoc int, endLoc int, kind int)

func (*PrsStream) MakeErrorToken

func (my *PrsStream) MakeErrorToken(firsttok int, lasttok int, errortok int, kind int) int

func (*PrsStream) MakeToken

func (my *PrsStream) MakeToken(startLoc int, endLoc int, kind int)

func (*PrsStream) MapKind

func (my *PrsStream) MapKind(kind int) int

func (*PrsStream) OrderedExportedSymbols

func (my *PrsStream) OrderedExportedSymbols() []string

func (*PrsStream) OrderedTerminalSymbols

func (my *PrsStream) OrderedTerminalSymbols() []string

func (*PrsStream) Peek

func (my *PrsStream) Peek() int

func (*PrsStream) RemapTerminalSymbols

func (my *PrsStream) RemapTerminalSymbols(ordered_parser_symbols []string, eof_symbol int) error

func (*PrsStream) RemoveLastToken

func (my *PrsStream) RemoveLastToken()

func (*PrsStream) ReportError

func (my *PrsStream) ReportError(errorCode int, leftToken int, rightToken int, errorInfo []string, errorToken int)

func (*PrsStream) Reset

func (my *PrsStream) Reset()

func (*PrsStream) ResetLexStream

func (my *PrsStream) ResetLexStream(lexStream ILexStream)

func (*PrsStream) ResetStreamLength

func (my *PrsStream) ResetStreamLength()

func (*PrsStream) ResetTo

func (my *PrsStream) ResetTo(i int)

func (*PrsStream) ResetTokenStream

func (my *PrsStream) ResetTokenStream()

func (*PrsStream) SetLexStream

func (my *PrsStream) SetLexStream(lexStream ILexStream)

func (*PrsStream) SetMessageHandler

func (my *PrsStream) SetMessageHandler(errMsg IMessageHandler)

Here is where we report errors. The default method is simply to fmt.Printf the error message to the console. However, the user may supply an error message handler to process error messages. To support that a message handler interface is provided that has a single method HandleMessage(). The user has his error message handler class implement the IMessageHandler interface and provides an object of my type to the runtime using the SetMessageHandler(errorMsg) method. If the message handler object is Set, the ReportError methods will invoke its HandleMessage() method.

IMessageHandler errMsg = null // the error message handler object is declared in LexStream

func (*PrsStream) SetSize

func (my *PrsStream) SetSize()

func (*PrsStream) SetStreamIndex

func (my *PrsStream) SetStreamIndex(index int)

func (*PrsStream) SetStreamLength

func (my *PrsStream) SetStreamLength(len int)

func (*PrsStream) ToString

func (my *PrsStream) ToString(t1 IToken, t2 IToken) string

func (*PrsStream) ToStringFromIndex

func (my *PrsStream) ToStringFromIndex(first_token int, last_token int) string

type RecoveryParser

type RecoveryParser struct {
	*DiagnoseParser
	// contains filtered or unexported fields
}

func NewRecoveryParser

func NewRecoveryParser(parser *BacktrackingParser, action *IntSegmentedTuple, tokens *IntTuple, tokStream IPrsStream,
	prs ParseTable, maxErrors int, maxTime int, monitor Monitor) *RecoveryParser

NewRecoveryParser maxErrors is the maximum int of errors to be repaired maxTime is the maximum amount of time allowed for diagnosing but at least one error must be diagnosed

func (*RecoveryParser) AcceptRecovery

func (my *RecoveryParser) AcceptRecovery(error_token int)

func (*RecoveryParser) CompleteScope

func (my *RecoveryParser) CompleteScope(action *IntSegmentedTuple, scope_rhs_index int) bool

func (*RecoveryParser) FixError

func (my *RecoveryParser) FixError(start_token int, error_token int) bool

Given the configuration consisting of the states in stateStack and the sequence of tokens (current_kind, followed by the tokens in tokStream), FixError parses up to error_token in the tokStream recovers, if possible, from that error and returns the result. While doing my, it also computes the location_stack information and the sequence of actions that matches up with the result that it returns.

func (*RecoveryParser) ReallocateStacks

func (my *RecoveryParser) ReallocateStacks()

func (*RecoveryParser) Recover

func (my *RecoveryParser) Recover(marker_token int, error_token int) (int, error)

func (*RecoveryParser) ReportError

func (my *RecoveryParser) ReportError(scope_index int, error_token int)

type RepairCandidate

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

func NewRepairCandidate

func NewRepairCandidate() *RepairCandidate

type RuleAction

type RuleAction interface {
	RuleAction(ruleNumber int)
}

type SecondaryRepairInfo

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

func NewSecondaryRepairInfo

func NewSecondaryRepairInfo() *SecondaryRepairInfo

type Stacks

type Stacks struct {
	STACK_INCREMENT int
	// contains filtered or unexported fields
}

func NewStacks

func NewStacks() *Stacks

func (*Stacks) AllocateOtherStacks

func (a *Stacks) AllocateOtherStacks()

Allocate location and parse stacks using the size of the state stack.

func (*Stacks) GetSym

func (a *Stacks) GetSym(i int) interface{}

Given a rule of the form A ::= x1 x2 ... xn n > 0

The function GETSYM(i): yields the AST subtree associated with symbol xi. NOTE that if xi is a terminal, GETSYM(i): is nil ! (However, see token_action below.):

SetSYM1(Object ast): is a function that allows us to assign an AST tree to GETSYM(1).

func (*Stacks) GetToken

func (a *Stacks) GetToken(i int) int

Given a rule of the form A ::= x1 x2 ... xn n > 0

the function GETTOKEN(i): yields the symbol xi, if xi is a terminal or ti, if xi is a nonterminal that produced a string of the form xi => ti w.

func (*Stacks) ReallocateStacks

func (a *Stacks) ReallocateStacks()

Allocate or reallocate all the stacks. Their sizes should always be the same.

func (*Stacks) ReallocateStateStack

func (a *Stacks) ReallocateStateStack()

Allocate or reallocate the state stack only.

func (*Stacks) SetSym1

func (a *Stacks) SetSym1(ast interface{})

type StateElement

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

func NewStateElement

func NewStateElement() *StateElement

type StateInfo

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

func NewStateInfo

func NewStateInfo(state int, next int) *StateInfo

func StateInfoArraycopy

func StateInfoArraycopy(src []*StateInfo, srcPos int,
	dest []*StateInfo, destPos int, length int) []*StateInfo

type Token

type Token struct {
	*AbstractToken
}

func NewToken

func NewToken(startOffSet int, endOffSet int, kind int, iPrsStream IPrsStream) *Token

func (*Token) GetFollowingAdjuncts

func (a *Token) GetFollowingAdjuncts() []IToken

func (*Token) GetPrecedingAdjuncts

func (a *Token) GetPrecedingAdjuncts() []IToken

type TokenArrayList

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

func NewTokenArrayList

func NewTokenArrayList() *TokenArrayList

func NewTokenArrayListFrom

func NewTokenArrayListFrom(array []IToken) *TokenArrayList

func NewTokenArrayListFromCopy

func NewTokenArrayListFromCopy(array []IToken) *TokenArrayList

func NewTokenArrayListSize

func NewTokenArrayListSize(size int, cap int) *TokenArrayList

func (*TokenArrayList) Add

func (a *TokenArrayList) Add(elem IToken) *TokenArrayList

func (*TokenArrayList) At

func (a *TokenArrayList) At(index int) (value IToken)

func (*TokenArrayList) Clear

func (a *TokenArrayList) Clear() bool

func (*TokenArrayList) Clone

func (a *TokenArrayList) Clone() *TokenArrayList

func (*TokenArrayList) Contains

func (a *TokenArrayList) Contains(val IToken) bool

func (*TokenArrayList) Get

func (a *TokenArrayList) Get(index int) IToken

func (*TokenArrayList) IndexOf

func (a *TokenArrayList) IndexOf(elem IToken) int

func (*TokenArrayList) IsEmpty

func (a *TokenArrayList) IsEmpty() bool

func (*TokenArrayList) LastIndexOf

func (a *TokenArrayList) LastIndexOf(elem IToken) int

func (*TokenArrayList) Remove

func (a *TokenArrayList) Remove(value IToken) bool

func (*TokenArrayList) RemoveAll

func (a *TokenArrayList) RemoveAll() bool

func (*TokenArrayList) RemoveAt

func (a *TokenArrayList) RemoveAt(index int) (value IToken, found bool)

func (*TokenArrayList) Search

func (a *TokenArrayList) Search(value IToken) int

func (*TokenArrayList) Set

func (a *TokenArrayList) Set(index int, element IToken) bool

func (*TokenArrayList) Size

func (a *TokenArrayList) Size() int

func (*TokenArrayList) ToArray

func (a *TokenArrayList) ToArray() []IToken

type TokenStream

type TokenStream interface {
	GetTokenFromEndToken(end_token int) int

	GetToken() int

	GetKind(i int) int

	GetNext(i int) int

	GetPrevious(i int) int

	GetName(i int) string

	Peek() int
	Reset()
	ResetTo(i int)

	BadToken() int

	GetLine(i int) int

	GetColumn(i int) int

	GetEndLine(i int) int

	GetEndColumn(i int) int

	AfterEol(i int) bool

	GetFileName() string

	GetStreamLength() int

	GetFirstRealToken(i int) int

	GetLastRealToken(i int) int

	ReportError(errorCode int, leftToken int, rightToken int, errorInfo []string, errorToken int)
}

type TokenStreamNotIPrsStreamException

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

func NewTokenStreamNotIPrsStreamException

func NewTokenStreamNotIPrsStreamException(info string) *TokenStreamNotIPrsStreamException

func (*TokenStreamNotIPrsStreamException) Error

Error implements the interface of Error, it returns all the error as string.

func (*TokenStreamNotIPrsStreamException) ToString

type UnavailableParserInformationException

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

func NewUnavailableParserInformationException

func NewUnavailableParserInformationException(info string) *UnavailableParserInformationException

func (*UnavailableParserInformationException) Error

Error implements the interface of Error, it returns all the error as string.

func (*UnavailableParserInformationException) ToString

type UndefinedEofSymbolException

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

func NewUndefinedEofSymbolException

func NewUndefinedEofSymbolException(info string) *UndefinedEofSymbolException

func (*UndefinedEofSymbolException) Error

Error implements the interface of Error, it returns all the error as string.

func (*UndefinedEofSymbolException) ToString

func (a *UndefinedEofSymbolException) ToString() string

type UnimplementedTerminalsException

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

func NewUnimplementedTerminalsException

func NewUnimplementedTerminalsException(symbols *IntArrayList) *UnimplementedTerminalsException

func (*UnimplementedTerminalsException) Error

Error implements the interface of Error, it returns all the error as string.

func (*UnimplementedTerminalsException) GetSymbols

func (*UnimplementedTerminalsException) ToString

type UnknownStreamType

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

func NewUnknownStreamType

func NewUnknownStreamType(info string) *UnknownStreamType

func (*UnknownStreamType) Error

func (a *UnknownStreamType) Error() string

Error implements the interface of Error, it returns all the error as string.

func (*UnknownStreamType) ToString

func (a *UnknownStreamType) ToString() string

Jump to

Keyboard shortcuts

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