parser

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LOWEST int = iota + 1
	OR
	AND
	REGEX
	EQUALS
	LESS_GREATER
	CONCAT
	PREFIX
	POSTFIX
	CALL
)

Reference: https://developer.fastly.com/reference/vcl/operators/

Variables

View Source
var NULLbyte = errors.New("NULL")

Sentinel error for indicating the presence of a NULL byte or zero code point in an escape.

Functions

func SwapLeadingInfix added in v1.7.0

func SwapLeadingInfix(from, to *ast.Meta)

func SwapLeadingTrailing added in v1.7.0

func SwapLeadingTrailing(from, to *ast.Meta)

Comment control helper

Types

type CustomParser added in v1.7.0

type CustomParser interface {
	Literal() string
	Parse(*Parser) (ast.CustomStatement, error)
}

type ParseError

type ParseError struct {
	Token   token.Token
	Message string
}

func DuplicateCase added in v1.4.0

func DuplicateCase(m *ast.Meta) *ParseError

func EmptySwitch added in v1.4.0

func EmptySwitch(m *ast.Meta) *ParseError

func FinalFallthrough added in v1.4.0

func FinalFallthrough(m *ast.Meta) *ParseError

func InvalidEscape added in v1.5.0

func InvalidEscape(m *ast.Meta, msg string) *ParseError

func MissingColon added in v1.4.0

func MissingColon(m *ast.Meta) *ParseError

func MissingSemicolon

func MissingSemicolon(m *ast.Meta) *ParseError

func MultipleDefaults added in v1.4.0

func MultipleDefaults(m *ast.Meta) *ParseError

func TypeConversionError

func TypeConversionError(m *ast.Meta, tt string) *ParseError

func UndefinedPrefix

func UndefinedPrefix(m *ast.Meta) *ParseError

func UnexpectedToken

func UnexpectedToken(m *ast.Meta, expects ...string) *ParseError

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) ErrorToken

func (e *ParseError) ErrorToken() token.Token

type Parser

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

func New

func New(l *lexer.Lexer, opts ...ParserOption) *Parser

func (*Parser) CurToken added in v1.7.0

func (p *Parser) CurToken() *ast.Meta

func (*Parser) CurTokenIs added in v1.7.0

func (p *Parser) CurTokenIs(t token.TokenType) bool

func (*Parser) ExpectPeek added in v1.7.0

func (p *Parser) ExpectPeek(t token.TokenType) bool

func (*Parser) NextToken added in v1.7.0

func (p *Parser) NextToken()

func (*Parser) Parse added in v1.7.0

func (p *Parser) Parse() (ast.Statement, error)

func (*Parser) ParseAclCidr added in v1.7.0

func (p *Parser) ParseAclCidr() (*ast.AclCidr, error)

func (*Parser) ParseAclDeclaration added in v1.7.0

func (p *Parser) ParseAclDeclaration() (*ast.AclDeclaration, error)

func (*Parser) ParseAddStatement added in v1.7.0

func (p *Parser) ParseAddStatement() (*ast.AddStatement, error)

func (*Parser) ParseAnotherIfStatement added in v1.7.0

func (p *Parser) ParseAnotherIfStatement(keyword string) (*ast.IfStatement, error)

AnotherIfStatement is similar to IfStatement but is not culious about alternative.

func (*Parser) ParseBackendDeclaration added in v1.7.0

func (p *Parser) ParseBackendDeclaration() (*ast.BackendDeclaration, error)

func (*Parser) ParseBackendProperty added in v1.7.0

func (p *Parser) ParseBackendProperty() (*ast.BackendProperty, error)

func (*Parser) ParseBlockStatement added in v1.7.0

func (p *Parser) ParseBlockStatement() (*ast.BlockStatement, error)

func (*Parser) ParseBoolean added in v1.7.0

func (p *Parser) ParseBoolean() *ast.Boolean

nolint: unparam

func (*Parser) ParseBreakStatement added in v1.7.0

func (p *Parser) ParseBreakStatement() (*ast.BreakStatement, error)

func (*Parser) ParseCallStatement added in v1.7.0

func (p *Parser) ParseCallStatement() (*ast.CallStatement, error)

func (*Parser) ParseCaseStatement added in v1.7.0

func (p *Parser) ParseCaseStatement() (*ast.CaseStatement, error)

func (*Parser) ParseCustomToken added in v1.7.0

func (p *Parser) ParseCustomToken() (ast.CustomStatement, error)

func (*Parser) ParseDeclareStatement added in v1.7.0

func (p *Parser) ParseDeclareStatement() (*ast.DeclareStatement, error)

func (*Parser) ParseDirectorBackend added in v1.7.0

func (p *Parser) ParseDirectorBackend() (ast.Expression, error)

func (*Parser) ParseDirectorDeclaration added in v1.7.0

func (p *Parser) ParseDirectorDeclaration() (*ast.DirectorDeclaration, error)

func (*Parser) ParseDirectorProperty added in v1.7.0

func (p *Parser) ParseDirectorProperty() (ast.Expression, error)

func (*Parser) ParseErrorStatement added in v1.7.0

func (p *Parser) ParseErrorStatement() (*ast.ErrorStatement, error)

func (*Parser) ParseEsiStatement added in v1.7.0

func (p *Parser) ParseEsiStatement() (*ast.EsiStatement, error)

func (*Parser) ParseExpression added in v1.0.0

func (p *Parser) ParseExpression(precedence int) (ast.Expression, error)

func (*Parser) ParseFallthroughStatement added in v1.7.0

func (p *Parser) ParseFallthroughStatement() (*ast.FallthroughStatement, error)

func (*Parser) ParseFloat added in v1.7.0

func (p *Parser) ParseFloat() (*ast.Float, error)

func (*Parser) ParseFunctionArgumentExpressions added in v1.7.0

func (p *Parser) ParseFunctionArgumentExpressions() ([]ast.Expression, error)

func (*Parser) ParseFunctionCall added in v1.7.0

func (p *Parser) ParseFunctionCall() (*ast.FunctionCallStatement, error)

func (*Parser) ParseFunctionCallExpression added in v1.7.0

func (p *Parser) ParseFunctionCallExpression(fn ast.Expression) (ast.Expression, error)

func (*Parser) ParseGotoDestination added in v1.7.0

func (p *Parser) ParseGotoDestination() (*ast.GotoDestinationStatement, error)

func (*Parser) ParseGotoStatement added in v1.7.0

func (p *Parser) ParseGotoStatement() (*ast.GotoStatement, error)

func (*Parser) ParseGroupedExpression added in v1.7.0

func (p *Parser) ParseGroupedExpression() (*ast.GroupedExpression, error)

func (*Parser) ParseIP added in v1.7.0

func (p *Parser) ParseIP() *ast.IP

func (*Parser) ParseIdent added in v1.7.0

func (p *Parser) ParseIdent() *ast.Ident

func (*Parser) ParseIfExpression added in v1.7.0

func (p *Parser) ParseIfExpression() (*ast.IfExpression, error)

func (*Parser) ParseIfStatement added in v1.7.0

func (p *Parser) ParseIfStatement() (*ast.IfStatement, error)

func (*Parser) ParseImportStatement added in v1.7.0

func (p *Parser) ParseImportStatement() (*ast.ImportStatement, error)

func (*Parser) ParseIncludeStatement added in v1.7.0

func (p *Parser) ParseIncludeStatement() (ast.Statement, error)

func (*Parser) ParseInfixExpression added in v1.7.0

func (p *Parser) ParseInfixExpression(left ast.Expression) (ast.Expression, error)

func (*Parser) ParseInfixStringConcatExpression added in v1.7.0

func (p *Parser) ParseInfixStringConcatExpression(left ast.Expression) (ast.Expression, error)

func (*Parser) ParseInteger added in v1.7.0

func (p *Parser) ParseInteger() (*ast.Integer, error)

func (*Parser) ParseLogStatement added in v1.7.0

func (p *Parser) ParseLogStatement() (*ast.LogStatement, error)

func (*Parser) ParsePenaltyboxDeclaration added in v1.7.0

func (p *Parser) ParsePenaltyboxDeclaration() (*ast.PenaltyboxDeclaration, error)

func (*Parser) ParsePostfixExpression added in v1.7.0

func (p *Parser) ParsePostfixExpression(left ast.Expression) (ast.Expression, error)

func (*Parser) ParsePrefixExpression added in v1.7.0

func (p *Parser) ParsePrefixExpression() (*ast.PrefixExpression, error)

func (*Parser) ParseRTime added in v1.7.0

func (p *Parser) ParseRTime() (*ast.RTime, error)

func (*Parser) ParseRatecounterDeclaration added in v1.7.0

func (p *Parser) ParseRatecounterDeclaration() (*ast.RatecounterDeclaration, error)

func (*Parser) ParseRemoveStatement added in v1.7.0

func (p *Parser) ParseRemoveStatement() (*ast.RemoveStatement, error)

func (*Parser) ParseRestartStatement added in v1.7.0

func (p *Parser) ParseRestartStatement() (*ast.RestartStatement, error)

func (*Parser) ParseReturnStatement added in v1.7.0

func (p *Parser) ParseReturnStatement() (*ast.ReturnStatement, error)

func (*Parser) ParseSetStatement added in v1.7.0

func (p *Parser) ParseSetStatement() (*ast.SetStatement, error)

func (*Parser) ParseSnippetVCL added in v0.9.3

func (p *Parser) ParseSnippetVCL() ([]ast.Statement, error)

ParseSnippetVCL is used for snippet parsing. VCL snippet is a piece of vcl code so we should Parse like BlockStatement inside, and returns slice of statement.

func (*Parser) ParseStatement added in v1.7.0

func (p *Parser) ParseStatement() (ast.Statement, error)

func (*Parser) ParseString added in v1.7.0

func (p *Parser) ParseString() (*ast.String, error)

func (*Parser) ParseSubroutineDeclaration added in v1.7.0

func (p *Parser) ParseSubroutineDeclaration() (*ast.SubroutineDeclaration, error)

func (*Parser) ParseSwitchStatement added in v1.7.0

func (p *Parser) ParseSwitchStatement() (*ast.SwitchStatement, error)

func (*Parser) ParseSyntheticBase64Statement added in v1.7.0

func (p *Parser) ParseSyntheticBase64Statement() (*ast.SyntheticBase64Statement, error)

func (*Parser) ParseSyntheticStatement added in v1.7.0

func (p *Parser) ParseSyntheticStatement() (*ast.SyntheticStatement, error)

func (*Parser) ParseTableDeclaration added in v1.7.0

func (p *Parser) ParseTableDeclaration() (*ast.TableDeclaration, error)

func (*Parser) ParseTableProperty added in v1.7.0

func (p *Parser) ParseTableProperty() (*ast.TableProperty, error)

func (*Parser) ParseUnsetStatement added in v1.7.0

func (p *Parser) ParseUnsetStatement() (*ast.UnsetStatement, error)

func (*Parser) ParseVCL

func (p *Parser) ParseVCL() (*ast.VCL, error)

func (*Parser) PeekToken added in v1.7.0

func (p *Parser) PeekToken() *ast.Meta

func (*Parser) PeekTokenIs added in v1.7.0

func (p *Parser) PeekTokenIs(t token.TokenType) bool

func (*Parser) PrevTokenIs added in v1.7.0

func (p *Parser) PrevTokenIs(t token.TokenType) bool

func (*Parser) ReadPeek added in v1.7.0

func (p *Parser) ReadPeek()

func (*Parser) Trailing added in v1.7.0

func (p *Parser) Trailing() ast.Comments

type ParserOption added in v1.7.0

type ParserOption func(p *Parser)

func WithCustomParser added in v1.7.0

func WithCustomParser(cps ...CustomParser) ParserOption

Jump to

Keyboard shortcuts

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