parser 2.0.0.beta3 → 2.0.0.beta4

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: d3c90abfdc392d6c6d0c73d73138f073428117e6
4
- data.tar.gz: d0c947aa1ada143e47b3558ae215a4f245f2ccff
3
+ metadata.gz: b376a16dbd765d49118c18432b8134011d732f09
4
+ data.tar.gz: 12cad6ee3c5f47b267b4b93d442e3e5ae80be478
5
5
  SHA512:
6
- metadata.gz: 76e1c1063a7ab852b19cc2b6a6eb1121cd7f9aa13ec40b3712dc568dfd24b8ac7b72610386d4a33932e22331eac5fca2575efdf302b3daf9cfe398edac1d13be
7
- data.tar.gz: 4647419022b86a8d8a53f9a126d0c47fa6d9f23d5b2ed2b5ce60277b6803a0202f7701e24c8905ce41d072954aa60408198fd98087584f9fdf44f688b176420b
6
+ metadata.gz: 5be76612d68a0692c0c3d2691bb83816b35aeda66d496cfebbb04c65a5dd0cacf8be7c6d739fbc0cbefff05f5f20b270fd3bd426c602f1ad32bcbf216102e6be
7
+ data.tar.gz: b1fa6025f4b3311870f5403a7fab57cd9da3e851f89ebff271a5853e783e7c4790a153440c753f681054edf0f94ca2821e5f793427cbc2ed7ed1bef0d4a2dbc9
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.0.0.beta4 (2013-06-05)
5
+ -------------------------
6
+
7
+ Bugs fixed:
8
+ * lexer.rl: fix heredoc parsing with CRLF line endings (closes #61). (Peter Zotov)
9
+ * lexer.rl: fix premature ending of heredoc "\<\<D\nABCDEF\nD" (fixes #59). (Peter Zotov)
10
+
4
11
  v2.0.0.beta3 (2013-05-29)
5
12
  -------------------------
6
13
 
data/README.md CHANGED
@@ -114,6 +114,10 @@ $ ruby-parse -E -e "2+2"
114
114
  [slop]: http://rubygems.org/gems/slop
115
115
  [insane-lexer]: http://whitequark.org/blog/2013/04/01/ruby-hacking-guide-ch-11-finite-state-lexer/
116
116
 
117
+ ## Documentation
118
+
119
+ Documentation for parser is available online on [rdoc.info](http://rdoc.info/github/whitequark/parser).
120
+
117
121
  ## Contributors
118
122
 
119
123
  * Peter Zotov ([whitequark][])
@@ -673,7 +673,7 @@ class Parser::Lexer
673
673
  # @heredoc_s to literal.saved_herebody_s, and after an interpolation (possibly
674
674
  # containing another heredocs) is closed, the previous value is restored.
675
675
 
676
- e_heredoc_nl = c_nl $ {
676
+ e_heredoc_nl = c_nl % {
677
677
  # After every heredoc was parsed, @herebody_s contains the
678
678
  # position of next token after all heredocs.
679
679
  if @herebody_s
@@ -683,10 +683,10 @@ class Parser::Lexer
683
683
  };
684
684
 
685
685
  action extend_string {
686
- if literal.nest_and_try_closing tok, @ts, @te
686
+ if !literal.heredoc? && literal.nest_and_try_closing(tok, @ts, @te)
687
687
  fnext *pop_literal; fbreak;
688
688
  else
689
- literal.extend_string tok, @ts, @te
689
+ literal.extend_string(tok, @ts, @te)
690
690
  end
691
691
  }
692
692
 
@@ -744,8 +744,8 @@ class Parser::Lexer
744
744
  if literal.heredoc?
745
745
  # Try ending the heredoc with the complete most recently
746
746
  # scanned line. @herebody_s always refers to the start of such line.
747
- if literal.nest_and_try_closing(tok(@herebody_s, @te - 1),
748
- @herebody_s, @te - 1)
747
+ if literal.nest_and_try_closing(tok(@herebody_s, @ts),
748
+ @herebody_s, @ts)
749
749
  # Adjust @herebody_s to point to the next line.
750
750
  @herebody_s = @te
751
751
 
@@ -1362,11 +1362,11 @@ class Parser::Lexer
1362
1362
  # Heredoc start.
1363
1363
  # <<EOF | <<-END | <<"FOOBAR" | <<-`SMTH`
1364
1364
  '<<' '-'?
1365
- ( '"' ( c_any - c_nl - '"' )* '"'
1366
- | "'" ( c_any - c_nl - "'" )* "'"
1367
- | "`" ( c_any - c_nl - "`" )* "`"
1368
- | bareword ) % { @heredoc_e = p }
1369
- ( c_any - c_nl )* c_nl % { new_herebody_s = p }
1365
+ ( '"' ( c_line - '"' )* '"'
1366
+ | "'" ( c_line - "'" )* "'"
1367
+ | "`" ( c_line - "`" )* "`"
1368
+ | bareword ) % { @heredoc_e = p }
1369
+ c_line* c_nl % { new_herebody_s = p }
1370
1370
  => {
1371
1371
  tok(@ts, @heredoc_e) =~ /^<<(-?)(["'`]?)(.*)\2$/
1372
1372
 
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.0.0.beta3'
2
+ VERSION = '2.0.0.beta4'
3
3
  end
@@ -811,6 +811,16 @@ class TestLexer < Minitest::Test
811
811
  :tNL, nil)
812
812
  end
813
813
 
814
+ def test_heredoc_one_character
815
+ util_lex_token("a = <<E\nABCDEF\nE\n",
816
+ :tIDENTIFIER, "a",
817
+ :tEQL, "=",
818
+ :tSTRING_BEG, "\"",
819
+ :tSTRING_CONTENT, "ABCDEF\n",
820
+ :tSTRING_END, "E",
821
+ :tNL, nil)
822
+ end
823
+
814
824
  def test_identifier
815
825
  util_lex_token("identifier", :tIDENTIFIER, "identifier")
816
826
  end
@@ -2499,6 +2509,14 @@ class TestLexer < Minitest::Test
2499
2509
  :kEND, "end")
2500
2510
  end
2501
2511
 
2512
+ def test_bug_heredoc_cr_lf
2513
+ util_lex_token("<<FIN\r\nfoo\r\nFIN\r\n",
2514
+ :tSTRING_BEG, "\"",
2515
+ :tSTRING_CONTENT, "foo\r\n",
2516
+ :tSTRING_END, "EOS",
2517
+ :tNL, nil)
2518
+ end
2519
+
2502
2520
  def test_bug_eh_symbol_no_newline
2503
2521
  util_lex_token("?\"\nfoo",
2504
2522
  :tINTEGER, 34,
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.0.0.beta3
4
+ version: 2.0.0.beta4
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-28 00:00:00.000000000 Z
11
+ date: 2013-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast