1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-26 22:37:08 +00:00
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
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-03-27 22:33:19 +03:00
parent 251eeb6bd0
commit 126c4de29b
8 changed files with 158 additions and 55 deletions

View File

@@ -5,24 +5,15 @@ type TokenType int
type Token struct {
Type TokenType
Literal string
Start int // excluding, useful for user
End int // excluding, useful for user and index
}
func (t Token) StartIndex() int {
if t.Start > 0 {
return t.Start + 1
}
return t.Start
}
func (t Token) EndIndex() int {
return t.End
Start int // including the first char, Literal[index:]
End int // including the last char, Literal[start:end+1)
}
// /about/{fullname:alphabetical}
// /profile/{anySpecialName:string}
// {id:int range(1,5) else 404}
// /admin/{id:int eq(1) else 402}
// /file/{filepath:tail else 405}
// /file/{filepath:file else 405}
const (
EOF = iota // 0
ILLEGAL
@@ -33,7 +24,7 @@ const (
// PARAM_IDENTIFIER // id
COLON // :
// let's take them in parser
// PARAM_TYPE // int, string, alphabetic, tail
// PARAM_TYPE // int, string, alphabetical, file, path or unexpected
// PARAM_FUNC // range
LPAREN // (
RPAREN // )