]> Cypherpunks repositories - gostls13.git/commit
text/template: simplify line tracking in the lexer
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 30 Aug 2018 17:02:41 +0000 (11:02 -0600)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 5 Sep 2018 21:27:04 +0000 (21:27 +0000)
commit98fd66808fafb6496caeb3e848ae277b734f8ed9
tree3b870b5ebe5e48b06ea09ad5af65cec915264d29
parent2524ed19946f10a9b0ecc4bf54f1a23c18faa525
text/template: simplify line tracking in the lexer

First, move the strings.Count logic out of emit, since only itemText
requires that. Use it in those call sites. itemLeftDelim and
itemRightDelim cannot contain newlines, as they're the "{{" and "}}"
tokens.

Secondly, introduce a startLine lexer field so that we don't have to
keep track of it elsewhere. That's also a requirement to move the
strings.Count out of emit, as emit modifies the start position field.

Change-Id: I69175f403487607a8e5b561b3f1916ee9dc3c0c6
Reviewed-on: https://go-review.googlesource.com/132275
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/text/template/parse/lex.go