equal
deleted
inserted
replaced
1 package toml |
1 package toml |
2 |
2 |
3 import ( |
3 import ( |
4 "fmt" |
4 "fmt" |
5 "strconv" |
|
6 "unicode" |
5 "unicode" |
7 ) |
6 ) |
8 |
7 |
9 // Define tokens |
8 // Define tokens |
10 type tokenType int |
9 type tokenType int |
33 tokenLeftParen |
32 tokenLeftParen |
34 tokenRightParen |
33 tokenRightParen |
35 tokenDoubleLeftBracket |
34 tokenDoubleLeftBracket |
36 tokenDoubleRightBracket |
35 tokenDoubleRightBracket |
37 tokenDate |
36 tokenDate |
|
37 tokenLocalDate |
38 tokenKeyGroup |
38 tokenKeyGroup |
39 tokenKeyGroupArray |
39 tokenKeyGroupArray |
40 tokenComma |
40 tokenComma |
41 tokenColon |
41 tokenColon |
42 tokenDollar |
42 tokenDollar |
66 "}", |
66 "}", |
67 "(", |
67 "(", |
68 ")", |
68 ")", |
69 "]]", |
69 "]]", |
70 "[[", |
70 "[[", |
71 "Date", |
71 "LocalDate", |
|
72 "LocalDate", |
72 "KeyGroup", |
73 "KeyGroup", |
73 "KeyGroupArray", |
74 "KeyGroupArray", |
74 ",", |
75 ",", |
75 ":", |
76 ":", |
76 "$", |
77 "$", |
91 idx := int(tt) |
92 idx := int(tt) |
92 if idx < len(tokenTypeNames) { |
93 if idx < len(tokenTypeNames) { |
93 return tokenTypeNames[idx] |
94 return tokenTypeNames[idx] |
94 } |
95 } |
95 return "Unknown" |
96 return "Unknown" |
96 } |
|
97 |
|
98 func (t token) Int() int { |
|
99 if result, err := strconv.Atoi(t.val); err != nil { |
|
100 panic(err) |
|
101 } else { |
|
102 return result |
|
103 } |
|
104 } |
97 } |
105 |
98 |
106 func (t token) String() string { |
99 func (t token) String() string { |
107 switch t.typ { |
100 switch t.typ { |
108 case tokenEOF: |
101 case tokenEOF: |