Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions parser/internal/pratt_parser_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ void ParserWorker::SynchronizeOnDelimiter() {

int64_t ParserWorker::NextId(int32_t position) {
int64_t id = next_id_++;
if (id > options_.expression_node_limit) {
if (id > options_.expression_node_limit && !node_limit_exceeded_) {
ReportError(position, "expression node limit exceeded");
node_limit_exceeded_ = true;
}
if (position >= 0) {
positions_.insert({id, position});
Expand All @@ -209,9 +210,7 @@ int64_t ParserWorker::NextId(int32_t position) {

int64_t ParserWorker::NextId() { return NextId(-1); }

bool ParserWorker::NodeLimitExceeded() {
return next_id_ > options_.expression_node_limit;
}
bool ParserWorker::NodeLimitExceeded() { return node_limit_exceeded_; }

int64_t ParserWorker::CopyId(int64_t id) {
if (id == 0) {
Expand Down
1 change: 1 addition & 0 deletions parser/internal/pratt_parser_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class ParserWorker {
Token peek_token_;
int recursion_depth_ = 0;
int64_t next_id_ = 1;
bool node_limit_exceeded_ = false;
absl::flat_hash_map<int64_t, int32_t> positions_;
std::vector<cel::ParseIssue>* absl_nullable parse_issues_;
int error_count_ = 0;
Expand Down
Loading