diff --git a/parser/parser.go b/parser/parser.go index 6ae25b5..ff2a0fb 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -137,6 +137,14 @@ func (p *Parser) parseStatement() gonginx.IDirective { return d } + for { + if p.curTokenIs(token.Comment) { + p.nextToken() + } else { + break + } + } + //ok, it does not end with a semicolon but a block starts, we will convert that block if we have a converter if p.curTokenIs(token.BlockStart) { d.Block = p.parseBlock() diff --git a/parser/parser_test.go b/parser/parser_test.go index 98a6709..efb7eb4 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -169,6 +169,16 @@ func TestParser_UnendedMultiParams(t *testing.T) { `)).Parse() } +func TestParser_SkipComment(t *testing.T) { + NewParserFromLexer(lex(` +if ($a ~* "")#comment +#comment +{#comment +return 400; +} +`)).Parse() +} + func Benchmark_ParseFullExample(t *testing.B) { fullconf := `user www www; worker_processes 5;