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

Method parseImportKeyword

parser.go:978–1009  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

976}
977
978func (p *codeParser) parseImportKeyword() *nodeImport {
979 /*
980 examples:
981 TRANS_SYMimport "lib/math" math.Sin
982 TRANS_SYMimport m "lib/math" m.Sin
983 TRANS_SYMimport . "lib/math" Sin
984 */
985 e := new(nodeImport)
986 // we are one token past the 'import' keyword
987 switch p.peek().tok {
988 case token.STRING:
989 e.decl.path = p.peek().lit
990 p.advance()
991 case token.IDENT:
992 e.decl.pkgName = p.peek().lit
993 p.advance()
994 if p.peek().tok != token.STRING {
995 p.errorf("expected string, got %s", p.peek().tok)
996 }
997 e.decl.path = p.peek().lit
998 case token.PERIOD:
999 e.decl.pkgName = "."
1000 p.advance()
1001 if p.peek().tok != token.STRING {
1002 p.errorf("expected string, got %s", p.peek().tok)
1003 }
1004 e.decl.path = p.peek().lit
1005 default:
1006 p.errorf("unexpected token type after "+transSymStr+"import: %s", p.peek().tok)
1007 }
1008 return e
1009}
1010
1011func (p *codeParser) parseExplicitExpression() *nodeGoStrExpr {
1012 // one token past the opening '('

Callers 1

parseCodeMethod · 0.95

Calls 3

peekMethod · 0.95
advanceMethod · 0.95
errorfMethod · 0.95

Tested by

no test coverage detected