File tree 1 file changed +10
-16
lines changed
1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
351
351
defer close (tokenCh )
352
352
var tok strings.Builder
353
353
var inQuotes bool
354
- var startedText bool
354
+
355
355
356
356
if matchedToken == "set_by_lua_block" {
357
357
arg := ""
@@ -393,10 +393,13 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
393
393
}
394
394
395
395
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
+
397
400
}
398
401
399
- tokenDepth += 1
402
+ tokenDepth ++
400
403
401
404
// TODO: check for opening brace?
402
405
@@ -405,22 +408,16 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
405
408
return // shrug emoji
406
409
}
407
410
411
+ next := ll .s .Text ()
408
412
if err := ll .s .Err (); err != nil {
409
413
lineno := ll .s .Line ()
410
414
tokenCh <- NgxToken {Error : & ParseError {File : & lexerFile , What : err .Error (), Line : & lineno }}
411
415
412
416
}
413
417
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
+
421
419
422
- // As soon as we hit a nonspace, we consider text to have started.
423
- startedText = true
420
+
424
421
425
422
switch {
426
423
case next == "{" && ! inQuotes :
@@ -472,10 +469,7 @@ func (ll *LuaLexer) Lex(matchedToken string) <-chan NgxToken {
472
469
// if tokenDepth == 0 {
473
470
// return
474
471
// }
475
- if tokenDepth == 0 && ! inQuotes {
476
- startedText = false
477
- // leadingWhitespace.Reset()
478
- }
472
+
479
473
}
480
474
}()
481
475
You can’t perform that action at this time.
0 commit comments