🚀 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.0.0.a6
to
3.0.0.a7
+14
-0
History.txt

@@ -0,1 +1,15 @@

=== 3.0.0.a7 / 2012-09-21
* 3 minor enhancements:
* Reorganized ruby_parse_extract_error so it will start much faster with a bunch of glob directories
* RubyParserStuff#process takes optional time arg and raises Timeout::Error if it goes too long. You should rescue that, ya know...
* ruby_parse_extract_error now checks *.rake and Rakefile on dir scan.
* 3 bug fixes:
* 1.9: Fixed ternary state tracking so {a:f{f()},b:nil} won't trip up the lexer.
* Fixed optional values in block args (no20/no21)
* ruby_parse_extract_error skips non-files. Some asshats put .rb on their dirs. :(
=== 3.0.0.a6 / 2012-08-20

@@ -2,0 +16,0 @@

+11
-8

@@ -19,3 +19,3 @@ # encoding: US-ASCII

attr_accessor :cond
attr_accessor :tern
attr_accessor :tern # TODO: rename ternary damnit... wtf
attr_accessor :nest

@@ -715,2 +715,3 @@

cmdarg.lexpop
tern.lexpop
self.lex_state = :expr_end

@@ -723,3 +724,2 @@ self.yacc_value = src.matched

}[src.matched]
self.tern.lexpop if [:tRBRACK, :tRCURLY].include?(result)
return result

@@ -1301,2 +1301,6 @@ elsif src.scan(/\.\.\.?|,|![=~]?/) then

def is_label_possible? command_state
(lex_state == :expr_beg && !command_state) || is_arg?
end
def yylex_paren19

@@ -1365,11 +1369,7 @@ if is_beg? then

unless self.tern.is_in_state
if (lex_state == :expr_beg && (ruby18 || !command_state)) ||
lex_state == :expr_arg ||
lex_state == :expr_cmdarg then
if is_label_possible? command_state then
colon = src.scan(/:/)
if colon && src.peek(1) != ":"
src.unscan
if colon && src.peek(1) != ":" then
self.lex_state = :expr_beg
src.scan(/:/)
self.yacc_value = [token, src.lineno]

@@ -1421,2 +1421,5 @@ return :tLABEL

# TODO:
# if (mb == ENC_CODERANGE_7BIT && lex_state != EXPR_DOT) {
self.lex_state =

@@ -1423,0 +1426,0 @@ if is_beg? || lex_state == :expr_dot || is_arg? then

@@ -6,2 +6,3 @@ require 'stringio'

require 'ruby_lexer'
require "timeout"

@@ -82,3 +83,3 @@ def d o

module RubyParserStuff
VERSION = '3.0.0.a6' unless constants.include? "VERSION" # SIGH
VERSION = '3.0.0.a7' unless constants.include? "VERSION" # SIGH

@@ -195,4 +196,4 @@ attr_accessor :lexer, :in_def, :in_single, :file

# HACK OMG THIS CODE IS SOOO UGLY! CLEAN ME
untested = %w[1 2 3 4 7 9 10 11 12 14]
raise "no block_args19 #{id}" if untested.include? id
untested = %w[1 2 3 4 7 9 10 12 14]
raise "no block_args19 #{id} #{val.inspect}" if untested.include? id

@@ -219,2 +220,4 @@ r = s(:array)

r << s(:lasgn, :"&#{v.last}")
when :lasgn then
r << s(:masgn, s(:array, v))
when :masgn then

@@ -906,25 +909,32 @@ r << v

def process(str, file = "(string)")
raise "bad val: #{str.inspect}" unless String === str
##
# Parse +str+ at path +file+ and return a sexp. Raises
# Timeout::Error if it runs for more than +time+ seconds.
str.lines.first(2).find { |s| s[/^# encoding: (.+)/, 1] }
encoding = $1
def process(str, file = "(string)", time = 10)
Timeout.timeout time do
raise "bad val: #{str.inspect}" unless String === str
str = str.dup
str.lines.first(2).find { |s| s[/^# encoding: (.+)/, 1] }
encoding = $1
if encoding then
if defined?(Encoding) then
str.force_encoding(encoding).encode! "utf-8"
else
warn "Skipping magic encoding comment"
str = str.dup
if encoding then
if defined?(Encoding) then
str.force_encoding(encoding).encode! "utf-8"
else
warn "Skipping magic encoding comment"
end
end
end
self.file = file
self.lexer.src = str
self.file = file
self.lexer.src = str
@yydebug = ENV.has_key? 'DEBUG'
@yydebug = ENV.has_key? 'DEBUG'
do_parse
do_parse
end
end
alias :parse :process

@@ -931,0 +941,0 @@

@@ -1192,6 +1192,36 @@ #!/usr/local/bin/ruby

def test_block_arg_optional
rb = "a { |b = 1| }"
pt = s(:iter,
s(:call, nil, :a),
s(:masgn, s(:array, s(:lasgn, :b, s(:lit, 1)))))
assert_parse rb, pt
end
def test_zomg_sometimes_i_hate_this_project
rb = <<-RUBY
{
a: lambda { b ? c() : d },
e: nil,
}
RUBY
pt = s(:hash,
s(:lit, :a),
s(:iter,
s(:call, nil, :lambda),
nil,
s(:if, s(:call, nil, :b), s(:call, nil, :c), s(:call, nil, :d))),
s(:lit, :e),
s(:nil))
assert_parse rb, pt
end
# def test_pipe_semicolon # HACK
# rb = "a.b do | ; c | end"
# pt = s(:iter, s(:call, s(:call, nil, :a), :b), 0)
#
#
# assert_parse rb, pt

@@ -1198,0 +1228,0 @@ # end

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