parser 2.1.0.pre1 → 2.1.0.pre2

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: 85ff1f420d063d29c4d333d54a120569fd0429e9
4
- data.tar.gz: f7fbd9186d41a3e8ca2561cbb590f8bde8067a6e
3
+ metadata.gz: ada647b43495037cf17844d58832f74d63348d88
4
+ data.tar.gz: 4c4a750b4e696fb5f31f8b6c46718f2d71731651
5
5
  SHA512:
6
- metadata.gz: 40f6351913140cd1b73bf9b2d2ada48dd56ce29dad4e7c08bb347762b5d36a9bac95aa5b2b59c9f46155d35fa2db7e6e3400da72ceabe6d847381d932886e030
7
- data.tar.gz: d1f1581bffe9ebecbd6fa02eaac2125db6ce329203d2d28061361588101b8442ace659f1b53e9a09189a6430506bc3662f323d7bebadef3cf41c2b98eb43634c
6
+ metadata.gz: 69ae3a6286559fa7942af81b631cc1389cb0075f5c683cc460a46f1d3a29a1527f174604dd220c687c4b660e1e4bb409b49ce401f8113d4b5be5481486a3fe12
7
+ data.tar.gz: 94b9c811b9d55d468ecc7de739228fa4c6622eb46bbfb7bdf3b4ef637f566fd2804e459354059b92ae6fb96fa0d2b2d9ffe9980bbf2a35236ac1d86687da985e
@@ -1,6 +1,18 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.1.0.pre2 (2013-11-25)
5
+ ------------------------
6
+
7
+ API modifications:
8
+ * Parser::Diagnostic: expose reason symbolically (closes #115, #116). (Ian MacLeod)
9
+
10
+ vir (2013-11-13)
11
+ ----------------
12
+
13
+ API modifications:
14
+ * lexer.rl: coerce literals to UTF-8 in ASCII-encoded files if they contain \uXXXX (Peter Zotov)
15
+
4
16
  v2.1.0.pre1 (2013-11-12)
5
17
  ------------------------
6
18
 
@@ -16,6 +16,7 @@ end
16
16
  #
17
17
  module Parser
18
18
  require 'parser/version'
19
+ require 'parser/messages'
19
20
 
20
21
  module AST
21
22
  require 'parser/ast/node'
@@ -64,58 +65,6 @@ module Parser
64
65
 
65
66
  require 'parser/rewriter'
66
67
 
67
- ERRORS = {
68
- # Lexer errors
69
- :unicode_point_too_large => 'invalid Unicode codepoint (too large)',
70
- :invalid_escape => 'invalid escape character syntax',
71
- :incomplete_escape => 'incomplete character syntax',
72
- :invalid_hex_escape => 'invalid hex escape',
73
- :invalid_unicode_escape => 'invalid Unicode escape',
74
- :unterminated_unicode => 'unterminated Unicode escape',
75
- :escape_eof => 'escape sequence meets end of file',
76
- :string_eof => 'unterminated string meets end of file',
77
- :regexp_options => 'unknown regexp options: %{options}',
78
- :cvar_name => "`%{name}' is not allowed as a class variable name",
79
- :ivar_name => "`%{name}' is not allowed as an instance variable name",
80
- :trailing_in_number => "trailing `%{character}' in number",
81
- :empty_numeric => 'numeric literal without digits',
82
- :invalid_octal => 'invalid octal digit',
83
- :no_dot_digit_literal => 'no .<digit> floating literal anymore; put 0 before dot',
84
- :bare_backslash => 'bare backslash only allowed before newline',
85
- :unexpected => "unexpected `%{character}'",
86
- :embedded_document => 'embedded document meets end of file (and they embark on a romantic journey)',
87
-
88
- # Lexer warnings
89
- :invalid_escape_use => 'invalid character syntax; use ?%{escape}',
90
- :ambiguous_literal => 'ambiguous first argument; parenthesize arguments or add whitespace to the right',
91
- :ambiguous_prefix => "`%{prefix}' interpreted as argument prefix",
92
-
93
- # Parser errors
94
- :nth_ref_alias => 'cannot define an alias for a back-reference variable',
95
- :begin_in_method => 'BEGIN in method',
96
- :backref_assignment => 'cannot assign to a back-reference variable',
97
- :invalid_assignment => 'cannot assign to a keyword',
98
- :module_name_const => 'class or module name must be a constant literal',
99
- :unexpected_token => 'unexpected token %{token}',
100
- :argument_const => 'formal argument cannot be a constant',
101
- :argument_ivar => 'formal argument cannot be an instance variable',
102
- :argument_gvar => 'formal argument cannot be a global variable',
103
- :argument_cvar => 'formal argument cannot be a class variable',
104
- :duplicate_argument => 'duplicate argument name',
105
- :empty_symbol => 'empty symbol literal',
106
- :odd_hash => 'odd number of entries for a hash',
107
- :singleton_literal => 'cannot define a singleton method for a literal',
108
- :dynamic_const => 'dynamic constant assignment',
109
- :module_in_def => 'module definition in method body',
110
- :class_in_def => 'class definition in method body',
111
- :unexpected_percent_str => '%{type}: unknown type of percent-literal',
112
- :block_and_blockarg => 'both block argument and literal block are passed',
113
- :masgn_as_condition => 'multiple assignment in conditional context',
114
-
115
- # Parser warnings
116
- :useless_else => 'else without rescue is useless',
117
- }.freeze
118
-
119
68
  ##
120
69
  # Verify that the current Ruby implementation supports Encoding.
121
70
  # @raise [RuntimeError]
@@ -235,11 +235,11 @@ module Parser
235
235
  when /^[a-z_]/
236
236
  # OK
237
237
  when /^[A-Z]/
238
- diagnostic :error, :argument_const, name_t
238
+ diagnostic :error, :argument_const, nil, name_t
239
239
  end
240
240
  end
241
241
 
242
- def diagnostic(level, kind, location_t, highlights_ts=[])
242
+ def diagnostic(level, reason, arguments, location_t, highlights_ts=[])
243
243
  _, location = location_t
244
244
 
245
245
  highlights = highlights_ts.map do |token|
@@ -247,9 +247,8 @@ module Parser
247
247
  range
248
248
  end
249
249
 
250
- message = ERRORS[kind]
251
250
  @diagnostics.process(
252
- Diagnostic.new(level, message, location, highlights))
251
+ Diagnostic.new(level, reason, arguments, location, highlights))
253
252
 
254
253
  if level == :error
255
254
  yyerror
@@ -260,9 +259,8 @@ module Parser
260
259
  token_name = token_to_str(error_token_id)
261
260
  _, location = error_value
262
261
 
263
- message = ERRORS[:unexpected_token] % { :token => token_name }
264
- @diagnostics.process(
265
- Diagnostic.new(:error, message, location))
262
+ @diagnostics.process(Diagnostic.new(
263
+ :error, :unexpected_token, { :token => token_name }, location))
266
264
  end
267
265
  end
268
266
 
@@ -146,7 +146,7 @@ module Parser
146
146
  n(:sym, [ str.children.first.to_sym ],
147
147
  collection_map(begin_t, str.loc.expression, end_t))
148
148
  elsif @parser.version == 18 && parts.empty?
149
- diagnostic(:error, ERRORS[:empty_symbol], loc(begin_t).join(loc(end_t)))
149
+ diagnostic :error, :empty_symbol, nil, loc(begin_t).join(loc(end_t))
150
150
  else
151
151
  n(:dsym, [ *parts ],
152
152
  collection_map(begin_t, parts, end_t))
@@ -233,8 +233,7 @@ module Parser
233
233
 
234
234
  def pair_list_18(list)
235
235
  if list.size % 2 != 0
236
- message = ERRORS[:odd_hash]
237
- diagnostic :error, message, list.last.loc.expression
236
+ diagnostic :error, :odd_hash, nil, list.last.loc.expression
238
237
  else
239
238
  list.
240
239
  each_slice(2).map do |key, value|
@@ -390,8 +389,7 @@ module Parser
390
389
 
391
390
  when :const
392
391
  if @parser.in_def?
393
- message = ERRORS[:dynamic_const]
394
- diagnostic :error, message, node.loc.expression
392
+ diagnostic :error, :dynamic_const, nil, node.loc.expression
395
393
  end
396
394
 
397
395
  node.updated(:casgn)
@@ -404,12 +402,10 @@ module Parser
404
402
 
405
403
  when :nil, :self, :true, :false,
406
404
  :__FILE__, :__LINE__, :__ENCODING__
407
- message = ERRORS[:invalid_assignment]
408
- diagnostic :error, message, node.loc.expression
405
+ diagnostic :error, :invalid_assignment, nil, node.loc.expression
409
406
 
410
407
  when :back_ref, :nth_ref
411
- message = ERRORS[:backref_assignment]
412
- diagnostic :error, message, node.loc.expression
408
+ diagnostic :error, :backref_assignment, nil, node.loc.expression
413
409
  end
414
410
  end
415
411
 
@@ -442,8 +438,7 @@ module Parser
442
438
  end
443
439
 
444
440
  when :back_ref, :nth_ref
445
- message = ERRORS[:backref_assignment]
446
- diagnostic :error, message, lhs.loc.expression
441
+ diagnostic :error, :backref_assignment, nil, lhs.loc.expression
447
442
  end
448
443
  end
449
444
 
@@ -497,8 +492,7 @@ module Parser
497
492
  when :int, :str, :dstr, :sym, :dsym,
498
493
  :regexp, :array, :hash
499
494
 
500
- message = ERRORS[:singleton_literal]
501
- diagnostic :error, message, definee.loc.expression
495
+ diagnostic :error, :singleton_literal, nil, definee.loc.expression
502
496
 
503
497
  else
504
498
  n(:defs, [ definee, value(name_t).to_sym, args, body ],
@@ -634,8 +628,7 @@ module Parser
634
628
  last_arg = call_args.last
635
629
 
636
630
  if last_arg && last_arg.type == :block_pass
637
- diagnostic :error, ERRORS[:block_and_blockarg],
638
- last_arg.loc.expression
631
+ diagnostic :error, :block_and_blockarg, nil, last_arg.loc.expression
639
632
  end
640
633
 
641
634
  n(:block, [ method_call, args, body ],
@@ -935,8 +928,7 @@ module Parser
935
928
  def check_condition(cond)
936
929
  case cond.type
937
930
  when :masgn
938
- diagnostic :error, ERRORS[:masgn_as_condition],
939
- cond.loc.expression
931
+ diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
940
932
 
941
933
  when :begin
942
934
  if cond.children.count == 1
@@ -988,7 +980,7 @@ module Parser
988
980
  if that_arg.nil?
989
981
  map[this_name] = this_arg
990
982
  elsif arg_name_collides?(this_name, that_name)
991
- diagnostic :error, ERRORS[:duplicate_argument],
983
+ diagnostic :error, :duplicate_argument, nil,
992
984
  this_arg.loc.name, [ that_arg.loc.name ]
993
985
  end
994
986
 
@@ -1341,9 +1333,9 @@ module Parser
1341
1333
  token[1] if token && token[0]
1342
1334
  end
1343
1335
 
1344
- def diagnostic(type, message, location, highlights=[])
1336
+ def diagnostic(type, reason, arguments, location, highlights=[])
1345
1337
  @parser.diagnostics.process(
1346
- Diagnostic.new(type, message, location, highlights))
1338
+ Diagnostic.new(type, reason, arguments, location, highlights))
1347
1339
 
1348
1340
  if type == :error
1349
1341
  @parser.send :yyerror
@@ -7,6 +7,14 @@ module Parser
7
7
  # @see LEVELS
8
8
  # @return [Symbol] diagnostic level
9
9
  #
10
+ # @!attribute [r] reason
11
+ # @see Parser::MESSAGES
12
+ # @return [Symbol] reason for error
13
+ #
14
+ # @!attribute [r] arguments
15
+ # @see Parser::MESSAGES
16
+ # @return [Symbol] extended arguments that describe the error
17
+ #
10
18
  # @!attribute [r] message
11
19
  # @return [String] error message
12
20
  #
@@ -26,30 +34,40 @@ module Parser
26
34
  #
27
35
  LEVELS = [:note, :warning, :error, :fatal].freeze
28
36
 
29
- attr_reader :level, :message
37
+ attr_reader :level, :reason, :arguments
30
38
  attr_reader :location, :highlights
31
39
 
32
40
  ##
33
41
  # @param [Symbol] level
34
- # @param [String] message
42
+ # @param [Symbol] reason
43
+ # @param [Hash] arguments
35
44
  # @param [Parser::Source::Range] location
36
45
  # @param [Array<Parser::Source::Range>] highlights
37
46
  #
38
- def initialize(level, message, location, highlights=[])
47
+ def initialize(level, reason, arguments, location, highlights=[])
39
48
  unless LEVELS.include?(level)
40
49
  raise ArgumentError,
41
50
  "Diagnostic#level must be one of #{LEVELS.join(', ')}; " \
42
51
  "#{level.inspect} provided."
43
52
  end
53
+ raise 'Expected a location' unless location
44
54
 
45
55
  @level = level
46
- @message = message.to_s.dup.freeze
56
+ @reason = reason
57
+ @arguments = (arguments || {}).dup.freeze
47
58
  @location = location
48
59
  @highlights = highlights.dup.freeze
49
60
 
50
61
  freeze
51
62
  end
52
63
 
64
+ ##
65
+ # @return [String] the rendered message.
66
+ #
67
+ def message
68
+ MESSAGES[@reason] % @arguments
69
+ end
70
+
53
71
  ##
54
72
  # Renders the diagnostic message as a clang-like diagnostic.
55
73
  #
@@ -76,7 +94,7 @@ module Parser
76
94
  highlight_line[range] = '^' * @location.size
77
95
 
78
96
  [
79
- "#{@location.to_s}: #{@level}: #{@message}",
97
+ "#{@location.to_s}: #{@level}: #{message}",
80
98
  source_line,
81
99
  highlight_line,
82
100
  ]
@@ -13,9 +13,10 @@ module Parser
13
13
  # end
14
14
  #
15
15
  # engine = Parser::Diagnostic::Engine.new(consumer)
16
- # diagnostic = Parser::Diagnostic.new(:warning, 'warning!', buffer, 1..2)
16
+ # diagnostic = Parser::Diagnostic.new(
17
+ # :warning, :unexpected_token, { :token => 'abc' }, buffer, 1..2)
17
18
  #
18
- # engine.process(diagnostic) # => "warning!"
19
+ # engine.process(diagnostic) # => "unexpected token abc"
19
20
  #
20
21
  # @api public
21
22
  #
@@ -348,9 +348,9 @@ class Parser::Lexer
348
348
  nil
349
349
  end
350
350
 
351
- def diagnostic(type, message, location=range, highlights=[])
351
+ def diagnostic(type, reason, arguments=nil, location=range, highlights=[])
352
352
  @diagnostics.process(
353
- Parser::Diagnostic.new(type, message, location, highlights))
353
+ Parser::Diagnostic.new(type, reason, arguments, location, highlights))
354
354
  end
355
355
 
356
356
  #
@@ -622,7 +622,7 @@ class Parser::Lexer
622
622
 
623
623
  if codepoint >= 0x110000
624
624
  @escape = lambda do
625
- diagnostic :error, Parser::ERRORS[:unicode_point_too_large],
625
+ diagnostic :error, :unicode_point_too_large, nil,
626
626
  range(codepoint_s, codepoint_s + codepoint_str.length)
627
627
  end
628
628
 
@@ -644,7 +644,7 @@ class Parser::Lexer
644
644
 
645
645
  action invalid_complex_escape {
646
646
  @escape = lambda do
647
- diagnostic :error, Parser::ERRORS[:invalid_escape]
647
+ diagnostic :error, :invalid_escape
648
648
  end
649
649
  }
650
650
 
@@ -684,7 +684,7 @@ class Parser::Lexer
684
684
  | 'x' ( c_any - xdigit )
685
685
  % {
686
686
  @escape = lambda do
687
- diagnostic :error, Parser::ERRORS[:invalid_hex_escape],
687
+ diagnostic :error, :invalid_hex_escape, nil,
688
688
  range(@escape_s - 1, p + 2)
689
689
  end
690
690
  }
@@ -699,7 +699,7 @@ class Parser::Lexer
699
699
  )
700
700
  % {
701
701
  @escape = lambda do
702
- diagnostic :error, Parser::ERRORS[:invalid_unicode_escape],
702
+ diagnostic :error, :invalid_unicode_escape, nil,
703
703
  range(@escape_s - 1, p)
704
704
  end
705
705
  }
@@ -713,7 +713,7 @@ class Parser::Lexer
713
713
  | xdigit{7,}
714
714
  ) % {
715
715
  @escape = lambda do
716
- diagnostic :fatal, Parser::ERRORS[:unterminated_unicode],
716
+ diagnostic :fatal, :unterminated_unicode, nil,
717
717
  range(p - 1, p)
718
718
  end
719
719
  }
@@ -741,8 +741,7 @@ class Parser::Lexer
741
741
  | ( c_any - [0-7xuCMc] ) %unescape_char
742
742
 
743
743
  | c_eof % {
744
- diagnostic :fatal, Parser::ERRORS[:escape_eof],
745
- range(p - 1, p)
744
+ diagnostic :fatal, :escape_eof, nil, range(p - 1, p)
746
745
  }
747
746
  );
748
747
 
@@ -856,7 +855,7 @@ class Parser::Lexer
856
855
  # has to handle such case specially.
857
856
  action extend_string_eol {
858
857
  if @te == pe
859
- diagnostic :fatal, Parser::ERRORS[:string_eof],
858
+ diagnostic :fatal, :string_eof, nil,
860
859
  range(literal.str_s, literal.str_s + 1)
861
860
  end
862
861
 
@@ -1031,8 +1030,8 @@ class Parser::Lexer
1031
1030
  => {
1032
1031
  unknown_options = tok.scan(/[^imxouesn]/)
1033
1032
  if unknown_options.any?
1034
- message = Parser::ERRORS[:regexp_options] % { :options => unknown_options.join }
1035
- diagnostic :error, message
1033
+ diagnostic :error, :regexp_options,
1034
+ { :options => unknown_options.join }
1036
1035
  end
1037
1036
 
1038
1037
  emit(:tREGEXP_OPT)
@@ -1183,8 +1182,7 @@ class Parser::Lexer
1183
1182
  class_var_v
1184
1183
  => {
1185
1184
  if tok =~ /^@@[0-9]/
1186
- message = Parser::ERRORS[:cvar_name] % { :name => tok }
1187
- diagnostic :error, message
1185
+ diagnostic :error, :cvar_name, { :name => tok }
1188
1186
  end
1189
1187
 
1190
1188
  emit(:tCVAR)
@@ -1194,8 +1192,7 @@ class Parser::Lexer
1194
1192
  instance_var_v
1195
1193
  => {
1196
1194
  if tok =~ /^@[0-9]/
1197
- message = Parser::ERRORS[:ivar_name] % { :name => tok }
1198
- diagnostic :error, message
1195
+ diagnostic :error, :ivar_name, { :name => tok }
1199
1196
  end
1200
1197
 
1201
1198
  emit(:tIVAR)
@@ -1369,8 +1366,7 @@ class Parser::Lexer
1369
1366
  # Ambiguous regexp literal.
1370
1367
  w_space+ '/'
1371
1368
  => {
1372
- diagnostic :warning, Parser::ERRORS[:ambiguous_literal],
1373
- range(@te - 1, @te)
1369
+ diagnostic :warning, :ambiguous_literal, nil, range(@te - 1, @te)
1374
1370
 
1375
1371
  fhold; fgoto expr_beg;
1376
1372
  };
@@ -1379,8 +1375,7 @@ class Parser::Lexer
1379
1375
  # Ambiguous splat, kwsplat or block-pass.
1380
1376
  w_space+ %{ tm = p } ( '+' | '-' | '*' | '&' | '**' )
1381
1377
  => {
1382
- message = Parser::ERRORS[:ambiguous_prefix] % { :prefix => tok(tm, @te) }
1383
- diagnostic :warning, message,
1378
+ diagnostic :warning, :ambiguous_prefix, { :prefix => tok(tm, @te) },
1384
1379
  range(tm, @te)
1385
1380
 
1386
1381
  p = tm - 1
@@ -1581,8 +1576,7 @@ class Parser::Lexer
1581
1576
 
1582
1577
  '%' c_eof
1583
1578
  => {
1584
- diagnostic :fatal, Parser::ERRORS[:string_eof],
1585
- range(@ts, @ts + 1)
1579
+ diagnostic :fatal, :string_eof, nil, range(@ts, @ts + 1)
1586
1580
  };
1587
1581
 
1588
1582
  # Heredoc start.
@@ -1660,8 +1654,7 @@ class Parser::Lexer
1660
1654
  => {
1661
1655
  escape = { " " => '\s', "\r" => '\r', "\n" => '\n', "\t" => '\t',
1662
1656
  "\v" => '\v', "\f" => '\f' }[tok[1]]
1663
- message = Parser::ERRORS[:invalid_escape_use] % { :escape => escape }
1664
- diagnostic :warning, message, range
1657
+ diagnostic :warning, :invalid_escape_use, { :escape => escape }, range
1665
1658
 
1666
1659
  p = @ts - 1
1667
1660
  fgoto expr_end;
@@ -1669,8 +1662,7 @@ class Parser::Lexer
1669
1662
 
1670
1663
  '?' c_eof
1671
1664
  => {
1672
- diagnostic :fatal, Parser::ERRORS[:incomplete_escape],
1673
- range(@ts, @ts + 1)
1665
+ diagnostic :fatal, :incomplete_escape, nil, range(@ts, @ts + 1)
1674
1666
  };
1675
1667
 
1676
1668
  # f ?aa : b: Disambiguate with a character literal.
@@ -1914,16 +1906,16 @@ class Parser::Lexer
1914
1906
  digits = tok(@num_digits_s, @num_suffix_s)
1915
1907
 
1916
1908
  if digits.end_with? '_'
1917
- diagnostic :error, Parser::ERRORS[:trailing_in_number] % { :character => '_' },
1909
+ diagnostic :error, :trailing_in_number, { :character => '_' },
1918
1910
  range(@te - 1, @te)
1919
1911
  elsif digits.empty? && @num_base == 8 && version?(18)
1920
1912
  # 1.8 did not raise an error on 0o.
1921
1913
  digits = "0"
1922
1914
  elsif digits.empty?
1923
- diagnostic :error, Parser::ERRORS[:empty_numeric]
1915
+ diagnostic :error, :empty_numeric
1924
1916
  elsif @num_base == 8 && (invalid_idx = digits.index(/[89]/))
1925
1917
  invalid_s = @num_digits_s + invalid_idx
1926
- diagnostic :error, Parser::ERRORS[:invalid_octal],
1918
+ diagnostic :error, :invalid_octal, nil,
1927
1919
  range(invalid_s, invalid_s + 1)
1928
1920
  end
1929
1921
 
@@ -1938,14 +1930,14 @@ class Parser::Lexer
1938
1930
 
1939
1931
  flo_frac flo_pow?
1940
1932
  => {
1941
- diagnostic :error, Parser::ERRORS[:no_dot_digit_literal]
1933
+ diagnostic :error, :no_dot_digit_literal
1942
1934
  };
1943
1935
 
1944
1936
  flo_int [eE]
1945
1937
  => {
1946
1938
  if version?(18, 19, 20)
1947
1939
  diagnostic :error,
1948
- Parser::ERRORS[:trailing_in_number] % { :character => tok(@te - 1, @te) },
1940
+ :trailing_in_number, { :character => tok(@te - 1, @te) },
1949
1941
  range(@te - 1, @te)
1950
1942
  else
1951
1943
  emit(:tINTEGER, tok(@ts, @te - 1).to_i)
@@ -1957,7 +1949,7 @@ class Parser::Lexer
1957
1949
  => {
1958
1950
  if version?(18, 19, 20)
1959
1951
  diagnostic :error,
1960
- Parser::ERRORS[:trailing_in_number] % { :character => tok(@te - 1, @te) },
1952
+ :trailing_in_number, { :character => tok(@te - 1, @te) },
1961
1953
  range(@te - 1, @te)
1962
1954
  else
1963
1955
  emit(:tFLOAT, tok(@ts, @te - 1).to_f)
@@ -2078,15 +2070,13 @@ class Parser::Lexer
2078
2070
  fnext expr_value; fbreak; };
2079
2071
 
2080
2072
  '\\' c_line {
2081
- diagnostic :error, Parser::ERRORS[:bare_backslash],
2082
- range(@ts, @ts + 1)
2073
+ diagnostic :error, :bare_backslash, nil, range(@ts, @ts + 1)
2083
2074
  fhold;
2084
2075
  };
2085
2076
 
2086
2077
  c_any
2087
2078
  => {
2088
- message = Parser::ERRORS[:unexpected] % { :character => tok.inspect[1..-2] }
2089
- diagnostic :fatal, message
2079
+ diagnostic :fatal, :unexpected, { :character => tok.inspect[1..-2] }
2090
2080
  };
2091
2081
 
2092
2082
  c_eof => do_eof;
@@ -2120,7 +2110,7 @@ class Parser::Lexer
2120
2110
 
2121
2111
  c_line* zlen
2122
2112
  => {
2123
- diagnostic :fatal, Parser::ERRORS[:embedded_document],
2113
+ diagnostic :fatal, :embedded_document, nil,
2124
2114
  range(@eq_begin_s, @eq_begin_s + '=begin'.length)
2125
2115
  };
2126
2116
  *|;