openCurlyBrace expects the current token to be an opening curly brace. This acts like an assertion because it returns an error if the token is not an opening curly brace. It does NOT advance the token.
()
| 685 | // because it returns an error if the token is not |
| 686 | // an opening curly brace. It does NOT advance the token. |
| 687 | func (p *parser) openCurlyBrace() error { |
| 688 | if p.Val() != "{" { |
| 689 | if p.valLooksLikeGlobalOptionsAfterImportedSnippets() { |
| 690 | return p.Err("global options block must appear before import directives; move the global options block to the top of the Caddyfile") |
| 691 | } |
| 692 | return p.SyntaxErr("{") |
| 693 | } |
| 694 | return nil |
| 695 | } |
| 696 | |
| 697 | func (p *parser) valLooksLikeGlobalOptionsAfterImportedSnippets() bool { |
| 698 | if p.Val() != "import" || len(p.block.Keys) == 0 { |
no test coverage detected