ruby_parser 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby_parser might be problematic. Click here for more details.

data/.autotest CHANGED
@@ -1,16 +1,18 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  require 'autotest/restart'
4
- require 'autotest/rcov'
4
+ require 'autotest/rcov' if ENV['RCOV']
5
5
 
6
6
  Autotest.add_hook :initialize do |at|
7
7
  at.extra_files << "../../ParseTree/dev/test/pt_testcase.rb"
8
- at.libs << ":../../ParseTree/dev/lib:../../ParseTree/dev/test:../../sexp_processor/dev/lib"
8
+ at.libs << ":../../ParseTree/dev/test:../../sexp_processor/dev/lib"
9
9
  at.add_exception 'unit'
10
10
  at.add_exception 'coverage'
11
11
  at.add_exception 'coverage.info'
12
12
  at.add_exception '.diff'
13
13
 
14
+ at.libs << ':../../minitest/dev/lib'
15
+ at.testlib = "minitest/autorun"
14
16
  at.unit_diff = "unit_diff -u -b"
15
17
 
16
18
  at.add_mapping(/^lib\/.*\.y$/) do |f, _|
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ === 2.0.4 / 2009-08-18
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Changed requires around to be more accurate.
6
+
7
+ * 4 bug fixes:
8
+
9
+ * Fixed .autotest for minitest
10
+ * Fixed emacs escape lexing bug: "\C-\\" (maglev/gemstone)
11
+ * Fixed octal lexing edgecases. (maglev/gemstone)
12
+ * Fixed regexp lexing edgecases. (maglev/gemstone)
13
+
1
14
  === 2.0.3 / 2009-06-23
2
15
 
3
16
  * 4 minor enhancements:
data/Rakefile CHANGED
@@ -14,8 +14,8 @@ hoe = Hoe.spec 'ruby_parser' do
14
14
 
15
15
  self.rubyforge_name = 'parsetree'
16
16
 
17
- extra_dev_deps << 'ParseTree'
18
- extra_deps << ['sexp_processor', '>= 3.0.1']
17
+ extra_dev_deps << ['ParseTree', '~> 3.0']
18
+ extra_deps << ['sexp_processor', '~> 3.0']
19
19
  end
20
20
 
21
21
  hoe.spec.files += ['lib/ruby_parser.rb'] # jim.... cmon man
data/lib/ruby_lexer.rb CHANGED
@@ -1,14 +1,10 @@
1
- $: << File.expand_path("~/Work/p4/zss/src/ParseTree/dev/lib") # for me, not you.
2
- require 'sexp'
3
- require 'ruby_parser_extras'
4
-
5
1
  class RubyLexer
6
2
  attr_accessor :command_start
7
3
  attr_accessor :cmdarg
8
4
  attr_accessor :cond
9
5
  attr_accessor :nest
10
6
 
11
- ESC_RE = /\\([0-7]{1,3}|x[0-9a-fA-F]{1,2}|M-.|(C-|c)\?|(C-|c).|[^0-7xMCc])/
7
+ ESC_RE = /\\([0-7]{1,3}|x[0-9a-fA-F]{1,2}|M-[^\\]|(C-|c)[^\\]|[^0-7xMCc])/
12
8
 
13
9
  # Additional context surrounding tokens that both the lexer and
14
10
  # grammar use.
@@ -248,9 +244,9 @@ class RubyLexer
248
244
  int_with_base(2)
249
245
  when src.scan(/[+-]?0d[0-9_]+/) then
250
246
  int_with_base(10)
251
- when src.scan(/[+-]?0o?[0-7_]*[89]/) then
247
+ when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then
252
248
  rb_compile_error "Illegal octal digit."
253
- when src.scan(/[+-]?0o?[0-7_]+|0o/) then
249
+ when src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/) then
254
250
  int_with_base(8)
255
251
  when src.scan(/[+-]?[\d_]+_(e|\.)/) then
256
252
  rb_compile_error "Trailing '_' in number."
@@ -411,7 +407,8 @@ class RubyLexer
411
407
  src.matched.to_i(8).chr
412
408
  when src.scan(/x([0-9a-fA-F]{1,2})/) then # hex constant
413
409
  src[1].to_i(16).chr
414
- when src.scan(/M-\\/) then
410
+ when src.check(/M-\\[\\MCc]/) then
411
+ src.scan(/M-\\/) # eat it
415
412
  c = self.read_escape
416
413
  c[0] = (c[0].ord | 0x80).chr
417
414
  c
@@ -419,12 +416,13 @@ class RubyLexer
419
416
  c = src[1]
420
417
  c[0] = (c[0].ord | 0x80).chr
421
418
  c
422
- when src.scan(/C-\\|c\\/) then
419
+ when src.check(/(C-|c)\\[\\MCc]/) then
420
+ src.scan(/(C-|c)\\/) # eat it
423
421
  c = self.read_escape
424
422
  c[0] = (c[0].ord & 0x9f).chr
425
423
  c
426
424
  when src.scan(/C-\?|c\?/) then
427
- 0177.chr
425
+ 127.chr
428
426
  when src.scan(/(C-|c)(.)/) then
429
427
  c = src[2]
430
428
  c[0] = (c[0].ord & 0x9f).chr
@@ -586,8 +584,8 @@ class RubyLexer
586
584
  "v" => "\13",
587
585
  "\\" => '\\',
588
586
  "\n" => "",
589
- "C-\?" => 0177.chr,
590
- "c\?" => 0177.chr,
587
+ "C-\?" => 127.chr,
588
+ "c\?" => 127.chr,
591
589
  }[s]
592
590
 
593
591
  return r if r
data/lib/ruby_parser.rb CHANGED
@@ -9,6 +9,7 @@ class RubyParser < Racc::Parser
9
9
 
10
10
 
11
11
  require "ruby_lexer"
12
+ require "ruby_parser_extras"
12
13
 
13
14
  # Local Variables: **
14
15
  # racc-token-length-max:14 **
data/lib/ruby_parser.y CHANGED
@@ -1783,6 +1783,7 @@ end
1783
1783
  ---- inner
1784
1784
 
1785
1785
  require "ruby_lexer"
1786
+ require "ruby_parser_extras"
1786
1787
 
1787
1788
  # Local Variables: **
1788
1789
  # racc-token-length-max:14 **
@@ -115,7 +115,7 @@ class RPStringScanner < StringScanner
115
115
  end
116
116
 
117
117
  class RubyParser < Racc::Parser
118
- VERSION = '2.0.3' unless constants.include? "VERSION" # SIGH
118
+ VERSION = '2.0.4' unless constants.include? "VERSION" # SIGH
119
119
 
120
120
  attr_accessor :lexer, :in_def, :in_single, :file
121
121
  attr_reader :env, :comments
@@ -591,7 +591,7 @@ class RubyParser < Racc::Parser
591
591
  options = val[2]
592
592
 
593
593
  o, k = 0, nil
594
- options.split(//).each do |c| # FIX: this has a better home
594
+ options.split(//).uniq.each do |c| # FIX: this has a better home
595
595
  v = {
596
596
  'x' => Regexp::EXTENDED,
597
597
  'i' => Regexp::IGNORECASE,
@@ -1,7 +1,9 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
- require "minitest/autorun"
4
- require "ruby_lexer"
3
+ require 'rubygems'
4
+ require 'minitest/autorun'
5
+ require 'ruby_lexer'
6
+ require 'ruby_parser'
5
7
 
6
8
  class TestRubyLexer < MiniTest::Unit::TestCase
7
9
  alias :deny :refute
@@ -830,6 +832,22 @@ class TestRubyLexer < MiniTest::Unit::TestCase
830
832
  util_bad_token "01__23"
831
833
  end
832
834
 
835
+ def test_yylex_integer_oct_O
836
+ util_lex_token "0O52", :tINTEGER, 42
837
+ end
838
+
839
+ def test_yylex_integer_oct_O_bad_range
840
+ util_bad_token "0O8"
841
+ end
842
+
843
+ def test_yylex_integer_oct_O_bad_underscores
844
+ util_bad_token "0O1__23"
845
+ end
846
+
847
+ def test_yylex_integer_oct_O_not_bad_none
848
+ util_lex_token "0O ", :tINTEGER, 0
849
+ end
850
+
833
851
  def test_yylex_integer_oct_o
834
852
  util_lex_token "0o52", :tINTEGER, 42
835
853
  end
@@ -1280,6 +1298,10 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1280
1298
  :tREGEXP_END, "")
1281
1299
  end
1282
1300
 
1301
+ def test_yylex_regexp_escape_hex_bad
1302
+ util_bad_token '/regex\\xzxp/', :tREGEXP_BEG, "/"
1303
+ end
1304
+
1283
1305
  def test_yylex_regexp_escape_hex_one
1284
1306
  util_lex_token('/^[\\xd\\xa]{2}/on',
1285
1307
  :tREGEXP_BEG, '/',
@@ -1287,10 +1309,6 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1287
1309
  :tREGEXP_END, 'on')
1288
1310
  end
1289
1311
 
1290
- def test_yylex_regexp_escape_hex_bad
1291
- util_bad_token '/regex\\xzxp/', :tREGEXP_BEG, "/"
1292
- end
1293
-
1294
1312
  def test_yylex_regexp_escape_oct1
1295
1313
  util_lex_token('/regex\\0xp/',
1296
1314
  :tREGEXP_BEG, "/",
@@ -1421,24 +1439,47 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1421
1439
  :tSTRING, "string")
1422
1440
  end
1423
1441
 
1424
- def test_yylex_string_double_escape_M
1425
- util_lex_token('"\\M-g"',
1426
- :tSTRING, "\347")
1442
+ def test_yylex_string_double_escape_C
1443
+ util_lex_token('"\\C-a"',
1444
+ :tSTRING, "\001")
1427
1445
  end
1428
1446
 
1429
- def test_yylex_string_escape_x_single
1430
- util_lex_token('"\\x0"',
1431
- :tSTRING, "\000")
1447
+ def test_yylex_string_double_escape_C_backslash
1448
+ util_lex_token('"\\C-\\\\"',
1449
+ :tSTRING_BEG, "\"",
1450
+ :tSTRING_CONTENT, "\034",
1451
+ :tSTRING_END, "\"")
1432
1452
  end
1433
1453
 
1434
- def test_yylex_string_double_escape_chars
1435
- util_lex_token('"s\\tri\\ng"',
1436
- :tSTRING, "s\tri\ng")
1454
+ def test_yylex_string_double_escape_C_escape
1455
+ util_lex_token('"\\C-\\M-a"',
1456
+ :tSTRING_BEG, "\"",
1457
+ :tSTRING_CONTENT, "\201",
1458
+ :tSTRING_END, "\"")
1437
1459
  end
1438
1460
 
1439
- def test_yylex_string_double_escape_hex
1440
- util_lex_token('"n = \\x61\\x62\\x63"',
1441
- :tSTRING, "n = abc")
1461
+ def test_yylex_string_double_escape_C_question
1462
+ util_lex_token('"\\C-?"',
1463
+ :tSTRING, "\177")
1464
+ end
1465
+
1466
+ def test_yylex_string_double_escape_M
1467
+ util_lex_token('"\\M-a"',
1468
+ :tSTRING, "\341")
1469
+ end
1470
+
1471
+ def test_yylex_string_double_escape_M_backslash
1472
+ util_lex_token('"\\M-\\\\"',
1473
+ :tSTRING_BEG, "\"",
1474
+ :tSTRING_CONTENT, "\334",
1475
+ :tSTRING_END, "\"")
1476
+ end
1477
+
1478
+ def test_yylex_string_double_escape_M_escape
1479
+ util_lex_token('"\\M-\\C-a"',
1480
+ :tSTRING_BEG, "\"",
1481
+ :tSTRING_CONTENT, "\201",
1482
+ :tSTRING_END, "\"")
1442
1483
  end
1443
1484
 
1444
1485
  def test_yylex_string_double_escape_bs1
@@ -1451,6 +1492,40 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1451
1492
  :tSTRING, "a\\a")
1452
1493
  end
1453
1494
 
1495
+ def test_yylex_string_double_escape_c
1496
+ util_lex_token('"\\ca"',
1497
+ :tSTRING, "\001")
1498
+ end
1499
+
1500
+ def test_yylex_string_double_escape_c_backslash
1501
+ util_lex_token('"\\c\\"',
1502
+ :tSTRING_BEG, "\"",
1503
+ :tSTRING_CONTENT, "\034",
1504
+ :tSTRING_END, "\"")
1505
+ end
1506
+
1507
+ def test_yylex_string_double_escape_c_escape
1508
+ util_lex_token('"\\c\\M-a"',
1509
+ :tSTRING_BEG, "\"",
1510
+ :tSTRING_CONTENT, "\201",
1511
+ :tSTRING_END, "\"")
1512
+ end
1513
+
1514
+ def test_yylex_string_double_escape_c_question
1515
+ util_lex_token('"\\c?"',
1516
+ :tSTRING, "\177")
1517
+ end
1518
+
1519
+ def test_yylex_string_double_escape_chars
1520
+ util_lex_token('"s\\tri\\ng"',
1521
+ :tSTRING, "s\tri\ng")
1522
+ end
1523
+
1524
+ def test_yylex_string_double_escape_hex
1525
+ util_lex_token('"n = \\x61\\x62\\x63"',
1526
+ :tSTRING, "n = abc")
1527
+ end
1528
+
1454
1529
  def test_yylex_string_double_escape_octal
1455
1530
  util_lex_token('"n = \\101\\102\\103"',
1456
1531
  :tSTRING, "n = ABC")
@@ -1484,6 +1559,11 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1484
1559
  :tSTRING, "blah # blah")
1485
1560
  end
1486
1561
 
1562
+ def test_yylex_string_escape_x_single
1563
+ util_lex_token('"\\x0"',
1564
+ :tSTRING, "\000")
1565
+ end
1566
+
1487
1567
  def test_yylex_string_pct_Q
1488
1568
  util_lex_token("%Q[s1 s2]",
1489
1569
  :tSTRING_BEG, "%Q[",
@@ -1556,6 +1636,14 @@ class TestRubyLexer < MiniTest::Unit::TestCase
1556
1636
  :tSTRING_END, nil)
1557
1637
  end
1558
1638
 
1639
+ def test_yylex_string_pct_w_tab
1640
+ util_lex_token("%w[abc\tdef]",
1641
+ :tAWORDS_BEG, "%w[",
1642
+ :tSTRING_CONTENT, "abc\tdef",
1643
+ :tSPACE, nil,
1644
+ :tSTRING_END, nil)
1645
+ end
1646
+
1559
1647
  def test_yylex_string_single
1560
1648
  util_lex_token("'string'",
1561
1649
  :tSTRING, "string")
@@ -1,5 +1,6 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
+ require 'rubygems'
3
4
  require 'minitest/autorun'
4
5
  require 'ruby_parser'
5
6
 
@@ -364,6 +365,22 @@ class TestRubyParser < RubyParserTestCase
364
365
  assert_equal pt, @processor.parse(rb)
365
366
  end
366
367
 
368
+ def test_regexp
369
+ regexps = {
370
+ "/wtf/" => /wtf/,
371
+ "/wtf/n" => /wtf/n,
372
+ "/wtf/m" => /wtf/m,
373
+ "/wtf/nm" => /wtf/nm,
374
+ "/wtf/nmnmnmnm" => /wtf/nm,
375
+ }
376
+
377
+ regexps.each do |rb, lit|
378
+ assert_equal s(:lit, lit), @processor.parse(rb)
379
+ end
380
+
381
+ # TODO: add more including interpolation etc
382
+ end
383
+
367
384
  def test_str_pct_Q_nested
368
385
  rb = "%Q[before [#\{nest}] after]"
369
386
  pt = s(:dstr, "before [", s(:evstr, s(:call, nil, :nest, s(:arglist))), s(:str, "] after"))
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'minitest/autorun'
2
3
  require 'ruby_parser_extras'
3
4
 
metadata CHANGED
@@ -1,36 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFM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y5OcZ8TdyiyINUHtb5ej/T
30
- FBHgymkyj/AOSqKRIpXPhjC6
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- date: 2009-06-23 00:00:00 -07:00
12
+ date: 2009-08-18 00:00:00 -07:00
34
13
  default_executable:
35
14
  dependencies:
36
15
  - !ruby/object:Gem::Dependency
@@ -39,9 +18,9 @@ dependencies:
39
18
  version_requirement:
40
19
  version_requirements: !ruby/object:Gem::Requirement
41
20
  requirements:
42
- - - ">="
21
+ - - ~>
43
22
  - !ruby/object:Gem::Version
44
- version: 3.0.1
23
+ version: "3.0"
45
24
  version:
46
25
  - !ruby/object:Gem::Dependency
47
26
  name: ParseTree
@@ -49,9 +28,9 @@ dependencies:
49
28
  version_requirement:
50
29
  version_requirements: !ruby/object:Gem::Requirement
51
30
  requirements:
52
- - - ">="
31
+ - - ~>
53
32
  - !ruby/object:Gem::Version
54
- version: "0"
33
+ version: "3.0"
55
34
  version:
56
35
  - !ruby/object:Gem::Dependency
57
36
  name: hoe
@@ -61,7 +40,7 @@ dependencies:
61
40
  requirements:
62
41
  - - ">="
63
42
  - !ruby/object:Gem::Version
64
- version: 2.3.0
43
+ version: 2.3.3
65
44
  version:
66
45
  description: |-
67
46
  ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
@@ -139,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
118
  requirements: []
140
119
 
141
120
  rubyforge_project: parsetree
142
- rubygems_version: 1.3.4
121
+ rubygems_version: 1.3.5
143
122
  signing_key:
144
123
  specification_version: 3
145
124
  summary: ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which does by default use a C extension)
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- �FW�s"a�zM���h���/'��y������" ���u��[6֮��
2
- ��oE�y±#Q�+Tm���f��}́�,m��|��l���r�1��Wo�S�R%F�b�yD��x#8xÄC��x��w��ɛ�L�ڀ��9��g��J����q�Dm�������>D��_� ��
metadata.gz.sig DELETED
Binary file