(canBeStructName *bool)
| 966 | } |
| 967 | |
| 968 | func (p *prattParserWorker) parseIdentOrCall(canBeStructName *bool) ast.Expr { |
| 969 | leadingDot := false |
| 970 | firstTok := p.peekTok |
| 971 | if p.peekTok.kind == tokDot { |
| 972 | p.nextToken() |
| 973 | leadingDot = true |
| 974 | } |
| 975 | idTok := p.nextToken() |
| 976 | if idTok.kind != tokIdent && idTok.kind != tokReservedWord { |
| 977 | if idTok.kind != tokError { |
| 978 | p.reportSyntaxError(idTok, "expected identifier") |
| 979 | } |
| 980 | if canBeStructName != nil { |
| 981 | *canBeStructName = false |
| 982 | } |
| 983 | return p.helper.newExpr(idTok) |
| 984 | } |
| 985 | var isQuoted bool |
| 986 | idText := p.normalizeIdent(idTok, p.enableCallEscapeSyntax, &isQuoted) |
| 987 | if idTok.kind == tokReservedWord { |
| 988 | if _, ok := reservedIds[idText]; ok && !p.isStructCreationAhead() { |
| 989 | p.reportError(idTok, "reserved identifier: %s", idText) |
| 990 | } |
| 991 | } |
| 992 | name := idText |
| 993 | if leadingDot { |
| 994 | name = "." + idText |
| 995 | } |
| 996 | if p.peekTok.kind == tokLeftParen { |
| 997 | lparen := p.nextToken() |
| 998 | callID := p.nextID(lparen) |
| 999 | args := p.parseArguments(tokRightParen) |
| 1000 | if canBeStructName != nil { |
| 1001 | *canBeStructName = false |
| 1002 | } |
| 1003 | return p.globalCallOrMacro(callID, name, args...) |
| 1004 | } |
| 1005 | if canBeStructName != nil { |
| 1006 | *canBeStructName = !isQuoted |
| 1007 | } |
| 1008 | targetTok := idTok |
| 1009 | if leadingDot { |
| 1010 | targetTok = firstTok |
| 1011 | } |
| 1012 | id := p.nextID(targetTok) |
| 1013 | return p.helper.newIdent(id, name) |
| 1014 | } |
| 1015 | |
| 1016 | func (p *prattParserWorker) parseArguments(closeTok tokenKind) []ast.Expr { |
| 1017 | var args []ast.Expr |
no test coverage detected