You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
readme.md:
- Update examples, fixing some arguments, and stop using deprecated
methods.
- Add blank lines between successive codeblocks, this is usually what is
expected by markdown parsers.
- Fix a typo in method name.
- Explain that numbers and underscores are not part of keywords by
default.
- Remove some whitespaces at the end of lines.
tokenizer.go
- Add blank lines before "Deprecated:" doc comment to allow go tools to
mark them as deprecated in the docs and in editors.
- Fix the description of DefineStringToken().
-`tokenizer.TokenKeyword` — keyword, any combination of letters, including unicode letters.
123
126
-`tokenizer.TokenInteger` — integer value
124
127
-`tokenizer.TokenFloat` — float/double value
125
128
-`tokenizer.TokenString` — quoted string
126
-
-`tokenizer.TokenStringFragment` — fragment framed (quoted) string
129
+
-`tokenizer.TokenStringFragment` — fragment framed (quoted) string
127
130
128
131
### Unknown token
129
132
@@ -132,6 +135,7 @@ A token marks as `tokenizer.TokenUnknown` if the parser detects an unknown token
132
135
```go
133
136
stream:= parser.ParseString(`one!`)
134
137
```
138
+
135
139
```
136
140
stream: [
137
141
{
@@ -151,6 +155,7 @@ Setting `tokenizer.StopOnUndefinedToken()` stops parser when `tokenizer.TokenUn
151
155
```go
152
156
stream:= parser.ParseString(`one!`)
153
157
```
158
+
154
159
```
155
160
stream: [
156
161
{
@@ -168,11 +173,12 @@ and the length of the original string.
168
173
169
174
Any word that is not a custom token is stored in a single token as `tokenizer.TokenKeyword`.
170
175
171
-
The word can contain unicode characters, numbers (see `tokenizer.AllowNumbersInKeyword()`) and underscore (see `tokenizer.AllowKeywordUnderscore ()`).
176
+
The word can contain unicode characters, and it can be configured to contain other characters, like numbers and underscores (see `tokenizer.AllowKeywordSymbols()`).
172
177
173
178
```go
174
179
stream:= parser.ParseString(`one 二 три`)
175
180
```
181
+
176
182
```
177
183
stream: [
178
184
{
@@ -210,6 +216,7 @@ Any integer is stored as one token with key `tokenizer.TokenInteger`.
210
216
```go
211
217
stream:= parser.ParseString(`223 999`)
212
218
```
219
+
213
220
```
214
221
stream: [
215
222
{
@@ -223,11 +230,11 @@ stream: [
223
230
]
224
231
```
225
232
226
-
To get int64 from the token value use `stream.GetInt()`:
233
+
To get int64 from the token value use `stream.GetInt64()`:
227
234
228
235
```go
229
236
stream:= tokenizer.ParseString("123")
230
-
fmt.Print("Token is %d", stream.CurrentToken().GetInt()) // Token is 123
237
+
fmt.Print("Token is %d", stream.CurrentToken().GetInt64()) // Token is 123
231
238
```
232
239
233
240
### Float number
@@ -241,6 +248,7 @@ Any float number is stored as one token with key `tokenizer.TokenFloat`. Float n
241
248
```go
242
249
stream:= parser.ParseString(`1.3e-8`):
243
250
```
251
+
244
252
```
245
253
stream: [
246
254
{
@@ -250,11 +258,11 @@ stream: [
250
258
]
251
259
```
252
260
253
-
To get float64 from the token value use `token.GetFloat()`:
261
+
To get float64 from the token value use `token.GetFloat64()`:
254
262
255
263
```go
256
264
stream:= parser.ParseString("1.3e2")
257
-
fmt.Print("Token is %d", stream.CurrentToken().GetFloat()) // Token is 130
265
+
fmt.Print("Token is %d", stream.CurrentToken().GetFloat64()) // Token is 130
0 commit comments