compiler

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const BiggestOverlapGroupAllowedBeforeWarning = 5
View Source
const MaxOverlapGroupErrors = 10

Variables

This section is empty.

Functions

func EvalTagExpr added in v0.5.1

func EvalTagExpr(expr *TagExpr, tags map[string]struct{}, methods map[string]struct{}) bool

func FindNonterminalRoutesWithoutChildren added in v0.7.7

func FindNonterminalRoutesWithoutChildren(routes []CompiledRoute) (withoutChildren []int)

func GetRouteRegexps

func GetRouteRegexps(routes []CompiledRoute, filter *TagExpr) routeRegexps

func GroupRoutes added in v0.7.0

func GroupRoutes(rwps []RouteWithParents) [][]RouteWithParents

func ParseJsonRouteFile added in v0.7.0

func ParseJsonRouteFile(input io.Reader, casePolicy CasePolicy) (entries []RouteFileEntry, errors []RouteError)

func ParseRouteFile

func ParseRouteFile(input io.Reader, casePolicy CasePolicy) ([]RouteFileEntry, []RouteError)

func ProcessRouteFiles added in v0.7.0

func ProcessRouteFiles(files [][]RouteFileEntry, filenames []string, nameSeparator string) ([]CompiledRoute, []RouteError)

func RouteRegexpsToJSON

func RouteRegexpsToJSON(rrs *routeRegexps, filter *TagExpr) ([]byte, int)

Types

type CasePolicy added in v0.4.0

type CasePolicy int
const (
	AllowUpperCase    CasePolicy = iota
	DisallowUpperCase CasePolicy = iota
)

type CompiledRoute added in v0.7.0

type CompiledRoute struct {
	Info     RouteInfo
	Compiled RouteRegexp
}

type InclusionStatus added in v0.5.1

type InclusionStatus int
const (
	Include InclusionStatus = iota
	Exclude InclusionStatus = iota
	Union   InclusionStatus = iota
)

type RouteError

type RouteError struct {
	Kind          RouteErrorKind
	Line          int
	Col           int
	DuplicateName string
	OtherLine     int
	IOError       error
	Filenames     []string
	Group         []RouteWithParents
	JsonError     j.Token
}

func CheckForGroupErrors added in v0.7.0

func CheckForGroupErrors(routes []CompiledRoute) (errors []RouteError)

func ParseRouteFiles

func ParseRouteFiles(inputFiles []string, inputReaders []io.Reader, jsonStart int, casePolicy CasePolicy) ([][]RouteFileEntry, []RouteError)

func (RouteError) Error

func (e RouteError) Error() string

type RouteErrorKind

type RouteErrorKind int
const (
	MissingNameOrRoute RouteErrorKind = iota
	DuplicateRouteName
	RootMustStartWithSlash
	OverlappingRoutes
	MisplacedDot
	RouteContainsBadCodePoint
	QuestionMarkInRoute
	HashInRoute
	WhitespaceInRoute
	IllegalCharInParamName
	IllegalBackslashEscape
	IllegalBackslashEscapeInRouteName
	NontabspaceIndentationCharacter
	BadCharacterInMethodName
	MissingCommaBetweenMethodNames
	TwoCommasInSequenceInMethodNames
	IndentLessThanFirstLine
	OnlyNoTrailingSlash
	NoTrailingSlashAfterSlash
	NoParamAfterParam
	NoTrailingSlashInMiddle
	MultipleSlashesInARow
	UpperCaseCharInRoute
	IOError
	EmptyMethodList
	ExpectedJSONRoutesToBeArray
	ExpectedJSONRouteFileEntryToBeObject
	UnexpectedKeyInJSONRouteFile
	JSONRouteMissingNameField
	JSONRouteMissingPatternField
	InvalidJsonInJSONRouteFile
	UnexpectedTokenInJSONRouteFile
	NoSlashInsideJSONRoutePatternElement
	FirstMemberOfJSONRouteFilePatternElementMustBeString
	BadFirstMemberOfJSONRouteFilePatternElement
	UnexpectedJSONRouteFilePatternElementMember
	JSONRouteFilePatternElementParameterNameMustBeString
	WarningBigGroup = iota | RouteWarning
)
const RouteWarning RouteErrorKind = (1 << 30)

type RouteFileEntry

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

type RouteInfo

type RouteInfo struct {
	Name     string
	Line     int
	Filename string
	Tags     map[string]struct{}
	Depth    int
	Terminal bool
	Methods  map[string]struct{}
}

type RouteRegexp added in v0.7.0

type RouteRegexp struct {
	Elems                 []routeElement
	MatchRegexp           string
	ConstantPortionRegexp func(int) string
	ConstantPortion       string
	ConstishPrefix        string // constant bar allowance of repeated '/', etc.
	ConstishSuffix        string
	NGroups               int
	ParamGroupNumbers     map[string]int
}

type RouteWithParents

type RouteWithParents struct {
	Route   *CompiledRoute
	Parents []*CompiledRoute
}

type TagExpr added in v0.5.1

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

func ParseTagExpr added in v0.5.1

func ParseTagExpr(input string) (expr *TagExpr, err error)

Jump to

Keyboard shortcuts

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