old_parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeywordTransaction = "transaction"
)

Variables

This section is empty.

Functions

func Parse

func Parse[T any](
	memoryGauge common.MemoryGauge,
	input []byte,
	parse func(*parser) (T, error),
	config Config,
) (result T, errors []error)

Parse creates a lexer to scan the given input string, and uses the given `parse` function to parse tokens into a result.

It can be composed with different parse functions to parse the input string into different results. See "ParseExpression", "ParseStatements" as examples.

func ParseArgumentList

func ParseArgumentList(
	memoryGauge common.MemoryGauge,
	input []byte,
	config Config,
) (
	arguments ast.Arguments,
	errs []error,
)

func ParseDeclarations

func ParseDeclarations(
	memoryGauge common.MemoryGauge,
	input []byte,
	config Config,
) (
	declarations []ast.Declaration,
	errs []error,
)

func ParseDocstringPragmaArguments

func ParseDocstringPragmaArguments(docString string) []string

ParseDocstringPragmaArguments parses the docstring and returns the values of all pragma arguments declarations.

A pragma arguments declaration has the form `pragma arguments <argument-list>`, where <argument-list> is a Cadence argument list.

The validity of the argument list is NOT checked by this function.

func ParseDocstringPragmaSigners

func ParseDocstringPragmaSigners(docString string) []string

ParseDocstringPragmaSigners parses the docstring and returns the values of all pragma signers declarations.

A pragma signers declaration has the form `pragma signers <signers-list>`, where <signers-list> is a list of strings.

The validity of the argument list is NOT checked by this function.

func ParseExpression

func ParseExpression(
	memoryGauge common.MemoryGauge,
	input []byte,
	config Config,
) (
	expression ast.Expression,
	errs []error,
)

func ParseProgram

func ParseProgram(memoryGauge common.MemoryGauge, code []byte, config Config) (program *ast.Program, err error)

func ParseProgramFromFile

func ParseProgramFromFile(
	memoryGauge common.MemoryGauge,
	filename string,
	config Config,
) (
	program *ast.Program,
	code []byte,
	err error,
)

func ParseProgramFromTokenStream

func ParseProgramFromTokenStream(
	memoryGauge common.MemoryGauge,
	input lexer.TokenStream,
	config Config,
) (
	program *ast.Program,
	err error,
)

func ParseStatements

func ParseStatements(
	memoryGauge common.MemoryGauge,
	input []byte,
	config Config,
) (
	statements []ast.Statement,
	errs []error,
)

func ParseStatementsFromTokenStream

func ParseStatementsFromTokenStream(
	memoryGauge common.MemoryGauge,
	tokens lexer.TokenStream,
	config Config,
) (
	statements []ast.Statement,
	errs []error,
)

func ParseTokenStream

func ParseTokenStream[T any](
	memoryGauge common.MemoryGauge,
	tokens lexer.TokenStream,
	parse func(*parser) (T, error),
	config Config,
) (
	result T,
	errs []error,
)

func ParseType

func ParseType(memoryGauge common.MemoryGauge, input []byte, config Config) (ty ast.Type, errs []error)

Types

type Config

type Config struct {
	// StaticModifierEnabled determines if the static modifier is enabled
	StaticModifierEnabled bool
	// NativeModifierEnabled determines if the native modifier is enabled
	NativeModifierEnabled bool
	// TypeParametersEnabled determines if type parameters are enabled
	TypeParametersEnabled bool
}

type Error

type Error struct {
	Code   []byte
	Errors []error
}

func (Error) ChildErrors

func (e Error) ChildErrors() []error

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() []error

type ExpressionDepthLimitReachedError

type ExpressionDepthLimitReachedError struct {
	Pos ast.Position
}

ExpressionDepthLimitReachedError is reported when the expression depth limit was reached

func (ExpressionDepthLimitReachedError) EndPosition

func (ExpressionDepthLimitReachedError) Error

func (ExpressionDepthLimitReachedError) IsUserError

func (ExpressionDepthLimitReachedError) IsUserError()

func (ExpressionDepthLimitReachedError) StartPosition

func (e ExpressionDepthLimitReachedError) StartPosition() ast.Position

type InvalidIntegerLiteralError

type InvalidIntegerLiteralError struct {
	Literal                   string
	IntegerLiteralKind        common.IntegerLiteralKind
	InvalidIntegerLiteralKind InvalidNumberLiteralKind
	ast.Range
}

func (*InvalidIntegerLiteralError) Error

func (*InvalidIntegerLiteralError) IsUserError

func (*InvalidIntegerLiteralError) IsUserError()

func (*InvalidIntegerLiteralError) SecondaryError

func (e *InvalidIntegerLiteralError) SecondaryError() string

type InvalidNumberLiteralKind

type InvalidNumberLiteralKind uint
const (
	InvalidNumberLiteralKindUnknown InvalidNumberLiteralKind = iota
	InvalidNumberLiteralKindLeadingUnderscore
	InvalidNumberLiteralKindTrailingUnderscore
	InvalidNumberLiteralKindUnknownPrefix
	InvalidNumberLiteralKindMissingDigits
)

func (InvalidNumberLiteralKind) Description

func (k InvalidNumberLiteralKind) Description() string

func (InvalidNumberLiteralKind) String

func (i InvalidNumberLiteralKind) String() string

type JuxtaposedUnaryOperatorsError

type JuxtaposedUnaryOperatorsError struct {
	Pos ast.Position
}

func (*JuxtaposedUnaryOperatorsError) EndPosition

func (*JuxtaposedUnaryOperatorsError) Error

func (*JuxtaposedUnaryOperatorsError) IsUserError

func (*JuxtaposedUnaryOperatorsError) IsUserError()

func (*JuxtaposedUnaryOperatorsError) StartPosition

func (e *JuxtaposedUnaryOperatorsError) StartPosition() ast.Position

type MissingCommaInParameterListError

type MissingCommaInParameterListError struct {
	Pos ast.Position
}

func (*MissingCommaInParameterListError) EndPosition

func (*MissingCommaInParameterListError) Error

func (*MissingCommaInParameterListError) IsUserError

func (*MissingCommaInParameterListError) IsUserError()

func (*MissingCommaInParameterListError) StartPosition

func (e *MissingCommaInParameterListError) StartPosition() ast.Position

type ParseError

type ParseError interface {
	errors.UserError
	ast.HasPosition
	// contains filtered or unexported methods
}

type SyntaxError

type SyntaxError struct {
	Message string
	Pos     ast.Position
}

func NewSyntaxError

func NewSyntaxError(pos ast.Position, message string, params ...any) *SyntaxError

func NewUnpositionedSyntaxError

func NewUnpositionedSyntaxError(message string, params ...any) *SyntaxError

func (*SyntaxError) EndPosition

func (e *SyntaxError) EndPosition(_ common.MemoryGauge) ast.Position

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

func (*SyntaxError) IsUserError

func (*SyntaxError) IsUserError()

func (*SyntaxError) StartPosition

func (e *SyntaxError) StartPosition() ast.Position

type TypeDepthLimitReachedError

type TypeDepthLimitReachedError struct {
	Pos ast.Position
}

func (TypeDepthLimitReachedError) EndPosition

func (TypeDepthLimitReachedError) Error

func (TypeDepthLimitReachedError) IsUserError

func (TypeDepthLimitReachedError) IsUserError()

func (TypeDepthLimitReachedError) StartPosition

func (e TypeDepthLimitReachedError) StartPosition() ast.Position

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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