-
Notifications
You must be signed in to change notification settings - Fork 31
/
cast.go
46 lines (38 loc) · 783 Bytes
/
cast.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package tokenizer
import "strings"
func lexPhpPossibleCast(l *Lexer) lexState {
// possible (string) etc
l.next() // "("
l.acceptSpaces()
typ := l.acceptPhpLabel()
l.acceptSpaces()
if l.accept(")") {
switch strings.ToLower(typ) {
case "int", "integer":
l.emit(T_INT_CAST)
return l.base
case "bool", "boolean":
l.emit(T_BOOL_CAST)
return l.base
case "float", "double", "real":
l.emit(T_DOUBLE_CAST)
return l.base
case "string":
l.emit(T_STRING_CAST)
return l.base
case "array":
l.emit(T_ARRAY_CAST)
return l.base
case "object":
l.emit(T_OBJECT_CAST)
return l.base
case "unset":
l.emit(T_UNSET_CAST)
return l.base
}
}
l.reset() // return to initial state
l.next() // "("
l.emit(Rune('('))
return l.base
}