Skip to content

Commit 50eb404

Browse files
committed
1
1 parent 3879d41 commit 50eb404

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

lex.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
351351
defer close(tokenCh)
352352
var tok strings.Builder
353353
var inQuotes bool
354-
var startedText bool
354+
355355

356356
if matchedToken == "set_by_lua_block" {
357357
arg := ""
@@ -393,10 +393,13 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
393393
}
394394

395395
if next := ll.s.Text(); next != "{" {
396-
// TODO: Return error, need { to open blockj
396+
lineno := ll.s.Line()
397+
tokenCh <- NgxToken{Error: &ParseError{File: &lexerFile, What: `unexpected "}"`, Line: &lineno}}
398+
return
399+
397400
}
398401

399-
tokenDepth += 1
402+
tokenDepth ++
400403

401404
// TODO: check for opening brace?
402405

@@ -405,22 +408,16 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
405408
return // shrug emoji
406409
}
407410

411+
next := ll.s.Text()
408412
if err := ll.s.Err(); err != nil {
409413
lineno := ll.s.Line()
410414
tokenCh <- NgxToken{Error: &ParseError{File: &lexerFile, What: err.Error(), Line: &lineno}}
411415

412416
}
413417

414-
next := ll.s.Text()
415-
416-
// Handle leading whitespace
417-
if !startedText && isSpace(next) && tokenDepth == 0 && !inQuotes {
418-
// leadingWhitespace.WriteString(next)
419-
continue
420-
}
418+
421419

422-
// As soon as we hit a nonspace, we consider text to have started.
423-
startedText = true
420+
424421

425422
switch {
426423
case next == "{" && !inQuotes:
@@ -472,10 +469,7 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
472469
// if tokenDepth == 0 {
473470
// return
474471
// }
475-
if tokenDepth == 0 && !inQuotes {
476-
startedText = false
477-
// leadingWhitespace.Reset()
478-
}
472+
479473
}
480474
}()
481475

0 commit comments

Comments
 (0)