diff --git a/lib/lrama/parser/token_scanner.rb b/lib/lrama/parser/token_scanner.rb index 1ff67b30..992b5742 100644 --- a/lib/lrama/parser/token_scanner.rb +++ b/lib/lrama/parser/token_scanner.rb @@ -11,7 +11,7 @@ def current_token end def current_type - current_token && current_token.type + current_token&.type end def previous_token @@ -26,9 +26,7 @@ def next def consume(*token_types) if token_types.include?(current_type) - token = current_token - self.next - return token + return self.next end return nil @@ -42,8 +40,7 @@ def consume_multi(*token_types) a = [] while token_types.include?(current_type) - a << current_token - self.next + a << self.next end raise "No token is consumed. #{token_types}" if a.empty?