MCPcopy Create free account
hub / github.com/adhocteam/pushup / parseStmtBlock

Method parseStmtBlock

parser.go:839–870  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

837}
838
839func (p *codeParser) parseStmtBlock() *nodeBlock {
840 // we are sitting on the opening '{' token here
841 if p.peek().tok != token.LBRACE {
842 p.errorf("expected '{', got '%s'", p.peek().String())
843 }
844 p.advance()
845 var block *nodeBlock
846 switch p.peek().tok {
847 // check for a transition, i.e., stay in code parser
848 case token.XOR:
849 p.advance()
850 code := p.parseCode()
851 if p.peek().tok == token.SEMICOLON {
852 p.advance()
853 }
854 block = &nodeBlock{nodes: []node{code}}
855 case token.EOF:
856 p.errorf("premature end of block in IF statement")
857 default:
858 block = p.transition()
859 }
860 // we should be at the closing '}' token here
861 if p.peek().tok != token.RBRACE {
862 if p.peek().tok == token.LSS {
863 p.errorf("there must be a single HTML element inside a Go code block, try wrapping them in a <text></text> pseudo-element")
864 } else {
865 p.errorf("expected closing '}', got %v", p.peek())
866 }
867 }
868 p.advance()
869 return block
870}
871
872// TODO(paulsmith): extract a common function with parseCodeKeyword
873func (p *codeParser) parseHandlerKeyword() *nodeGoCode {

Callers 4

parseIfStmtMethod · 0.95
parseForStmtMethod · 0.95
parseSectionKeywordMethod · 0.95
parsePartialKeywordMethod · 0.95

Calls 6

peekMethod · 0.95
errorfMethod · 0.95
advanceMethod · 0.95
parseCodeMethod · 0.95
transitionMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected