parser 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/doc/css/.gitkeep ADDED
File without changes
@@ -0,0 +1,68 @@
1
+ body
2
+ {
3
+ font-size: 14px;
4
+ line-height: 1.6;
5
+ margin: 0 auto;
6
+ max-width: 960px;
7
+ }
8
+
9
+ p code
10
+ {
11
+ background: #f2f2f2;
12
+ padding-left: 3px;
13
+ padding-right: 3px;
14
+ }
15
+
16
+ pre.code
17
+ {
18
+ font-size: 13px;
19
+ line-height: 1.4;
20
+ }
21
+
22
+ /**
23
+ * YARD uses generic table styles, using a special class means those tables
24
+ * don't get messed up.
25
+ */
26
+ .table
27
+ {
28
+ border: 1px solid #ccc;
29
+ border-right: none;
30
+ border-collapse: separate;
31
+ border-spacing: 0;
32
+ text-align: left;
33
+ }
34
+
35
+ .table.full
36
+ {
37
+ width: 100%;
38
+ }
39
+
40
+ .table .field_name
41
+ {
42
+ min-width: 160px;
43
+ }
44
+
45
+ .table thead tr th.no_sort:first-child
46
+ {
47
+ width: 25px;
48
+ }
49
+
50
+ .table thead tr th, .table tbody tr td
51
+ {
52
+ border-bottom: 1px solid #ccc;
53
+ border-right: 1px solid #ccc;
54
+ min-width: 20px;
55
+ padding: 8px 5px;
56
+ text-align: left;
57
+ vertical-align: top;
58
+ }
59
+
60
+ .table tbody tr:last-child td
61
+ {
62
+ border-bottom: none;
63
+ }
64
+
65
+ .table tr:nth-child(odd) td
66
+ {
67
+ background: #f9f9f9;
68
+ }
@@ -393,19 +393,19 @@ module Parser
393
393
  lt_t, superclass,
394
394
  body, end_t)
395
395
  n(:class, [ name, superclass, body ],
396
- definition_map(class_t, lt_t, nil, end_t))
396
+ module_definition_map(class_t, name, lt_t, end_t))
397
397
  end
398
398
 
399
399
  def def_sclass(class_t, lshft_t, expr,
400
400
  body, end_t)
401
401
  n(:sclass, [ expr, body ],
402
- definition_map(class_t, lshft_t, nil, end_t))
402
+ module_definition_map(class_t, nil, lshft_t, end_t))
403
403
  end
404
404
 
405
405
  def def_module(module_t, name,
406
406
  body, end_t)
407
407
  n(:module, [ name, body ],
408
- definition_map(module_t, nil, nil, end_t))
408
+ module_definition_map(module_t, name, nil, end_t))
409
409
  end
410
410
 
411
411
  #
@@ -978,6 +978,16 @@ module Parser
978
978
  Source::Map::Variable.new(name_range, expr_l)
979
979
  end
980
980
 
981
+ def module_definition_map(keyword_t, name_e, operator_t, end_t)
982
+ if name_e
983
+ name_l = name_e.src.expression
984
+ end
985
+
986
+ Source::Map::Definition.new(loc(keyword_t),
987
+ loc(operator_t), name_l,
988
+ loc(end_t))
989
+ end
990
+
981
991
  def definition_map(keyword_t, operator_t, name_t, end_t)
982
992
  Source::Map::Definition.new(loc(keyword_t),
983
993
  loc(operator_t), loc(name_t),
data/lib/parser/lexer.rl CHANGED
@@ -461,7 +461,7 @@ class Parser::Lexer
461
461
  global_var = '$'
462
462
  ( bareword | digit+
463
463
  | [`'+~*$&?!@/\\;,.=:<>"] # `
464
- | '-' [A-Za-z0-9_]?
464
+ | '-' c_alnum
465
465
  )
466
466
  ;
467
467
 
@@ -1802,7 +1802,7 @@ class Parser::Lexer
1802
1802
 
1803
1803
  c_any
1804
1804
  => {
1805
- message = Parser::ERRORS[:unexpected] % { :character => tok.inspect }
1805
+ message = Parser::ERRORS[:unexpected] % { :character => tok.inspect[1..-2] }
1806
1806
  diagnostic :fatal, message
1807
1807
  };
1808
1808
 
@@ -47,7 +47,7 @@ module Parser
47
47
  end
48
48
 
49
49
  def to_source
50
- source_line[column_range]
50
+ @source_buffer.source[self.begin_pos...self.end_pos]
51
51
  end
52
52
 
53
53
  def is?(*what)
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
data/parser.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = spec.description
11
11
  spec.homepage = 'http://github.com/whitequark/parser'
12
12
  spec.license = 'MIT'
13
+ spec.has_rdoc = 'yard'
13
14
 
14
15
  spec.files = `git ls-files`.split($/) + %w(
15
16
  lib/parser/lexer.rb
@@ -36,6 +37,6 @@ Gem::Specification.new do |spec|
36
37
 
37
38
  spec.add_development_dependency 'simplecov-sublime-ruby-coverage'
38
39
 
39
- spec.add_development_dependency 'github-markup'
40
40
  spec.add_development_dependency 'yard'
41
+ spec.add_development_dependency 'kramdown'
41
42
  end
data/test/parse_helper.rb CHANGED
@@ -55,7 +55,7 @@ module ParseHelper
55
55
  end
56
56
 
57
57
  # Use like this:
58
- # ```
58
+ # ~~~
59
59
  # assert_parses(
60
60
  # s(:send, s(:lit, 10), :+, s(:lit, 20))
61
61
  # %q{10 + 20},
@@ -65,7 +65,7 @@ module ParseHelper
65
65
  # },
66
66
  # %w(1.8 1.9) # optional
67
67
  # )
68
- # ```
68
+ # ~~~
69
69
  def assert_parses(ast, code, source_maps='', versions=ALL_VERSIONS)
70
70
  with_versions(code, versions) do |version, parser|
71
71
  source_file = Parser::Source::Buffer.new('(assert_parses)')
@@ -103,13 +103,13 @@ module ParseHelper
103
103
  end
104
104
 
105
105
  # Use like this:
106
- # ```
106
+ # ~~~
107
107
  # assert_diagnoses(
108
108
  # [:warning, :ambiguous_prefix, { prefix: '*' }],
109
109
  # %q{foo *bar},
110
110
  # %q{ ^ location
111
111
  # | ~~~ highlights (0)})
112
- # ```
112
+ # ~~~
113
113
  def assert_diagnoses(diagnostic, code, source_maps='', versions=ALL_VERSIONS)
114
114
  with_versions(code, versions) do |version, parser|
115
115
  source_file = Parser::Source::Buffer.new('(assert_diagnoses)')
data/test/test_lexer.rb CHANGED
@@ -622,9 +622,10 @@ class TestLexer < MiniTest::Unit::TestCase
622
622
  util_lex_token("$`", :tBACK_REF, "$`")
623
623
  end
624
624
 
625
- def test_global_dash_nothing
626
- util_lex_token("$- ", :tGVAR, "$-")
627
- end
625
+ # This was removed in 2.1.
626
+ # def test_global_dash_nothing
627
+ # util_lex_token("$- ", :tGVAR, "$-")
628
+ # end
628
629
 
629
630
  def test_global_dash_something
630
631
  util_lex_token("$-x", :tGVAR, "$-x")
data/test/test_parser.rb CHANGED
@@ -529,6 +529,14 @@ class TestParser < MiniTest::Unit::TestCase
529
529
  %q{~~~~ expression})
530
530
  end
531
531
 
532
+ def test_gvar_dash_empty
533
+ assert_diagnoses(
534
+ [:fatal, :unexpected, { :character => '$' }],
535
+ %q{$- },
536
+ %q{^ location},
537
+ %w(2.1))
538
+ end
539
+
532
540
  def test_back_ref
533
541
  assert_parses(
534
542
  s(:back_ref, :$+),
@@ -1285,6 +1293,7 @@ class TestParser < MiniTest::Unit::TestCase
1285
1293
  s(:nil)),
1286
1294
  %q{module Foo; nil; end},
1287
1295
  %q{~~~~~~ keyword
1296
+ | ~~~ name
1288
1297
  | ~~~ end})
1289
1298
  end
1290
1299
 
@@ -1322,6 +1331,7 @@ class TestParser < MiniTest::Unit::TestCase
1322
1331
  s(:nil)),
1323
1332
  %q{class Foo; nil; end},
1324
1333
  %q{~~~~~ keyword
1334
+ | ~~~ name
1325
1335
  | ~~~ end})
1326
1336
  end
1327
1337
 
@@ -56,6 +56,14 @@ class TestSourceRange < MiniTest::Unit::TestCase
56
56
  assert_equal 5, sr_end.end_pos
57
57
  end
58
58
 
59
+ def test_to_source
60
+ sr = Parser::Source::Range.new(@sfile, 0, 3)
61
+ assert_equal "foo", sr.to_source
62
+
63
+ sr_multi = Parser::Source::Range.new(@sfile, 0, 10)
64
+ assert_equal "foobar\nbaz", sr_multi.to_source
65
+ end
66
+
59
67
  def test_to_s
60
68
  sr = Parser::Source::Range.new(@sfile, 8, 9)
61
69
  assert_equal "(string):2:2", sr.to_s
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.1
4
+ version: 1.3.2
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-09 00:00:00.000000000 Z
11
+ date: 2013-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: github-markup
154
+ name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - '>='
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: yard
168
+ name: kramdown
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - '>='
@@ -200,6 +200,8 @@ files:
200
200
  - doc/AST_FORMAT.md
201
201
  - doc/CUSTOMIZATION.md
202
202
  - doc/INTERNALS.md
203
+ - doc/css/.gitkeep
204
+ - doc/css/common.css
203
205
  - lib/parser.rb
204
206
  - lib/parser/all.rb
205
207
  - lib/parser/ast/node.rb
@@ -306,4 +308,4 @@ test_files:
306
308
  - test/test_source_rewriter.rb
307
309
  - test/test_source_rewriter_action.rb
308
310
  - test/test_static_environment.rb
309
- has_rdoc:
311
+ has_rdoc: yard