lex creates a new scanner for the input string.
(name, input string, run bool)
| 272 | |
| 273 | // lex creates a new scanner for the input string. |
| 274 | func lex(name, input string, run bool) *lexer { |
| 275 | l := &lexer{ |
| 276 | name: name, |
| 277 | input: input, |
| 278 | items: make(chan item), |
| 279 | leftDelim: defaultLeftDelim, |
| 280 | rightDelim: defaultRightDelim, |
| 281 | leftComment: defaultLeftComment, |
| 282 | rightComment: defaultRightComment, |
| 283 | trimRightDelim: rightTrimMarker + defaultRightDelim, |
| 284 | } |
| 285 | if run { |
| 286 | l.run() |
| 287 | } |
| 288 | return l |
| 289 | } |
| 290 | |
| 291 | // run runs the state machine for the lexer. |
| 292 | func (l *lexer) run() { |