Documentation
¶
Index ¶
- Constants
- Variables
- func CallFunc(calleeNode Node, state *State, arguments interface{}, must bool) (interface{}, error)
- func Check(node Node) error
- func Eval(node Node, state *State) (result interface{}, err error)
- func ExtValOf(v interface{}, state *State) interface{}
- func MustEval(node Node, state *State) interface{}
- func ToReflectVal(v interface{}) reflect.Value
- func Traverse(v interface{}, fn func(interface{}) (TraversalAction, error), ...) (terror error)
- func UnwrapReflectVal(v interface{}) interface{}
- func ValOf(v interface{}) interface{}
- func Walk(node Node, fn func(Node) error) error
- type AbsolutePathExpression
- type AbsolutePathLiteral
- type AbsolutePathPatternLiteral
- type Assignment
- type BinaryExpression
- type BinaryOperator
- type Block
- type BooleanLiteral
- type Call
- type Case
- type Context
- type EmbeddedModule
- type ExternalValue
- type FilesystemPermission
- type FloatLiteral
- type ForStatement
- type Func
- type FunctionDeclaration
- type FunctionExpression
- type FunctionParameter
- type GlobalConstantDeclarations
- type GlobalVarPermission
- type GlobalVariable
- type HTTPHost
- type HTTPHostLiteral
- type HTTPHostPattern
- type HTTPHostPatternLiteral
- type HttpPermission
- type Identifier
- type IdentifierLiteral
- type IdentifierMemberExpression
- type IfStatement
- type ImportStatement
- type IndexExpression
- type IntLiteral
- type IntRange
- type IntRangeIterator
- type Iterable
- type Iterator
- type JSONstring
- type KeyList
- type KeyListExpression
- type LazyExpression
- type LineCount
- type List
- type ListLiteral
- type MatchStatement
- type Matcher
- type MemberExpression
- type Module
- type MultiAssignment
- type NilLiteral
- type Node
- type NodeBase
- type NodeSpan
- type NotAllowedError
- type Object
- type ObjectLiteral
- type ObjectProperty
- type ParsingError
- type Path
- type PathPattern
- type PathSlice
- type Permission
- type PermissionKind
- type QuantityLiteral
- type QuantityRange
- type RelativePathExpression
- type RelativePathLiteral
- type RelativePathPatternLiteral
- type Requirements
- type ReturnStatement
- type Routine
- type RoutineGroup
- type RoutinePermission
- type SliceExpression
- type SpawnExpression
- type StackPermission
- type State
- type Statement
- type StringLiteral
- type SwitchStatement
- type TraversalAction
- type TraversalConfiguration
- type TraversalOrder
- type URL
- type URLExpression
- type URLLiteral
- type URLPattern
- type URLPatternLiteral
- type UpperBoundRangeExpression
- type Variable
Constants ¶
View Source
const DEFAULT_MAX_STACK_HEIGHT = 5
View Source
const GOPHERSCRIPT_MIMETYPE = "application/gopherscript"
View Source
const HTTP_URL_PATTERN = "^https?:\\/\\/(localhost|(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,32}\\.[a-zA-Z0-9]{1,6})\\b([-a-zA-Z0-9@:%_+.~#?&//=]{0,100})$"
View Source
const IMPLICIT_KEY_LEN_KEY = "__len"
View Source
const LOOSE_HTTP_EXPR_PATTERN = "^https?:\\/\\/(localhost|(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,32}\\.[a-zA-Z0-9]{1,6})\\b([-a-zA-Z0-9@:%_+.~#?&//=$]{0,100})$"
View Source
const LOOSE_HTTP_HOST_PATTERN_PATTERN = "^https?:\\/\\/(\\*|(www\\.)?[-a-zA-Z0-9.*]{1,32}\\.[a-zA-Z0-9*]{1,6})(:[0-9]{1,5})?$"
View Source
const RETURN_1_MODULE_HASH = "SG2a/7YNuwBjsD2OI6bM9jZM4gPcOp9W8g51DrQeyt4="
View Source
const TRULY_MAX_STACK_HEIGHT = 10
Variables ¶
View Source
var BINARY_OPERATOR_STRINGS = []string{
"+", "+.", "-", "-.", "*", "*.", "/", "/.", "++", "<", "<.", "<=", "<=", ">", ">.", ">=", ">=.", "==", "!=",
"in", "keyof", ".", "..", "..<",
}
View Source
var CTX_PTR_TYPE = reflect.TypeOf(&Context{})
View Source
var ERROR_INTERFACE_TYPE = reflect.TypeOf((*error)(nil)).Elem()
View Source
var HTTP_URL_REGEX = regexp.MustCompile(HTTP_URL_PATTERN)
View Source
var ITERABLE_INTERFACE_TYPE = reflect.TypeOf((*Iterable)(nil)).Elem()
View Source
var KEYWORDS = []string{"if", "else", "require", "for", "assign", "fn", "switch", "match", "import", "sr"}
View Source
var LOOSE_HTTP_EXPR_PATTERN_REGEX = regexp.MustCompile(LOOSE_HTTP_EXPR_PATTERN)
View Source
var LOOSE_HTTP_HOST_PATTERN_REGEX = regexp.MustCompile(LOOSE_HTTP_HOST_PATTERN_PATTERN)
View Source
var MODULE_CACHE = map[string]string{ RETURN_1_MODULE_HASH: "return 1", }
View Source
var PERMISSION_KIND_STRINGS = []string{"read", "update", "create", "delete", "use", "consume", "provide"}
Functions ¶
func ToReflectVal ¶
Wraps its argument in a reflect.Value if it is not already wrapped.
func Traverse ¶
func Traverse(v interface{}, fn func(interface{}) (TraversalAction, error), config TraversalConfiguration) (terror error)
Traverse a graph of values starting from v. Only objects & lists are considered source nodes, the other ones are sinks (leafs). A list of encountered source nodes is used to prevent cycling
func UnwrapReflectVal ¶
func UnwrapReflectVal(v interface{}) interface{}
Unwraps the content of a reflect.Value.
Types ¶
type AbsolutePathExpression ¶
type AbsolutePathLiteral ¶
type Assignment ¶
type BinaryExpression ¶
type BinaryExpression struct {
NodeBase
Operator BinaryOperator
Left Node
Right Node
}
type BinaryOperator ¶
type BinaryOperator int
const ( Add BinaryOperator = iota AddF Sub SubF Mul MulF Div DivF Concat LessThan LessThanF LessOrEqual LessOrEqualF GreaterThan GreaterThanF GreaterOrEqual GreaterOrEqualF Equal NotEqual In Keyof Dot //unused, present for symmetry Range ExclEndRange )
func (BinaryOperator) String ¶
func (operator BinaryOperator) String() string
type BooleanLiteral ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(permissions []Permission) *Context
func (*Context) CheckHasPermission ¶
func (ctx *Context) CheckHasPermission(perm Permission) error
func (*Context) HasPermission ¶
func (ctx *Context) HasPermission(perm Permission) bool
type EmbeddedModule ¶
type EmbeddedModule struct {
NodeBase
Requirements *Requirements
Statements []Node
}
type ExternalValue ¶
type ExternalValue struct {
// contains filtered or unexported fields
}
type FilesystemPermission ¶
type FilesystemPermission struct {
Kind_ PermissionKind
Entity interface{}
}
func (FilesystemPermission) Includes ¶
func (perm FilesystemPermission) Includes(otherPerm Permission) bool
func (FilesystemPermission) Kind ¶
func (perm FilesystemPermission) Kind() PermissionKind
func (FilesystemPermission) String ¶
func (perm FilesystemPermission) String() string
type FloatLiteral ¶
type ForStatement ¶
type FunctionDeclaration ¶
type FunctionDeclaration struct {
NodeBase
Function FunctionExpression
Name *IdentifierLiteral
}
type FunctionExpression ¶
type FunctionExpression struct {
NodeBase
Parameters []FunctionParameter
Body *Block
Requirements *Requirements
}
type FunctionParameter ¶
type FunctionParameter struct {
Var *Variable
}
type GlobalVarPermission ¶
type GlobalVarPermission struct {
Kind_ PermissionKind
Name string //"*" means any
}
func (GlobalVarPermission) Includes ¶
func (perm GlobalVarPermission) Includes(otherPerm Permission) bool
func (GlobalVarPermission) Kind ¶
func (perm GlobalVarPermission) Kind() PermissionKind
func (GlobalVarPermission) String ¶
func (perm GlobalVarPermission) String() string
type GlobalVariable ¶
type HTTPHostLiteral ¶
type HTTPHostPattern ¶
type HTTPHostPattern string
func (HTTPHostPattern) IsMatcherFor ¶
func (patt HTTPHostPattern) IsMatcherFor(v interface{}) bool
type HTTPHostPatternLiteral ¶
type HttpPermission ¶
type HttpPermission struct {
Kind_ PermissionKind
Entity interface{}
}
func (HttpPermission) Includes ¶
func (perm HttpPermission) Includes(otherPerm Permission) bool
func (HttpPermission) Kind ¶
func (perm HttpPermission) Kind() PermissionKind
func (HttpPermission) String ¶
func (perm HttpPermission) String() string
type Identifier ¶
type Identifier string
type IdentifierLiteral ¶
type IdentifierMemberExpression ¶
type IdentifierMemberExpression struct {
NodeBase
Left Node
PropertyNames []*IdentifierLiteral
}
type IfStatement ¶
type ImportStatement ¶
type ImportStatement struct {
NodeBase
Identifier *IdentifierLiteral
URL *URLLiteral
ValidationString *StringLiteral
ArgumentObject *ObjectLiteral
GrantedPermissions *ObjectLiteral
}
type IndexExpression ¶
type IntLiteral ¶
type IntRangeIterator ¶
type IntRangeIterator struct {
// contains filtered or unexported fields
}
func (*IntRangeIterator) GetNext ¶
func (it *IntRangeIterator) GetNext() interface{}
func (IntRangeIterator) HasNext ¶
func (it IntRangeIterator) HasNext() bool
type KeyListExpression ¶
type KeyListExpression struct {
NodeBase
Keys []*IdentifierLiteral
}
type LazyExpression ¶
type ListLiteral ¶
type MatchStatement ¶
type MemberExpression ¶
type MemberExpression struct {
NodeBase
Left Node
PropertyName *IdentifierLiteral
}
type Module ¶
type Module struct {
NodeBase
GlobalConstantDeclarations *GlobalConstantDeclarations //nil if no const declarations at the top of the module
Requirements *Requirements //nil if no require at the top of the module
Statements []Node
}
func MustParseModule ¶
type MultiAssignment ¶
type NilLiteral ¶
type NilLiteral struct {
NodeBase
}
type Node ¶
type Node interface {
Base() NodeBase
}
all node types embed NodeBase, NodeBase implements the Node interface
type NotAllowedError ¶
type NotAllowedError struct {
Permission Permission
Message string
}
func (NotAllowedError) Error ¶
func (err NotAllowedError) Error() string
type ObjectLiteral ¶
type ObjectLiteral struct {
NodeBase
Properties []ObjectProperty
}
func (ObjectLiteral) Permissions ¶
func (objLit ObjectLiteral) Permissions(globalConsts *GlobalConstantDeclarations, runningState *State) []Permission
type ObjectProperty ¶
func (ObjectProperty) Name ¶
func (prop ObjectProperty) Name() string
type ParsingError ¶
func (ParsingError) Error ¶
func (err ParsingError) Error() string
type PathPattern ¶
type PathPattern string
func (PathPattern) IsMatcherFor ¶
func (patt PathPattern) IsMatcherFor(v interface{}) bool
func (PathPattern) IsPrefixPattern ¶
func (patt PathPattern) IsPrefixPattern() bool
func (PathPattern) Prefix ¶
func (patt PathPattern) Prefix() string
func (PathPattern) ToAbs ¶
func (patt PathPattern) ToAbs() PathPattern
type Permission ¶
type Permission interface {
Kind() PermissionKind
Includes(Permission) bool
String() string
}
type PermissionKind ¶
type PermissionKind int
const ( ReadPerm PermissionKind = iota UpdatePerm CreatePerm DeletePerm UsePerm ConsumePerm ProvidePerm )
func PermissionKindFromString ¶
func PermissionKindFromString(s string) (PermissionKind, bool)
func (PermissionKind) String ¶
func (kind PermissionKind) String() string
type QuantityLiteral ¶
type QuantityRange ¶
type QuantityRange struct {
Start interface{}
End interface{}
// contains filtered or unexported fields
}
type RelativePathExpression ¶
type RelativePathLiteral ¶
type Requirements ¶
type Requirements struct {
Object *ObjectLiteral
}
type ReturnStatement ¶
type Routine ¶
type Routine struct {
// contains filtered or unexported fields
}
func (*Routine) WaitResult ¶
type RoutineGroup ¶
type RoutineGroup struct {
// contains filtered or unexported fields
}
func (*RoutineGroup) WaitAllResults ¶
func (group *RoutineGroup) WaitAllResults(ctx *Context) (interface{}, error)
type RoutinePermission ¶
type RoutinePermission struct {
Kind_ PermissionKind
}
func (RoutinePermission) Includes ¶
func (perm RoutinePermission) Includes(otherPerm Permission) bool
func (RoutinePermission) Kind ¶
func (perm RoutinePermission) Kind() PermissionKind
func (RoutinePermission) String ¶
func (perm RoutinePermission) String() string
type SliceExpression ¶
type SpawnExpression ¶
type SpawnExpression struct {
NodeBase
GroupIdent *IdentifierLiteral //can be nil
Globals Node
ExprOrVar Node
GrantedPermissions *ObjectLiteral //nil if no "allow ...." in the spawn expression
}
type StackPermission ¶
type StackPermission struct {
// contains filtered or unexported fields
}
func (StackPermission) Includes ¶
func (perm StackPermission) Includes(otherPerm Permission) bool
func (StackPermission) Kind ¶
func (perm StackPermission) Kind() PermissionKind
func (StackPermission) String ¶
func (perm StackPermission) String() string
type State ¶
type State struct {
ScopeStack []map[string]interface{}
ReturnValue *interface{}
// contains filtered or unexported fields
}
func (State) CurrentScope ¶
func (State) GlobalScope ¶
type StringLiteral ¶
type SwitchStatement ¶
type TraversalAction ¶
type TraversalAction int
const ( Continue TraversalAction = iota Prune StopTraversal )
type TraversalConfiguration ¶
type TraversalConfiguration struct {
MaxDepth int
}
type TraversalOrder ¶
type TraversalOrder int
type URLExpression ¶
type URLExpression struct {
NodeBase
Raw string
HostPart string
Path *AbsolutePathExpression
}
type URLLiteral ¶
type URLPattern ¶
type URLPattern string
func (URLPattern) IsMatcherFor ¶
func (patt URLPattern) IsMatcherFor(v interface{}) bool
func (URLPattern) Prefix ¶
func (patt URLPattern) Prefix() string
type URLPatternLiteral ¶
Click to show internal directories.
Click to hide internal directories.



