parser 2.1.0.pre2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ada647b43495037cf17844d58832f74d63348d88
4
- data.tar.gz: 4c4a750b4e696fb5f31f8b6c46718f2d71731651
3
+ metadata.gz: 6c8816d86f0b6658877e3cf52a953145a3cfb6a8
4
+ data.tar.gz: 2190740a21e07f44df7171d0f6128cf215db2d9e
5
5
  SHA512:
6
- metadata.gz: 69ae3a6286559fa7942af81b631cc1389cb0075f5c683cc460a46f1d3a29a1527f174604dd220c687c4b660e1e4bb409b49ce401f8113d4b5be5481486a3fe12
7
- data.tar.gz: 94b9c811b9d55d468ecc7de739228fa4c6622eb46bbfb7bdf3b4ef637f566fd2804e459354059b92ae6fb96fa0d2b2d9ffe9980bbf2a35236ac1d86687da985e
6
+ metadata.gz: 75057aa78a15de4a464146b0d979f6c039e9ca8407cb140b293168b23d1d87829da79762402683cf8909e696e6d9b85b216e09e004d9eff568cdec819797abcb
7
+ data.tar.gz: 4508a8d6b23ecb1bbe786c1c3bdea5621ab4ef45b83eff998f2a27726c7fb13d8c6a58d4bf0492742bc45e62e3f4c11a5c10baf8cc5f63d44c42246d0e2db0fc
data/.travis.yml CHANGED
@@ -4,7 +4,7 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - rbx-18mode
8
- - rbx-19mode
9
7
  - jruby-18mode
10
8
  - jruby-19mode
9
+ - rbx
10
+ cache: bundler
data/CHANGELOG.md CHANGED
@@ -1,18 +1,16 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- v2.1.0.pre2 (2013-11-25)
5
- ------------------------
4
+ v2.1.0 (2013-12-25)
5
+ -------------------
6
6
 
7
7
  API modifications:
8
8
  * Parser::Diagnostic: expose reason symbolically (closes #115, #116). (Ian MacLeod)
9
-
10
- vir (2013-11-13)
11
- ----------------
12
-
13
- API modifications:
14
9
  * lexer.rl: coerce literals to UTF-8 in ASCII-encoded files if they contain \uXXXX (Peter Zotov)
15
10
 
11
+ Bugs fixed:
12
+ * builders/default: represent heredocs with dedicated map (fixes #100). (Peter Zotov)
13
+
16
14
  v2.1.0.pre1 (2013-11-12)
17
15
  ------------------------
18
16
 
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in parser.gemspec
4
4
  gemspec
5
+
6
+ platforms :rbx do
7
+ gem 'rubysl', '~> 2.0'
8
+ gem 'rubinius', '~> 2.0'
9
+ end
data/doc/AST_FORMAT.md CHANGED
@@ -76,6 +76,18 @@ Format:
76
76
  ~~~~~~~~~~~~~~ expression
77
77
  ~~~
78
78
 
79
+ #### Here document
80
+
81
+ Format:
82
+
83
+ ~~~
84
+ (str "foo\nbar\n")
85
+ '<<HERE␊foo␊bar␊HERE'
86
+ ~~~~~~ expression
87
+ ~~~~~~~~ heredoc_body
88
+ ~~~~ heredoc_end
89
+ ~~~
90
+
79
91
  ### Symbol
80
92
 
81
93
  #### Plain
@@ -106,6 +118,8 @@ Format:
106
118
 
107
119
  ### Execute-string
108
120
 
121
+ #### Plain
122
+
109
123
  Format:
110
124
 
111
125
  ~~~
@@ -115,6 +129,18 @@ Format:
115
129
  ~~~~~~~~~~~ expression
116
130
  ~~~
117
131
 
132
+ #### Here document
133
+
134
+ Format:
135
+
136
+ ~~~
137
+ (xstr (str "foo\nbar\n"))
138
+ "<<`HERE`␊foo␊bar␊HERE"
139
+ ~~~~~~~~ expression
140
+ ~~~~~~~~ heredoc_body
141
+ ~~~~ heredoc_end
142
+ ~~~
143
+
118
144
  ### Regexp
119
145
 
120
146
  #### Options
data/lib/parser.rb CHANGED
@@ -45,6 +45,7 @@ module Parser
45
45
  require 'parser/source/map/ternary'
46
46
  require 'parser/source/map/for'
47
47
  require 'parser/source/map/rescue_body'
48
+ require 'parser/source/map/heredoc'
48
49
  end
49
50
 
50
51
  require 'parser/syntax_error'
@@ -109,11 +109,11 @@ module Parser
109
109
  parts.first
110
110
  else
111
111
  n(:str, parts.first.children,
112
- collection_map(begin_t, parts, end_t))
112
+ string_map(begin_t, parts, end_t))
113
113
  end
114
114
  else
115
115
  n(:dstr, [ *parts ],
116
- collection_map(begin_t, parts, end_t))
116
+ string_map(begin_t, parts, end_t))
117
117
  end
118
118
  end
119
119
 
@@ -157,7 +157,7 @@ module Parser
157
157
 
158
158
  def xstring_compose(begin_t, parts, end_t)
159
159
  n(:xstr, [ *parts ],
160
- collection_map(begin_t, parts, end_t))
160
+ string_map(begin_t, parts, end_t))
161
161
  end
162
162
 
163
163
  # Regular expressions
@@ -1092,6 +1092,20 @@ module Parser
1092
1092
  Source::Map::Collection.new(loc(begin_t), loc(end_t), expr_l)
1093
1093
  end
1094
1094
 
1095
+ def string_map(begin_t, parts, end_t)
1096
+ if begin_t && value(begin_t).start_with?('<<')
1097
+ if parts.any?
1098
+ expr_l = join_exprs(parts.first, parts.last)
1099
+ else
1100
+ expr_l = loc(end_t).begin
1101
+ end
1102
+
1103
+ Source::Map::Heredoc.new(loc(begin_t), expr_l, loc(end_t))
1104
+ else
1105
+ collection_map(begin_t, parts, end_t)
1106
+ end
1107
+ end
1108
+
1095
1109
  def regexp_map(begin_t, end_t, options_e)
1096
1110
  Source::Map::Collection.new(loc(begin_t), loc(end_t),
1097
1111
  loc(begin_t).join(options_e.loc.expression))
data/lib/parser/lexer.rl CHANGED
@@ -81,6 +81,12 @@ class Parser::Lexer
81
81
  %% write data nofinal;
82
82
  # %
83
83
 
84
+ ESCAPES = {
85
+ 'a' => "\a", 'b' => "\b", 'e' => "\e", 'f' => "\f",
86
+ 'n' => "\n", 'r' => "\r", 's' => "\s", 't' => "\t",
87
+ 'v' => "\v", '\\' => "\\"
88
+ }
89
+
84
90
  attr_reader :source_buffer
85
91
  attr_reader :encoding
86
92
 
@@ -635,11 +641,8 @@ class Parser::Lexer
635
641
  }
636
642
 
637
643
  action unescape_char {
638
- @escape = {
639
- 'a' => "\a", 'b' => "\b", 'e' => "\e", 'f' => "\f",
640
- 'n' => "\n", 'r' => "\r", 's' => "\s", 't' => "\t",
641
- 'v' => "\v", '\\' => "\\"
642
- }.fetch(@source[p - 1].chr, @source[p - 1].chr)
644
+ char = @source[p - 1].chr
645
+ @escape = ESCAPES.fetch(char, char)
643
646
  }
644
647
 
645
648
  action invalid_complex_escape {
@@ -1591,7 +1594,7 @@ class Parser::Lexer
1591
1594
  tok(@ts, @heredoc_e) =~ /^<<(-?)(["'`]?)(.*)\2$/
1592
1595
 
1593
1596
  indent = !$1.empty?
1594
- type = $2.empty? ? '"' : $2
1597
+ type = '<<' + ($2.empty? ? '"' : $2)
1595
1598
  delimiter = $3
1596
1599
 
1597
1600
  fnext *push_literal(type, delimiter, @ts, @heredoc_e, indent);
@@ -8,27 +8,30 @@ module Parser
8
8
 
9
9
  TYPES = {
10
10
  # type start token interpolate?
11
- "'" => [ :tSTRING_BEG, false ],
12
- '%q' => [ :tSTRING_BEG, false ],
13
- '"' => [ :tSTRING_BEG, true ],
14
- '%' => [ :tSTRING_BEG, true ],
15
- '%Q' => [ :tSTRING_BEG, true ],
16
-
17
- '%w' => [ :tQWORDS_BEG, false ],
18
- '%W' => [ :tWORDS_BEG, true ],
19
-
20
- '%i' => [ :tQSYMBOLS_BEG, false ],
21
- '%I' => [ :tSYMBOLS_BEG, true ],
22
-
23
- ":'" => [ :tSYMBEG, false ],
24
- '%s' => [ :tSYMBEG, false ],
25
- ':"' => [ :tSYMBEG, true ],
26
-
27
- '/' => [ :tREGEXP_BEG, true ],
28
- '%r' => [ :tREGEXP_BEG, true ],
29
-
30
- '%x' => [ :tXSTRING_BEG, true ],
31
- '`' => [ :tXSTRING_BEG, true ],
11
+ "'" => [ :tSTRING_BEG, false ],
12
+ "<<'" => [ :tSTRING_BEG, false ],
13
+ '%q' => [ :tSTRING_BEG, false ],
14
+ '"' => [ :tSTRING_BEG, true ],
15
+ '<<"' => [ :tSTRING_BEG, true ],
16
+ '%' => [ :tSTRING_BEG, true ],
17
+ '%Q' => [ :tSTRING_BEG, true ],
18
+
19
+ '%w' => [ :tQWORDS_BEG, false ],
20
+ '%W' => [ :tWORDS_BEG, true ],
21
+
22
+ '%i' => [ :tQSYMBOLS_BEG, false ],
23
+ '%I' => [ :tSYMBOLS_BEG, true ],
24
+
25
+ ":'" => [ :tSYMBEG, false ],
26
+ '%s' => [ :tSYMBEG, false ],
27
+ ':"' => [ :tSYMBEG, true ],
28
+
29
+ '/' => [ :tREGEXP_BEG, true ],
30
+ '%r' => [ :tREGEXP_BEG, true ],
31
+
32
+ '%x' => [ :tXSTRING_BEG, true ],
33
+ '`' => [ :tXSTRING_BEG, true ],
34
+ '<<`' => [ :tXSTRING_BEG, true ],
32
35
  }
33
36
 
34
37
  attr_reader :heredoc_e, :str_s
@@ -10,6 +10,10 @@ module Parser
10
10
  # * other ranges (`begin`, `end`, `operator`, ...): node-specific ranges
11
11
  # pointing to various interesting tokens corresponding to the node.
12
12
  #
13
+ # Note that the {Map::Heredoc} map is the only one whose `expression` does
14
+ # not include other ranges. It only covers the heredoc marker (`<<HERE`),
15
+ # not the here document itself.
16
+ #
13
17
  # All ranges except `expression` are defined by {Map} subclasses.
14
18
  #
15
19
  # Ranges (except `expression`) can be `nil` if the corresponding token is
@@ -0,0 +1,17 @@
1
+ module Parser
2
+ module Source
3
+
4
+ class Map::Heredoc < Map
5
+ attr_reader :heredoc_body
6
+ attr_reader :heredoc_end
7
+
8
+ def initialize(begin_l, body_l, end_l)
9
+ @heredoc_body = body_l
10
+ @heredoc_end = end_l
11
+
12
+ super(begin_l)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.1.0.pre2'
2
+ VERSION = '2.1.0'
3
3
  end
data/test/test_lexer.rb CHANGED
@@ -745,8 +745,8 @@ class TestLexer < Minitest::Test
745
745
  def test_heredoc_backtick
746
746
  assert_scanned("a = <<`EOF`\n blah blah\nEOF\n",
747
747
  :tIDENTIFIER, "a",
748
- :tEQL, "=",
749
- :tXSTRING_BEG, "`",
748
+ :tEQL, "=",
749
+ :tXSTRING_BEG, "<<`",
750
750
  :tSTRING_CONTENT, " blah blah\n",
751
751
  :tSTRING_END, "EOF",
752
752
  :tNL, nil)
@@ -755,8 +755,8 @@ class TestLexer < Minitest::Test
755
755
  def test_heredoc_double
756
756
  assert_scanned("a = <<\"EOF\"\n blah blah\nEOF\n",
757
757
  :tIDENTIFIER, "a",
758
- :tEQL, "=",
759
- :tSTRING_BEG, "\"",
758
+ :tEQL, "=",
759
+ :tSTRING_BEG, "<<\"",
760
760
  :tSTRING_CONTENT, " blah blah\n",
761
761
  :tSTRING_END, "EOF",
762
762
  :tNL, nil)
@@ -765,8 +765,8 @@ class TestLexer < Minitest::Test
765
765
  def test_heredoc_double_dash
766
766
  assert_scanned("a = <<-\"EOF\"\n blah blah\n EOF\n",
767
767
  :tIDENTIFIER, "a",
768
- :tEQL, "=",
769
- :tSTRING_BEG, "\"",
768
+ :tEQL, "=",
769
+ :tSTRING_BEG, "<<\"",
770
770
  :tSTRING_CONTENT, " blah blah\n",
771
771
  :tSTRING_END, "EOF",
772
772
  :tNL, nil)
@@ -775,22 +775,22 @@ class TestLexer < Minitest::Test
775
775
  def test_heredoc_double_eos
776
776
  refute_scanned("a = <<\"EOF\"\nblah",
777
777
  :tIDENTIFIER, "a",
778
- :tEQL, "=",
779
- :tSTRING_BEG, "\"")
778
+ :tEQL, "=",
779
+ :tSTRING_BEG, "<<\"")
780
780
  end
781
781
 
782
782
  def test_heredoc_double_eos_nl
783
783
  refute_scanned("a = <<\"EOF\"\nblah\n",
784
784
  :tIDENTIFIER, "a",
785
- :tEQL, "=",
786
- :tSTRING_BEG, "\"")
785
+ :tEQL, "=",
786
+ :tSTRING_BEG, "<<\"")
787
787
  end
788
788
 
789
789
  def test_heredoc_double_interp
790
790
  assert_scanned("a = <<\"EOF\"\n#x a \#@a b \#$b c \#{3} \nEOF\n",
791
791
  :tIDENTIFIER, "a",
792
- :tEQL, "=",
793
- :tSTRING_BEG, "\"",
792
+ :tEQL, "=",
793
+ :tSTRING_BEG, "<<\"",
794
794
  :tSTRING_CONTENT, "#x a ",
795
795
  :tSTRING_DVAR, nil,
796
796
  :tIVAR, "@a",
@@ -808,7 +808,7 @@ class TestLexer < Minitest::Test
808
808
 
809
809
  def test_heredoc_empty
810
810
  assert_scanned("<<\"\"\n\#{x}\nblah2\n\n",
811
- :tSTRING_BEG, "\"",
811
+ :tSTRING_BEG, "<<\"",
812
812
  :tSTRING_DBEG, "\#{",
813
813
  :tIDENTIFIER, "x",
814
814
  :tRCURLY, "}",
@@ -821,8 +821,8 @@ class TestLexer < Minitest::Test
821
821
  def test_heredoc_none
822
822
  assert_scanned("a = <<EOF\nblah\nblah\nEOF",
823
823
  :tIDENTIFIER, "a",
824
- :tEQL, "=",
825
- :tSTRING_BEG, "\"",
824
+ :tEQL, "=",
825
+ :tSTRING_BEG, "<<\"",
826
826
  :tSTRING_CONTENT, "blah\n",
827
827
  :tSTRING_CONTENT, "blah\n",
828
828
  :tSTRING_END, "EOF",
@@ -832,8 +832,8 @@ class TestLexer < Minitest::Test
832
832
  def test_heredoc_none_dash
833
833
  assert_scanned("a = <<-EOF\nblah\nblah\n EOF",
834
834
  :tIDENTIFIER, "a",
835
- :tEQL, "=",
836
- :tSTRING_BEG, "\"",
835
+ :tEQL, "=",
836
+ :tSTRING_BEG, "<<\"",
837
837
  :tSTRING_CONTENT, "blah\n",
838
838
  :tSTRING_CONTENT, "blah\n",
839
839
  :tSTRING_END, "EOF",
@@ -843,8 +843,8 @@ class TestLexer < Minitest::Test
843
843
  def test_heredoc_single
844
844
  assert_scanned("a = <<'EOF'\n blah blah\nEOF\n",
845
845
  :tIDENTIFIER, "a",
846
- :tEQL, "=",
847
- :tSTRING_BEG, "'",
846
+ :tEQL, "=",
847
+ :tSTRING_BEG, "<<'",
848
848
  :tSTRING_CONTENT, " blah blah\n",
849
849
  :tSTRING_END, "EOF",
850
850
  :tNL, nil)
@@ -860,8 +860,8 @@ class TestLexer < Minitest::Test
860
860
  def test_heredoc_single_dash
861
861
  assert_scanned("a = <<-'EOF'\n blah blah\n EOF\n",
862
862
  :tIDENTIFIER, "a",
863
- :tEQL, "=",
864
- :tSTRING_BEG, "'",
863
+ :tEQL, "=",
864
+ :tSTRING_BEG, "<<'",
865
865
  :tSTRING_CONTENT, " blah blah\n",
866
866
  :tSTRING_END, "EOF",
867
867
  :tNL, nil)
@@ -870,8 +870,8 @@ class TestLexer < Minitest::Test
870
870
  def test_heredoc_one_character
871
871
  assert_scanned("a = <<E\nABCDEF\nE\n",
872
872
  :tIDENTIFIER, "a",
873
- :tEQL, "=",
874
- :tSTRING_BEG, "\"",
873
+ :tEQL, "=",
874
+ :tSTRING_BEG, "<<\"",
875
875
  :tSTRING_CONTENT, "ABCDEF\n",
876
876
  :tSTRING_END, "E",
877
877
  :tNL, nil)
@@ -880,8 +880,8 @@ class TestLexer < Minitest::Test
880
880
  def test_heredoc_cr
881
881
  assert_scanned("a = <<E\r\r\nABCDEF\r\r\nE\r\r\r\n",
882
882
  :tIDENTIFIER, "a",
883
- :tEQL, "=",
884
- :tSTRING_BEG, "\"",
883
+ :tEQL, "=",
884
+ :tSTRING_BEG, "<<\"",
885
885
  :tSTRING_CONTENT, "ABCDEF\r\n",
886
886
  :tSTRING_END, "E",
887
887
  :tNL, nil)
@@ -2495,14 +2495,14 @@ class TestLexer < Minitest::Test
2495
2495
  def test_whitespace_cr
2496
2496
  setup_lexer(20)
2497
2497
  assert_scanned("<<E\nfoo\nE\rO",
2498
- :tSTRING_BEG, '"',
2498
+ :tSTRING_BEG, '<<"',
2499
2499
  :tSTRING_CONTENT, "foo\n",
2500
2500
  :tSTRING_END, 'E',
2501
2501
  :tNL, nil)
2502
2502
 
2503
2503
  setup_lexer(21)
2504
2504
  refute_scanned("<<E\nfoo\nE\rO",
2505
- :tSTRING_BEG, '"',
2505
+ :tSTRING_BEG, '<<"',
2506
2506
  :tSTRING_CONTENT, "foo\n")
2507
2507
  end
2508
2508
 
@@ -2581,7 +2581,7 @@ class TestLexer < Minitest::Test
2581
2581
 
2582
2582
  def test_bug_expr_beg_heredoc
2583
2583
  assert_scanned("<<EOL % [\nfoo\nEOL\n]",
2584
- :tSTRING_BEG, '"',
2584
+ :tSTRING_BEG, '<<"',
2585
2585
  :tSTRING_CONTENT, "foo\n",
2586
2586
  :tSTRING_END, 'EOL',
2587
2587
  :tPERCENT, '%',
@@ -2638,9 +2638,9 @@ class TestLexer < Minitest::Test
2638
2638
 
2639
2639
  @lex.state = :expr_arg
2640
2640
  assert_scanned(" <<EOS\nEOS",
2641
- :tSTRING_BEG, "\"",
2642
- :tSTRING_END, "EOS",
2643
- :tNL, nil)
2641
+ :tSTRING_BEG, "<<\"",
2642
+ :tSTRING_END, "EOS",
2643
+ :tNL, nil)
2644
2644
  end
2645
2645
 
2646
2646
  def test_bug_expr_arg_slash
@@ -2682,7 +2682,7 @@ class TestLexer < Minitest::Test
2682
2682
  def test_bug_heredoc_continuation
2683
2683
  @lex.state = :expr_arg
2684
2684
  assert_scanned(" <<EOS\nEOS\nend",
2685
- :tSTRING_BEG, "\"",
2685
+ :tSTRING_BEG, "<<\"",
2686
2686
  :tSTRING_END, "EOS",
2687
2687
  :tNL, nil,
2688
2688
  :kEND, "end")
@@ -2690,7 +2690,7 @@ class TestLexer < Minitest::Test
2690
2690
 
2691
2691
  def test_bug_heredoc_cr_lf
2692
2692
  assert_scanned("<<FIN\r\nfoo\r\nFIN\r\n",
2693
- :tSTRING_BEG, "\"",
2693
+ :tSTRING_BEG, "<<\"",
2694
2694
  :tSTRING_CONTENT, "foo\n",
2695
2695
  :tSTRING_END, "FIN",
2696
2696
  :tNL, nil)
@@ -2735,7 +2735,7 @@ class TestLexer < Minitest::Test
2735
2735
 
2736
2736
  def test_bug_heredoc_backspace_nl
2737
2737
  assert_scanned(" <<'XXX'\nf \\\nXXX\n",
2738
- :tSTRING_BEG, "'",
2738
+ :tSTRING_BEG, "<<'",
2739
2739
  :tSTRING_CONTENT, "f \\\n",
2740
2740
  :tSTRING_END, "XXX",
2741
2741
  :tNL, nil)
@@ -2743,7 +2743,7 @@ class TestLexer < Minitest::Test
2743
2743
 
2744
2744
  def test_bug_heredoc_lshft
2745
2745
  assert_scanned("<<RULES << CLEANINGS\nRULES",
2746
- :tSTRING_BEG, '"',
2746
+ :tSTRING_BEG, '<<"',
2747
2747
  :tSTRING_END, 'RULES',
2748
2748
  :tLSHFT, '<<',
2749
2749
  :tCONSTANT, 'CLEANINGS')
@@ -2871,7 +2871,7 @@ class TestLexer < Minitest::Test
2871
2871
 
2872
2872
  def test_bug_interleaved_heredoc
2873
2873
  assert_scanned(%Q{<<w; "\nfoo\nw\n"},
2874
- :tSTRING_BEG, '"',
2874
+ :tSTRING_BEG, '<<"',
2875
2875
  :tSTRING_CONTENT, "foo\n",
2876
2876
  :tSTRING_END, 'w',
2877
2877
  :tSEMI, ';',
@@ -2881,7 +2881,7 @@ class TestLexer < Minitest::Test
2881
2881
 
2882
2882
  @lex.state = :expr_beg
2883
2883
  assert_scanned(%Q{<<w; %w[\nfoo\nw\n1]},
2884
- :tSTRING_BEG, '"',
2884
+ :tSTRING_BEG, '<<"',
2885
2885
  :tSTRING_CONTENT, "foo\n",
2886
2886
  :tSTRING_END, 'w',
2887
2887
  :tSEMI, ';',
@@ -2892,7 +2892,7 @@ class TestLexer < Minitest::Test
2892
2892
 
2893
2893
  @lex.state = :expr_beg
2894
2894
  assert_scanned(%Q{<<w; "\#{\nfoo\nw\n}"},
2895
- :tSTRING_BEG, '"',
2895
+ :tSTRING_BEG, '<<"',
2896
2896
  :tSTRING_CONTENT, "foo\n",
2897
2897
  :tSTRING_END, 'w',
2898
2898
  :tSEMI, ';',
data/test/test_parser.rb CHANGED
@@ -237,6 +237,29 @@ class TestParser < Minitest::Test
237
237
  %w(1.8))
238
238
  end
239
239
 
240
+ def test_heredoc
241
+ assert_parses(
242
+ s(:dstr, s(:str, "foo\n"), s(:str, "bar\n")),
243
+ %Q{<<HERE!foo!bar!HERE}.gsub('!', "\n"),
244
+ %q{~~~~~~ expression
245
+ | ~~~~~~~~ heredoc_body
246
+ | ~~~~ heredoc_end})
247
+
248
+ assert_parses(
249
+ s(:dstr, s(:str, "foo\n"), s(:str, "bar\n")),
250
+ %Q{<<'HERE'!foo!bar!HERE}.gsub('!', "\n"),
251
+ %q{~~~~~~~~ expression
252
+ | ~~~~~~~~ heredoc_body
253
+ | ~~~~ heredoc_end})
254
+
255
+ assert_parses(
256
+ s(:xstr, s(:str, "foo\n"), s(:str, "bar\n")),
257
+ %Q{<<`HERE`!foo!bar!HERE}.gsub('!', "\n"),
258
+ %q{~~~~~~~~ expression
259
+ | ~~~~~~~~ heredoc_body
260
+ | ~~~~ heredoc_end})
261
+ end
262
+
240
263
  # Symbols
241
264
 
242
265
  def test_symbol_plain
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: 2.1.0.pre2
4
+ version: 2.1.0
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-11-25 00:00:00.000000000 Z
11
+ date: 2013-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -286,6 +286,7 @@ files:
286
286
  - lib/parser/source/map/constant.rb
287
287
  - lib/parser/source/map/definition.rb
288
288
  - lib/parser/source/map/for.rb
289
+ - lib/parser/source/map/heredoc.rb
289
290
  - lib/parser/source/map/keyword.rb
290
291
  - lib/parser/source/map/operator.rb
291
292
  - lib/parser/source/map/rescue_body.rb
@@ -337,12 +338,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
338
  version: '0'
338
339
  required_rubygems_version: !ruby/object:Gem::Requirement
339
340
  requirements:
340
- - - '>'
341
+ - - '>='
341
342
  - !ruby/object:Gem::Version
342
- version: 1.3.1
343
+ version: '0'
343
344
  requirements: []
344
345
  rubyforge_project:
345
- rubygems_version: 2.0.0
346
+ rubygems_version: 2.0.14
346
347
  signing_key:
347
348
  specification_version: 4
348
349
  summary: A Ruby parser written in pure Ruby.