🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ruby_parser

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ruby_parser - rubygems Package Compare versions

Comparing version
3.6.6
to
3.7.0
lib/ruby_parser.yy

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

+18
-0

@@ -0,1 +1,19 @@

=== 3.7.0 / 2015-05-28
* 2 major enhancements:
* Added preliminary support for ruby 2.2 syntax.
* Now writing all 2.x parsers from one source, generating racc files.
* 1 minor enhancement:
* Added RubyLexer#process_label and hooked it up to "x": and 'x': productions.
* 4 bug fixes:
* Fixed handling of block_args to be consistent across all parse versions.
* Fixed lexing of label assoc args w/ newlines in between k/v. (jeremyf)
* Fixed lexing of x?'':y for ruby22 (not a label). (presidentbeef)
* clear and restore cmdarg stack around def args and body.
=== 3.6.6 / 2015-04-13

@@ -2,0 +20,0 @@

+44
-11

@@ -84,3 +84,2 @@ # encoding: UTF-8

attr_accessor :lex_state
attr_accessor :lex_strterm

@@ -124,6 +123,2 @@ attr_accessor :lpar_beg

def check re
ss.check re
end
def comments # TODO: remove this... maybe comment_string + attr_accessor

@@ -283,2 +278,6 @@ c = @comments.join

def ruby22_label?
ruby22? and is_label_possible?
end
def is_label_possible?

@@ -288,2 +287,6 @@ (in_lex_state?(:expr_beg, :expr_endfn) && !command_state) || is_arg?

def is_label_suffix?
check(/:(?!:)/)
end
def is_space_arg? c = "x"

@@ -342,2 +345,8 @@ is_arg? and space_seen and c !~ /\s/

self.lex_state = :expr_endarg
# TODO
# if (c == '}') {
# if (!brace_nest--) c = tSTRING_DEND;
# }
return :tRCURLY, matched

@@ -457,3 +466,3 @@ when "]" then

return if in_lex_state?(:expr_beg, :expr_value, :expr_class,
:expr_fname, :expr_dot)
:expr_fname, :expr_dot, :expr_labelarg)

@@ -662,2 +671,8 @@ if scan(/([\ \t\r\f\v]*)\./) then

def process_label text
result = process_symbol text
result[0] = :tLABEL
result
end
def process_token text

@@ -683,3 +698,4 @@ # TODO: make this always return [token, lineno]

if !ruby18 and is_label_possible? and scan(/:(?!:)/) then
if !ruby18 and is_label_possible? and is_label_suffix? then
scan(/:/)
return result(:expr_labelarg, :tLABEL, [token, self.lineno])

@@ -745,3 +761,3 @@ end

end
when in_lex_state?(:expr_beg, :expr_value) then
when in_lex_state?(:expr_beg, :expr_value) then # TODO: :expr_labelarg
result(state, keyword.id0, value)

@@ -878,2 +894,6 @@ when keyword.id0 != keyword.id1 then

def check re
ss.check re
end
def scanner_class # TODO: design this out of oedipus_lex. or something.

@@ -1049,2 +1069,6 @@ RPStringScanner

def ruby22?
Ruby22Parser === parser
end
def process_string # TODO: rewrite / remove

@@ -1057,7 +1081,16 @@ token = if lex_strterm[0] == :heredoc then

token_type, _ = token
token_type, c = token
if token_type == :tSTRING_END || token_type == :tREGEXP_END then
if ruby22? && token_type == :tSTRING_END && ["'", '"'].include?(c) then
if (([:expr_beg, :expr_endfn].include?(lex_state) &&
!cond.is_in_state) || is_arg?) &&
is_label_suffix? then
scan(/:/)
token_type = token[0] = :tLABEL_END
end
end
if [:tSTRING_END, :tREGEXP_END, :tLABEL_END].include? token_type then
self.lex_strterm = nil
self.lex_state = :expr_end
self.lex_state = (token_type == :tLABEL_END) ? :expr_labelarg : :expr_end
end

@@ -1064,0 +1097,0 @@

+4
-0

@@ -114,2 +114,4 @@ # encoding: UTF-8

end # group /=/
when ruby22_label? && (text = ss.scan(/\"(#{SIMPLE_STRING})\":/o)) then
process_label text
when text = ss.scan(/\"(#{SIMPLE_STRING})\"/o) then

@@ -165,2 +167,4 @@ action { result :expr_end, :tSTRING, text[1..-2].gsub(ESC) { unescape $1 } }

process_square_bracket text
when ruby22_label? && (text = ss.scan(/\'#{SSTRING}\':/o)) then
process_label text
when text = ss.scan(/\'#{SSTRING}\'/o) then

@@ -167,0 +171,0 @@ action { result :expr_end, :tSTRING, matched[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'") } # " stupid emacs

@@ -94,3 +94,3 @@ # encoding: ASCII-8BIT

module RubyParserStuff
VERSION = "3.6.6" unless constants.include? "VERSION" # SIGH
VERSION = "3.7.0" unless constants.include? "VERSION" # SIGH

@@ -1323,2 +1323,6 @@ attr_accessor :lexer, :in_def, :in_single, :file

class Ruby22Parser < Racc::Parser
include RubyParserStuff
end
class Ruby21Parser < Racc::Parser

@@ -1353,2 +1357,3 @@ include RubyParserStuff

@p21 = Ruby21Parser.new
@p22 = Ruby22Parser.new
end

@@ -1358,3 +1363,3 @@

e = nil
[@p21, @p20, @p19, @p18].each do |parser|
[@p22, @p21, @p20, @p19, @p18].each do |parser|
begin

@@ -1376,2 +1381,3 @@ return parser.process s, f, t

@p21.reset
@p22.reset
end

@@ -1389,2 +1395,4 @@

Ruby21Parser.new
when /^2.2/ then
Ruby22Parser.new
else

@@ -1391,0 +1399,0 @@ raise "unrecognized RUBY_VERSION #{RUBY_VERSION}"

@@ -5,2 +5,3 @@ require 'ruby18_parser'

require 'ruby21_parser'
require 'ruby22_parser'
require 'ruby_parser_extras'

@@ -17,2 +17,4 @@ .autotest

lib/ruby21_parser.y
lib/ruby22_parser.rb
lib/ruby22_parser.y
lib/ruby_lexer.rb

@@ -22,2 +24,3 @@ lib/ruby_lexer.rex

lib/ruby_parser.rb
lib/ruby_parser.yy
lib/ruby_parser_extras.rb

@@ -24,0 +27,0 @@ test/test_ruby_lexer.rb

@@ -25,7 +25,11 @@ # -*- ruby -*-

if plugin? :perforce then
if plugin? :perforce then # generated files
self.perforce_ignore << "lib/ruby18_parser.rb"
self.perforce_ignore << "lib/ruby19_parser.rb"
self.perforce_ignore << "lib/ruby20_parser.rb"
self.perforce_ignore << "lib/ruby20_parser.y"
self.perforce_ignore << "lib/ruby21_parser.rb"
self.perforce_ignore << "lib/ruby21_parser.y"
self.perforce_ignore << "lib/ruby22_parser.rb"
self.perforce_ignore << "lib/ruby22_parser.y"
self.perforce_ignore << "lib/ruby_lexer.rex.rb"

@@ -37,2 +41,14 @@ end

file "lib/ruby20_parser.y" => "lib/ruby_parser.yy" do |t|
sh "unifdef -tk -DRUBY20 -URUBY21 -URUBY22 -UDEAD #{t.source} > #{t.name} || true"
end
file "lib/ruby21_parser.y" => "lib/ruby_parser.yy" do |t|
sh "unifdef -tk -URUBY20 -DRUBY21 -URUBY22 -UDEAD #{t.source} > #{t.name} || true"
end
file "lib/ruby22_parser.y" => "lib/ruby_parser.yy" do |t|
sh "unifdef -tk -URUBY20 -URUBY21 -DRUBY22 -UDEAD #{t.source} > #{t.name} || true"
end
file "lib/ruby18_parser.rb" => "lib/ruby18_parser.y"

@@ -42,2 +58,3 @@ file "lib/ruby19_parser.rb" => "lib/ruby19_parser.y"

file "lib/ruby21_parser.rb" => "lib/ruby21_parser.y"
file "lib/ruby22_parser.rb" => "lib/ruby22_parser.y"
file "lib/ruby_lexer.rex.rb" => "lib/ruby_lexer.rex"

@@ -50,2 +67,3 @@

Dir["coverage"] +
Dir["lib/ruby2*_parser.y"] +
Dir["lib/*.output"])

@@ -82,9 +100,15 @@ end

%w[18 19 20 21].each do |v|
# possibly new instructions:
#
# 1) check out the XX version of ruby
# 2) YFLAGS="-r all" make parse.c
# 3) mv y.output parseXX.output
%w[18 19 20 21 22].each do |v|
task "compare#{v}" do
sh "./yack.rb lib/ruby#{v}_parser.output > racc#{v}.txt"
sh "./yack.rb parse#{v}.output > yacc#{v}.txt"
sh "diff -du yacc#{v}.txt racc#{v}.txt || true"
sh "diff -du racc#{v}.txt yacc#{v}.txt || true"
puts
sh "diff -du yacc#{v}.txt racc#{v}.txt | wc -l"
sh "diff -du racc#{v}.txt yacc#{v}.txt | wc -l"
end

@@ -94,3 +118,3 @@ end

task :debug => :isolate do
ENV["V"] ||= "21"
ENV["V"] ||= "22"
Rake.application[:parser].invoke # this way we can have DEBUG set

@@ -112,2 +136,4 @@ Rake.application[:lexer].invoke # this way we can have DEBUG set

Ruby21Parser.new
when "22" then
Ruby22Parser.new
else

@@ -119,3 +145,4 @@ raise "Unsupported version #{ENV["V"]}"

file = ENV["F"] || ENV["FILE"]
n = ENV["BUG"]
file = (n && "bug#{n}.rb") || ENV["F"] || ENV["FILE"]

@@ -122,0 +149,0 @@ ruby = if file then

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display