| 1 | // Copyright 2018 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package parser |
| 16 | |
| 17 | import ( |
| 18 | "github.com/google/cel-go/common" |
| 19 | ) |
| 20 | |
| 21 | // parseErrors is a specialization of Errors. |
| 22 | type parseErrors struct { |
| 23 | errs *common.Errors |
| 24 | } |
| 25 | |
| 26 | // errorCount indicates the number of errors reported. |
| 27 | func (e *parseErrors) errorCount() int { |
| 28 | return len(e.errs.GetErrors()) |
| 29 | } |
| 30 | |
| 31 | func (e *parseErrors) internalError(message string) { |
| 32 | e.errs.ReportErrorAtID(0, common.NoLocation, "%s", message) |
| 33 | } |
| 34 | |
| 35 | func (e *parseErrors) syntaxError(l common.Location, message string) { |
| 36 | e.errs.ReportErrorAtID(0, l, "Syntax error: %s", message) |
| 37 | } |
| 38 | |
| 39 | func (e *parseErrors) reportErrorAtID(id int64, l common.Location, message string, args ...any) { |
| 40 | e.errs.ReportErrorAtID(id, l, message, args...) |
| 41 | } |