(state, lookAhead int)
| 983 | } |
| 984 | |
| 985 | func plpgsqlErrorMessage(state, lookAhead int) string { |
| 986 | const TOKSTART = 4 |
| 987 | |
| 988 | if !plpgsqlErrorVerbose { |
| 989 | return "syntax error" |
| 990 | } |
| 991 | |
| 992 | for _, e := range plpgsqlErrorMessages { |
| 993 | if e.state == state && e.token == lookAhead { |
| 994 | return "syntax error: " + e.msg |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | res := "syntax error: unexpected " + plpgsqlTokname(lookAhead) |
| 999 | |
| 1000 | // To match Bison, suggest at most four expected tokens. |
| 1001 | expected := make([]int, 0, 4) |
| 1002 | |
| 1003 | // Look for shiftable tokens. |
| 1004 | base := int(plpgsqlPact[state]) |
| 1005 | for tok := TOKSTART; tok-1 < len(plpgsqlToknames); tok++ { |
| 1006 | if n := base + tok; n >= 0 && n < plpgsqlLast && int(plpgsqlChk[int(plpgsqlAct[n])]) == tok { |
| 1007 | if len(expected) == cap(expected) { |
| 1008 | return res |
| 1009 | } |
| 1010 | expected = append(expected, tok) |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | if plpgsqlDef[state] == -2 { |
| 1015 | i := 0 |
| 1016 | for plpgsqlExca[i] != -1 || int(plpgsqlExca[i+1]) != state { |
| 1017 | i += 2 |
| 1018 | } |
| 1019 | |
| 1020 | // Look for tokens that we accept or reduce. |
| 1021 | for i += 2; plpgsqlExca[i] >= 0; i += 2 { |
| 1022 | tok := int(plpgsqlExca[i]) |
| 1023 | if tok < TOKSTART || plpgsqlExca[i+1] == 0 { |
| 1024 | continue |
| 1025 | } |
| 1026 | if len(expected) == cap(expected) { |
| 1027 | return res |
| 1028 | } |
| 1029 | expected = append(expected, tok) |
| 1030 | } |
| 1031 | |
| 1032 | // If the default action is to accept or reduce, give up. |
| 1033 | if plpgsqlExca[i+1] != 0 { |
| 1034 | return res |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | for i, tok := range expected { |
| 1039 | if i == 0 { |
| 1040 | res += ", expecting " |
| 1041 | } else { |
| 1042 | res += " or " |
no test coverage detected
searching dependent graphs…