From c7504ddfe8bbdf0a123658ad7e2844fdb0f4da81 Mon Sep 17 00:00:00 2001 From: alpha Date: Mon, 15 Aug 2022 23:19:49 +0000 Subject: [PATCH] 10.1.1 FossilOrigin-Name: c0a4d7dadf87d80ec3d0b6ef67e74d6c49d3ff2efa3179acf0ed90599b476efd --- ruby/lib/lox/parser.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby/lib/lox/parser.rb b/ruby/lib/lox/parser.rb index c6e8e24..1e14e53 100644 --- a/ruby/lib/lox/parser.rb +++ b/ruby/lib/lox/parser.rb @@ -16,6 +16,8 @@ module Lox statements << declaration end statements + rescue ParseError + synchronize! end private @@ -24,8 +26,6 @@ module Lox return var_declaration if match?(:VAR) statement - rescue ParseError - synchronize! end def var_declaration @@ -240,6 +240,8 @@ module Lox args = [] if !check?(:RIGHT_PAREN) loop do + raise ParseError.new(peek, "Can't have more than 255 arguments.") if args.size >= 255 + args << expression break unless match?(:COMMA) end