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

Method parseHandlerKeyword

parser.go:873–904  ·  view source on GitHub ↗

TODO(paulsmith): extract a common function with parseCodeKeyword

()

Source from the content-addressed store, hash-verified

871
872// TODO(paulsmith): extract a common function with parseCodeKeyword
873func (p *codeParser) parseHandlerKeyword() *nodeGoCode {
874 result := &nodeGoCode{context: handlerGoCode}
875 // we are one token past the 'handler' keyword
876 if p.peek().tok != token.LBRACE {
877 p.errorf("expected '{', got '%s'", p.peek().tok)
878 }
879 depth := 1
880 p.advance()
881 result.pos.start = p.parser.offset
882 start := p.peek().pos
883loop:
884 for {
885 switch p.peek().tok {
886 case token.LBRACE:
887 depth++
888 case token.RBRACE:
889 depth--
890 if depth == 0 {
891 break loop
892 }
893 }
894 p.advance()
895 }
896 n := (p.file.Offset(p.prev().pos) - p.file.Offset(start)) + len(p.prev().String())
897 if p.peek().tok != token.RBRACE {
898 panic("")
899 }
900 p.advance()
901 result.code = p.sourceFrom(start)[:n]
902 result.pos.end = result.pos.start + n
903 return result
904}
905
906func (p *codeParser) parseSectionKeyword() *nodeSection {
907 // enter function one past the "section" IDENT token

Callers 1

parseCodeMethod · 0.95

Calls 6

peekMethod · 0.95
errorfMethod · 0.95
advanceMethod · 0.95
prevMethod · 0.95
sourceFromMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected