parser 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1651bd7bc0d39e00057fd6f24dd4a6ef2239e108
4
- data.tar.gz: 31d38b4035c2cb105075c204ff321b725653c7c9
3
+ metadata.gz: 6cd417cce73823b5c02700b31b2ddc3364453aaf
4
+ data.tar.gz: 143425da0cc95ae994b1068807561968afb43267
5
5
  SHA512:
6
- metadata.gz: 6452eeb521655b074987d3d17daf6b5cfbbd979769c3a892db9ba970a2f774180ad81eeeb8d9f2e412c6c14d8bed95510061266144e24a9fada054ec3071aae4
7
- data.tar.gz: 4454c5b7db370bc275a2deb63eca54c8c8d896db0726a5a9f688576d8219670ff49527cac3a636551a920e773b7bfd2104b6570cb448e6fe7182d75b4de80b1d
6
+ metadata.gz: 1f55f2a694de612a9f9c71c428a91fa210134523b2377c4d5b2fe1276f64ddee27f4a702df979128d1b93172654fd7f684e9cbe3e297ccfcec53f00a29d90c8b
7
+ data.tar.gz: 634c5ce4b572ee896d4eb82443b43c6f91af5542121f1525eff684259f24f8d59fc23920d8ec3e93b47d46014baabd18ff9b6563e5f5102a9f55d1f832971ae1
@@ -1717,7 +1717,7 @@ class Parser::Lexer
1717
1717
 
1718
1718
  constant
1719
1719
  => { emit(:tCONSTANT)
1720
- fbreak; };
1720
+ fnext expr_arg; fbreak; };
1721
1721
 
1722
1722
  constant ambiguous_const_suffix
1723
1723
  => { emit(:tCONSTANT, tok(@ts, tm), @ts, tm)
@@ -8,12 +8,15 @@ module Parser
8
8
 
9
9
  def self.recognize_encoding(string)
10
10
  if string.empty?
11
- return Encoding::UTF_8
11
+ return Encoding::BINARY
12
12
  end
13
13
 
14
14
  # TODO: Make this more efficient.
15
15
  first_line, second_line = string.lines.first(2)
16
- first_line.force_encoding(Encoding::ASCII_8BIT)
16
+
17
+ [first_line, second_line].each do |line|
18
+ line.force_encoding(Encoding::ASCII_8BIT) if line
19
+ end
17
20
 
18
21
  if first_line =~ /\A\xef\xbb\xbf/ # BOM
19
22
  return Encoding::UTF_8
@@ -23,9 +26,7 @@ module Parser
23
26
  encoding_line = first_line
24
27
  end
25
28
 
26
- encoding_line.force_encoding(Encoding::ASCII_8BIT)
27
-
28
- if encoding_line =~ /coding[:=]?\s*([a-z0-9_-]+)/
29
+ if encoding_line =~ /^#.*coding[:=]\s*([a-z0-9_-]+)/
29
30
  Encoding.find($1)
30
31
  else
31
32
  string.encoding
@@ -105,7 +106,7 @@ module Parser
105
106
  end
106
107
  end
107
108
 
108
- @lines[line - @first_line]
109
+ @lines[line - @first_line].dup
109
110
  end
110
111
 
111
112
  private
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '1.3.3'
2
+ VERSION = '1.3.4'
3
3
  end
@@ -25,7 +25,16 @@ class TestEncoding < MiniTest::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_empty
28
- assert_equal Encoding::UTF_8, recognize("")
28
+ assert_equal Encoding::BINARY, recognize("")
29
+ end
30
+
31
+ def test_no_comment
32
+ assert_equal Encoding::BINARY, recognize(%{require 'cane/encoding_aware_iterator'})
33
+ end
34
+
35
+ def test_adjacent
36
+ assert_equal Encoding::BINARY, recognize("# codingkoi8-r")
37
+ assert_equal Encoding::BINARY, recognize("# coding koi8-r")
29
38
  end
30
39
  end
31
40
  end
@@ -2117,6 +2117,13 @@ class TestLexer < MiniTest::Unit::TestCase
2117
2117
  :kSELF, "self")
2118
2118
  end
2119
2119
 
2120
+ def test_bug_const_expr_end
2121
+ util_lex_token("Option",
2122
+ :tCONSTANT, 'Option')
2123
+
2124
+ assert_equal :expr_arg, @lex.state
2125
+ end
2126
+
2120
2127
  def test_bug_expr_beg_div
2121
2128
  @lex.state = :expr_beg
2122
2129
  util_lex_token("/=/",
@@ -71,6 +71,15 @@ class TestSourceBuffer < MiniTest::Unit::TestCase
71
71
  assert_equal "foo", @buffer.source_line(2)
72
72
  end
73
73
 
74
+ def test_line_mutate
75
+ @buffer.source = "1\nfoo\nbar"
76
+
77
+ assert_equal "1", @buffer.source_line(1)
78
+
79
+ @buffer.source_line(1)[0] = '2'
80
+ assert_equal "1", @buffer.source_line(1)
81
+ end
82
+
74
83
  def test_line_mapped
75
84
  @buffer = Parser::Source::Buffer.new('(string)', 5)
76
85
  @buffer.source = "1\nfoo\nbar"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-15 00:00:00.000000000 Z
11
+ date: 2013-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast