iris/_future/ipel/ast/param.go
Gerasimos (Makis) Maropoulos 126c4de29b _future
1. Fix index, including both start and end. So Literal[start:end+1] will
be a valid part.

2. Replace any with string, add file param type

3. Start of making the evaluator, starting with regexp for param types
(these expression can be changed or/and overriden by user later on)


Former-commit-id: ab95265f953dadbf84170b543e1ff8840f9c4a14
2017-03-27 22:33:19 +03:00

45 lines
800 B
Go

package ast
type ParamType uint8
const (
ParamTypeUnExpected ParamType = iota
// /myparam1
ParamTypeString
// /42
ParamTypeInt
// /myparam
ParamTypeAlphabetical
// /main.css
ParamTypeFile
// /myparam1/myparam2
ParamTypePath
)
var paramTypes = map[string]ParamType{
"string": ParamTypeString,
"int": ParamTypeInt,
"alphabetical": ParamTypeAlphabetical,
"file": ParamTypeFile,
"path": ParamTypePath,
// could be named also:
// "tail":
// "wild"
// "wildcard"
}
func LookupParamType(ident string) ParamType {
if typ, ok := paramTypes[ident]; ok {
return typ
}
return ParamTypeUnExpected
}
type ParamStatement struct {
Name string // id
Type ParamType // int
Funcs []ParamFunc // range
ErrorCode int // 404
}