Skip to content

Commit 801d6c2

Browse files
committed
fix if the lua token is the name of the upstream
1 parent 48d8fdd commit 801d6c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lex.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ func tokenize(reader io.Reader, tokenCh chan NgxToken, options LexOptions) {
103103
depth := 0
104104
var la, quote string
105105

106+
// check the lua token is not the directive start
107+
processdLine := make(map[int]bool)
108+
106109
scanner := bufio.NewScanner(reader)
107110
scanner.Split(bufio.ScanRunes)
108111

109112
emit := func(line int, quoted bool, err error) {
110113
tokenCh <- NgxToken{Value: token.String(), Line: line, IsQuoted: quoted, Error: err}
114+
processdLine[line] = true
111115
token.Reset()
112116
lexState = skipSpace
113117
}
@@ -158,7 +162,7 @@ func tokenize(reader io.Reader, tokenCh chan NgxToken, options LexOptions) {
158162

159163
if token.Len() > 0 {
160164
tokenStr := token.String()
161-
if ext, ok := externalLexers[tokenStr]; ok {
165+
if ext, ok := externalLexers[tokenStr]; ok && !processdLine[tokenLine] {
162166
emit(tokenStartLine, false, nil)
163167
externalScanner.tokenLine = tokenLine
164168
extTokenCh := ext.Lex(tokenStr)

0 commit comments

Comments
 (0)