ruby-changes:58554
From: Nobuyoshi <ko1@a...>
Date: Mon, 4 Nov 2019 09:33:28 +0900 (JST)
Subject: [ruby-changes:58554] cbbdb4e5a2 (master): [ruby/racc] Strip trailing whitespaces at the last line of actions
https://git.ruby-lang.org/ruby.git/commit/?id=cbbdb4e5a2 From cbbdb4e5a2eb46750d3c455def99486d23fc625b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 31 Oct 2019 00:54:50 +0900 Subject: [ruby/racc] Strip trailing whitespaces at the last line of actions https://github.com/ruby/racc/commit/a887ebe529 diff --git a/lib/racc/grammarfileparser.rb b/lib/racc/grammarfileparser.rb index ff7c682..3ae539a 100644 --- a/lib/racc/grammarfileparser.rb +++ b/lib/racc/grammarfileparser.rb @@ -450,6 +450,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/lib/racc/grammarfileparser.rb#L450 nest -= 1 if nest == 0 @in_block = nil + buf.sub!(/[ \t\f]+\z/, '') return buf end buf << (pre = ch) diff --git a/test/racc/assets/intp.y b/test/racc/assets/intp.y index 24e547d..39e42af 100644 --- a/test/racc/assets/intp.y +++ b/test/racc/assets/intp.y @@ -27,7 +27,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/intp.y#L27 result.push val[1] } | stmt_list EOL - + stmt : expr | assign | IDENT realprim @@ -38,7 +38,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/intp.y#L38 | if_stmt | while_stmt | defun - + if_stmt : IF stmt THEN EOL stmt_list else_stmt END { result = IfNode.new( @fname, val[0][0], @@ -261,7 +261,7 @@ module Intp https://github.com/ruby/ruby/blob/trunk/test/racc/assets/intp.y#L261 class Core - def initialize + def initialize @ftab = {} @obj = Object.new @stack = [] @@ -318,7 +318,7 @@ module Intp https://github.com/ruby/ruby/blob/trunk/test/racc/assets/intp.y#L318 def lvar?(name) @lvars.key? name end - + def [](key) @lvars[key] end diff --git a/test/racc/assets/mailp.y b/test/racc/assets/mailp.y index da332a3..eb7d4d5 100644 --- a/test/racc/assets/mailp.y +++ b/test/racc/assets/mailp.y @@ -35,7 +35,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L35 @field.domain = mb.domain } ; - + datetime : day DIGIT ATOM DIGIT hour zone # 0 1 2 3 4 5 # day month year @@ -44,11 +44,11 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L44 result = (t + val[4] - val[5]).localtime } ; - + day : /* none */ | ATOM ',' ; - + hour : DIGIT ':' DIGIT { result = (result.to_i * 60 * 60) + (val[2].to_i * 60) @@ -60,16 +60,16 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L60 + val[4].to_i } ; - + zone : ATOM { result = ::TMail.zonestr2i( val[0] ) * 60 } ; - + received : from by via with id for recvdatetime ; - + from : /* none */ | FROM domain { @@ -84,28 +84,28 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L84 @field.from = Address.join( val[1] ) } ; - + by : /* none */ | BY domain { @field.by = Address.join( val[1] ) } ; - + via : /* none */ | VIA ATOM { @field.via = val[1] } ; - + with : /* none */ | WITH ATOM { @field.with.push val[1] } ; - + id : /* none */ | ID msgid { @@ -116,14 +116,14 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L116 @field.msgid = val[1] } ; - + for : /* none */ | FOR addr { @field.for_ = val[1].address } ; - + recvdatetime : /* none */ | ';' datetime @@ -131,7 +131,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L131 @field.date = val[1] } ; - + returnpath: '<' '>' | routeaddr { @@ -173,7 +173,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L173 } # | phrase ':' ';' { result = AddressGroup.new( result ) } ; - + routeaddr : '<' route spec '>' { result = val[2] @@ -184,22 +184,22 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L184 result = val[1] } ; - + route : at_domains ':' ; - + at_domains: '@' domain { result = [ val[1] ] } | at_domains ',' '@' domain { result.push val[3] } ; - + spec : local '@' domain { result = Address.new( val[0], val[2] ) } | local { result = Address.new( result, nil ) } ; - + local : word { result = val } | local '.' word { result.push val[2] } ; - + domain : domword { result = val } | domain '.' domword { result.push val[2] } ; @@ -215,11 +215,11 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L215 result = val.join('') } ; - + phrase : word | phrase word { result << ' ' << val[1] } ; - + word : atom | QUOTED | DIGIT @@ -228,7 +228,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L228 keys : phrase | keys ',' phrase ; - + enc : word { @field.encrypter = val[0] @@ -258,7 +258,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L258 @field.sub = '' } ; - + params : /* none */ | params ';' TOKEN '=' value { @@ -281,7 +281,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L281 @field.disposition = val[0] } ; - + disp_params : /* none */ | disp_params ';' disp_param @@ -293,7 +293,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L293 @field.params[ val[0].downcase ] = val[2] } ; - + atom : ATOM | FROM | BY @@ -302,7 +302,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L302 | ID | FOR ; - + end @@ -382,7 +382,7 @@ module TMail https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mailp.y#L382 @scanner.scan @pass_array end end - + def on_error( tok, val, vstack ) raise ParseError, "\nparse error in '#{@field.name}' header, on token #{val.inspect}" diff --git a/test/racc/assets/mof.y b/test/racc/assets/mof.y index 1adc5ad..da31729 100644 --- a/test/racc/assets/mof.y +++ b/test/racc/assets/mof.y @@ -33,7 +33,7 @@ class MOF::Parser https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L33 octalValue decimalValue hexValue - + rule /* Returns a Hash of filename and MofResult */ @@ -47,7 +47,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L47 result[@name] = @result } ; - + mofProduction : compilerDirective | classDeclaration @@ -66,7 +66,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L66 * compilerDirective * */ - + compilerDirective : "#" PRAGMA INCLUDE pragmaParameters_opt { raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3] @@ -107,7 +107,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L107 * classDeclaration * */ - + classDeclaration : qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";" { qualifiers = val[0] @@ -151,7 +151,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L151 result << val[2] if val[2] } ; - + qualifier : qualifierName qualifierParameter_opt flavor_opt { # Get qualifier decl @@ -242,7 +242,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L242 result = CIM::Property.new(type,val[2],val[0],val[4]) } ; - + referenceDeclaration : qualifierList_opt objectRef referenceName array_opt defaultValue_opt ";" { if val[4] @@ -308,7 +308,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L308 : /* empty */ | parameterList ; - + parameterList : parameter parameters { result = val[1].unshift val[0] } @@ -367,7 +367,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L367 : /* empty */ | defaultValue ; - + defaultValue : "=" initializer { result = val[1] } @@ -416,7 +416,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L416 | string stringValue { result = val[0] + val[1] } ; - + referenceInitializer : objectHandle | aliasIdentifier @@ -465,7 +465,7 @@ rule https://github.com/ruby/ruby/blob/trunk/test/racc/assets/mof.y#L465 * qualifierDeclaration * */ - + qualifierDeclaration /* 0 1 (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/