diff options
author | Rob Findley <rfindley@google.com> | 2020-09-11 14:23:34 -0400 |
---|---|---|
committer | Rob Findley <rfindley@google.com> | 2020-09-11 14:23:34 -0400 |
commit | f8b1c17aced24a1618c6984794be9770c5d260be (patch) | |
tree | 45af8d39b5c3d9f43d439ebec0a2ba42b49efe70 /src/text/template/parse/lex.go | |
parent | e5d91ab096a9ff9673311f1a7f3f860a7f9c2062 (diff) | |
parent | 07c1788357cfe6a4ee5f6f6a54d4fe9f579fa844 (diff) | |
download | go-f8b1c17aced24a1618c6984794be9770c5d260be.tar.gz go-f8b1c17aced24a1618c6984794be9770c5d260be.zip |
[dev.types] all: merge master into dev.typesdev.types
Change-Id: Ia6964cb4e09153c15cc9c5b441373d1b3cb8f757
Diffstat (limited to 'src/text/template/parse/lex.go')
-rw-r--r-- | src/text/template/parse/lex.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/text/template/parse/lex.go b/src/text/template/parse/lex.go index 30371f2862..e41373a002 100644 --- a/src/text/template/parse/lex.go +++ b/src/text/template/parse/lex.go @@ -41,6 +41,7 @@ const ( itemBool // boolean constant itemChar // printable ASCII character; grab bag for comma etc. itemCharConstant // character constant + itemComment // comment text itemComplex // complex constant (1+2i); imaginary is just a number itemAssign // equals ('=') introducing an assignment itemDeclare // colon-equals (':=') introducing a declaration @@ -112,6 +113,7 @@ type lexer struct { leftDelim string // start of action rightDelim string // end of action trimRightDelim string // end of action with trim marker + emitComment bool // emit itemComment tokens. pos Pos // current position in the input start Pos // start position of this item width Pos // width of last rune read from input @@ -203,7 +205,7 @@ func (l *lexer) drain() { } // lex creates a new scanner for the input string. -func lex(name, input, left, right string) *lexer { +func lex(name, input, left, right string, emitComment bool) *lexer { if left == "" { left = leftDelim } @@ -216,6 +218,7 @@ func lex(name, input, left, right string) *lexer { leftDelim: left, rightDelim: right, trimRightDelim: rightTrimMarker + right, + emitComment: emitComment, items: make(chan item), line: 1, startLine: 1, @@ -323,6 +326,9 @@ func lexComment(l *lexer) stateFn { if !delim { return l.errorf("comment ends before closing delimiter") } + if l.emitComment { + l.emit(itemComment) + } if trimSpace { l.pos += trimMarkerLen } |