rdoc 5.1.0 → 6.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

@@ -45,6 +45,7 @@ class RDoc::RubyLex
45
45
 
46
46
  attr_accessor :continue
47
47
  attr_accessor :lex_state
48
+ attr_accessor :first_in_method_statement
48
49
  attr_reader :reader
49
50
 
50
51
  class << self
@@ -106,10 +107,15 @@ class RDoc::RubyLex
106
107
  @rests = []
107
108
  @seek = 0
108
109
 
110
+ @heredoc_queue = []
111
+
109
112
  @indent = 0
110
113
  @indent_stack = []
111
114
  @lex_state = :EXPR_BEG
112
115
  @space_seen = false
116
+ @escaped_nl = false
117
+ @first_in_method_statement = false
118
+ @after_question = false
113
119
 
114
120
  @continue = false
115
121
  @line = ""
@@ -350,6 +356,7 @@ class RDoc::RubyLex
350
356
  begin
351
357
  tk = @OP.match(self)
352
358
  @space_seen = tk.kind_of?(TkSPACE)
359
+ @first_in_method_statement = false if !@space_seen && @first_in_method_statement
353
360
  rescue SyntaxError => e
354
361
  raise Error, "syntax error: #{e.message}" if
355
362
  @exception_on_syntax_error
@@ -361,6 +368,28 @@ class RDoc::RubyLex
361
368
  if @readed_auto_clean_up
362
369
  get_readed
363
370
  end
371
+
372
+ if TkSYMBEG === tk then
373
+ tk1 = token
374
+ set_token_position tk.seek, tk.line_no, tk.char_no
375
+
376
+ case tk1
377
+ when TkId, TkOp, TkSTRING, TkDSTRING, TkSTAR, TkAMPER then
378
+ if tk1.respond_to?(:name) then
379
+ tk = Token(TkSYMBOL, ":" + tk1.name)
380
+ else
381
+ tk = Token(TkSYMBOL, ":" + tk1.text)
382
+ end
383
+ else
384
+ tk = tk1
385
+ end
386
+ elsif (TkPLUS === tk or TkMINUS === tk) and peek(0) =~ /\d/ then
387
+ tk1 = token
388
+ set_token_position tk.seek, tk.line_no, tk.char_no
389
+ tk = Token(tk1.class, tk.text + tk1.text)
390
+ end
391
+ @after_question = false if @after_question and !(TkQUESTION === tk)
392
+
364
393
  # Tracer.off
365
394
  tk
366
395
  end
@@ -380,7 +409,9 @@ class RDoc::RubyLex
380
409
  "r" => "/",
381
410
  "w" => "]",
382
411
  "W" => "]",
383
- "s" => ":"
412
+ "s" => ":",
413
+ "i" => "]",
414
+ "I" => "]"
384
415
  }
385
416
 
386
417
  PERCENT_PAREN = {
@@ -430,15 +461,18 @@ class RDoc::RubyLex
430
461
  proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
431
462
  |op, io|
432
463
  @ltype = "="
433
- res = ''
434
- nil until getc == "\n"
464
+ res = op
465
+ until (ch = getc) == "\n" do
466
+ res << ch
467
+ end
468
+ res << ch
435
469
 
436
470
  until ( peek_equal?("=end") && peek(4) =~ /\s/ ) do
437
471
  (ch = getc)
438
472
  res << ch
439
473
  end
440
474
 
441
- gets # consume =end
475
+ res << gets # consume =end
442
476
 
443
477
  @ltype = nil
444
478
  Token(TkRD_COMMENT, res)
@@ -446,42 +480,90 @@ class RDoc::RubyLex
446
480
 
447
481
  @OP.def_rule("\n") do |op, io|
448
482
  print "\\n\n" if RDoc::RubyLex.debug?
483
+ unless @heredoc_queue.empty?
484
+ info = @heredoc_queue[0]
485
+ if !info[:started] # "\n"
486
+ info[:started] = true
487
+ ungetc "\n"
488
+ elsif info[:heredoc_end].nil? # heredoc body
489
+ tk, heredoc_end = identify_here_document_body(info[:quoted], info[:lt], info[:indent])
490
+ info[:heredoc_end] = heredoc_end
491
+ ungetc "\n"
492
+ else # heredoc end
493
+ @heredoc_queue.shift
494
+ @lex_state = :EXPR_BEG
495
+ tk = Token(TkHEREDOCEND, info[:heredoc_end])
496
+ if !@heredoc_queue.empty?
497
+ @heredoc_queue[0][:started] = true
498
+ ungetc "\n"
499
+ end
500
+ end
501
+ end
502
+ unless tk
503
+ case @lex_state
504
+ when :EXPR_BEG, :EXPR_FNAME, :EXPR_DOT
505
+ @continue = true
506
+ else
507
+ @continue = false
508
+ @lex_state = :EXPR_BEG unless @escaped_nl
509
+ until (@indent_stack.empty? ||
510
+ [TkLPAREN, TkLBRACK, TkLBRACE,
511
+ TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
512
+ @indent_stack.pop
513
+ end
514
+ end
515
+ @current_readed = @readed
516
+ @here_readed.clear
517
+ tk = Token(TkNL)
518
+ end
519
+ @escaped_nl = false
520
+ tk
521
+ end
522
+
523
+ @OP.def_rules("=") do
524
+ |op, io|
449
525
  case @lex_state
450
- when :EXPR_BEG, :EXPR_FNAME, :EXPR_DOT
451
- @continue = true
526
+ when :EXPR_FNAME, :EXPR_DOT
527
+ @lex_state = :EXPR_ARG
452
528
  else
453
- @continue = false
454
529
  @lex_state = :EXPR_BEG
455
- until (@indent_stack.empty? ||
456
- [TkLPAREN, TkLBRACK, TkLBRACE,
457
- TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
458
- @indent_stack.pop
459
- end
460
530
  end
461
- @current_readed = @readed
462
- @here_readed.clear
463
- Token(TkNL)
531
+ Token(op)
464
532
  end
465
533
 
466
534
  @OP.def_rules("*", "**",
467
- "=", "==", "===",
535
+ "==", "===",
468
536
  "=~", "<=>",
469
537
  "<", "<=",
470
- ">", ">=", ">>") do
538
+ ">", ">=", ">>", "=>") do
471
539
  |op, io|
472
540
  case @lex_state
473
541
  when :EXPR_FNAME, :EXPR_DOT
542
+ tk = Token(TkId, op)
474
543
  @lex_state = :EXPR_ARG
475
544
  else
545
+ tk = Token(op)
476
546
  @lex_state = :EXPR_BEG
477
547
  end
548
+ tk
549
+ end
550
+
551
+ @OP.def_rules("->") do
552
+ |op, io|
553
+ @lex_state = :EXPR_ENDFN
478
554
  Token(op)
479
555
  end
480
556
 
481
557
  @OP.def_rules("!", "!=", "!~") do
482
558
  |op, io|
483
- @lex_state = :EXPR_BEG
484
- Token(op)
559
+ case @lex_state
560
+ when :EXPR_FNAME, :EXPR_DOT
561
+ @lex_state = :EXPR_ARG
562
+ Token(TkId, op)
563
+ else
564
+ @lex_state = :EXPR_BEG
565
+ Token(op)
566
+ end
485
567
  end
486
568
 
487
569
  @OP.def_rules("<<") do
@@ -490,16 +572,17 @@ class RDoc::RubyLex
490
572
  if @lex_state != :EXPR_END && @lex_state != :EXPR_CLASS &&
491
573
  (@lex_state != :EXPR_ARG || @space_seen)
492
574
  c = peek(0)
493
- if /\S/ =~ c && (/["'`]/ =~ c || /\w/ =~ c || c == "-")
494
- tk = identify_here_document
575
+ if /\S/ =~ c && (/["'`]/ =~ c || /\w/ =~ c || c == "-" || c == "~")
576
+ tk = identify_here_document(op)
495
577
  end
496
578
  end
497
579
  unless tk
498
- tk = Token(op)
499
580
  case @lex_state
500
581
  when :EXPR_FNAME, :EXPR_DOT
582
+ tk = Token(TkId, op)
501
583
  @lex_state = :EXPR_ARG
502
584
  else
585
+ tk = Token(op)
503
586
  @lex_state = :EXPR_BEG
504
587
  end
505
588
  end
@@ -513,9 +596,9 @@ class RDoc::RubyLex
513
596
 
514
597
  @OP.def_rules("`") do
515
598
  |op, io|
516
- if @lex_state == :EXPR_FNAME
517
- @lex_state = :EXPR_END
518
- Token(op)
599
+ if :EXPR_FNAME == @lex_state or :EXPR_DOT == @lex_state
600
+ @lex_state = :EXPR_ARG
601
+ Token(TkId, op)
519
602
  else
520
603
  identify_string(op)
521
604
  end
@@ -525,6 +608,7 @@ class RDoc::RubyLex
525
608
  |op, io|
526
609
  if @lex_state == :EXPR_END
527
610
  @lex_state = :EXPR_BEG
611
+ @after_question = true
528
612
  Token(TkQUESTION)
529
613
  else
530
614
  ch = getc
@@ -534,17 +618,31 @@ class RDoc::RubyLex
534
618
  Token(TkQUESTION)
535
619
  else
536
620
  @lex_state = :EXPR_END
621
+ ch << getc if "\\" == ch
537
622
  Token(TkCHAR, "?#{ch}")
538
623
  end
539
624
  end
540
625
  end
541
626
 
542
- @OP.def_rules("&", "&&", "|", "||") do
627
+ @OP.def_rules("&&", "||") do
543
628
  |op, io|
544
629
  @lex_state = :EXPR_BEG
545
630
  Token(op)
546
631
  end
547
632
 
633
+ @OP.def_rules("&", "|") do
634
+ |op, io|
635
+ case @lex_state
636
+ when :EXPR_FNAME, :EXPR_DOT
637
+ tk = Token(TkId, op)
638
+ @lex_state = :EXPR_ARG
639
+ else
640
+ tk = Token(op)
641
+ @lex_state = :EXPR_BEG
642
+ end
643
+ tk
644
+ end
645
+
548
646
  @OP.def_rules("+=", "-=", "*=", "**=",
549
647
  "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
550
648
  |op, io|
@@ -556,19 +654,22 @@ class RDoc::RubyLex
556
654
  @OP.def_rule("+@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
557
655
  |op, io|
558
656
  @lex_state = :EXPR_ARG
559
- Token(op)
657
+ Token(TkId, op)
560
658
  end
561
659
 
562
660
  @OP.def_rule("-@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
563
661
  |op, io|
564
662
  @lex_state = :EXPR_ARG
565
- Token(op)
663
+ Token(TkId, op)
566
664
  end
567
665
 
568
666
  @OP.def_rules("+", "-") do
569
667
  |op, io|
570
668
  catch(:RET) do
571
- if @lex_state == :EXPR_ARG
669
+ if :EXPR_FNAME == @lex_state or :EXPR_DOT == @lex_state
670
+ tk = Token(TkId, op)
671
+ @lex_state = :EXPR_ARG
672
+ elsif @lex_state == :EXPR_ARG
572
673
  if @space_seen and peek(0) =~ /[0-9]/
573
674
  throw :RET, identify_number(op)
574
675
  else
@@ -579,20 +680,21 @@ class RDoc::RubyLex
579
680
  else
580
681
  @lex_state = :EXPR_BEG
581
682
  end
582
- Token(op)
683
+ tk = Token(op) unless tk
684
+ tk
583
685
  end
584
686
  end
585
687
 
586
- @OP.def_rule(".") do
688
+ @OP.def_rules(".", "&.") do
587
689
  |op, io|
588
690
  @lex_state = :EXPR_BEG
589
691
  if peek(0) =~ /[0-9]/
590
692
  ungetc
591
693
  identify_number
592
694
  else
593
- # for "obj.if" etc.
695
+ # for "obj.if" or "obj&.if" etc.
594
696
  @lex_state = :EXPR_DOT
595
- Token(TkDOT)
697
+ Token(op)
596
698
  end
597
699
  end
598
700
 
@@ -639,7 +741,10 @@ class RDoc::RubyLex
639
741
 
640
742
  @OP.def_rule("/") do
641
743
  |op, io|
642
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
744
+ if :EXPR_FNAME == @lex_state or :EXPR_DOT == @lex_state
745
+ @lex_state = :EXPR_ARG
746
+ Token(TkId, op)
747
+ elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID || @first_in_method_statement
643
748
  identify_string(op)
644
749
  elsif peek(0) == '='
645
750
  getc
@@ -655,8 +760,15 @@ class RDoc::RubyLex
655
760
 
656
761
  @OP.def_rules("^") do
657
762
  |op, io|
658
- @lex_state = :EXPR_BEG
659
- Token("^")
763
+ case @lex_state
764
+ when :EXPR_FNAME, :EXPR_DOT
765
+ tk = Token(TkId, op)
766
+ @lex_state = :EXPR_ARG
767
+ else
768
+ tk = Token(op)
769
+ @lex_state = :EXPR_BEG
770
+ end
771
+ tk
660
772
  end
661
773
 
662
774
  # @OP.def_rules("^=") do
@@ -683,8 +795,14 @@ class RDoc::RubyLex
683
795
 
684
796
  @OP.def_rule("~") do
685
797
  |op, io|
686
- @lex_state = :EXPR_BEG
687
- Token("~")
798
+ case @lex_state
799
+ when :EXPR_FNAME, :EXPR_DOT
800
+ @lex_state = :EXPR_ARG
801
+ Token(TkId, op)
802
+ else
803
+ @lex_state = :EXPR_BEG
804
+ Token(op)
805
+ end
688
806
  end
689
807
 
690
808
  @OP.def_rule("~@", proc{|op, io| @lex_state == :EXPR_FNAME}) do
@@ -710,17 +828,18 @@ class RDoc::RubyLex
710
828
  @OP.def_rule("[]", proc{|op, io| @lex_state == :EXPR_FNAME}) do
711
829
  |op, io|
712
830
  @lex_state = :EXPR_ARG
713
- Token("[]")
831
+ Token(TkId, op)
714
832
  end
715
833
 
716
834
  @OP.def_rule("[]=", proc{|op, io| @lex_state == :EXPR_FNAME}) do
717
835
  |op, io|
718
836
  @lex_state = :EXPR_ARG
719
- Token("[]=")
837
+ Token(TkId, op)
720
838
  end
721
839
 
722
840
  @OP.def_rule("[") do
723
841
  |op, io|
842
+ text = nil
724
843
  @indent += 1
725
844
  if @lex_state == :EXPR_FNAME
726
845
  tk_c = TkfLBRACK
@@ -729,13 +848,25 @@ class RDoc::RubyLex
729
848
  tk_c = TkLBRACK
730
849
  elsif @lex_state == :EXPR_ARG && @space_seen
731
850
  tk_c = TkLBRACK
851
+ elsif @lex_state == :EXPR_DOT
852
+ if peek(0) == "]"
853
+ tk_c = TkIDENTIFIER
854
+ getc
855
+ if peek(0) == "="
856
+ text = "[]="
857
+ else
858
+ text = "[]"
859
+ end
860
+ else
861
+ tk_c = TkOp
862
+ end
732
863
  else
733
864
  tk_c = TkfLBRACK
734
865
  end
735
866
  @lex_state = :EXPR_BEG
736
867
  end
737
868
  @indent_stack.push tk_c
738
- Token(tk_c)
869
+ Token(tk_c, text)
739
870
  end
740
871
 
741
872
  @OP.def_rule("{") do
@@ -753,23 +884,25 @@ class RDoc::RubyLex
753
884
 
754
885
  @OP.def_rule('\\') do
755
886
  |op, io|
756
- if getc == "\n"
887
+ if peek(0) == "\n"
757
888
  @space_seen = true
758
889
  @continue = true
759
- Token(TkSPACE)
760
- else
761
- ungetc
762
- Token("\\")
890
+ @escaped_nl = true
763
891
  end
892
+ Token("\\")
764
893
  end
765
894
 
766
895
  @OP.def_rule('%') do
767
896
  |op, io|
768
- if @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
897
+ if :EXPR_FNAME == @lex_state or :EXPR_DOT == @lex_state
898
+ @lex_state = :EXPR_ARG
899
+ Token(TkId, op)
900
+ elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_MID
769
901
  identify_quotation
770
902
  elsif peek(0) == '='
771
903
  getc
772
- Token(TkOPASGN, :%)
904
+ @lex_state = :EXPR_BEG
905
+ Token(TkOPASGN, '%')
773
906
  elsif @lex_state == :EXPR_ARG and @space_seen and peek(0) !~ /\s/
774
907
  identify_quotation
775
908
  else
@@ -871,7 +1004,7 @@ class RDoc::RubyLex
871
1004
 
872
1005
  ungetc
873
1006
 
874
- if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
1007
+ if ((ch == "!" && peek(1) != "=") || ch == "?") && token[0,1] =~ /\w/
875
1008
  token.concat getc
876
1009
  end
877
1010
 
@@ -944,44 +1077,63 @@ class RDoc::RubyLex
944
1077
  @lex_state = :EXPR_END
945
1078
  end
946
1079
  end
1080
+ if token_c.ancestors.include?(TkId) and peek(0) == ':' and !peek_match?(/^::/)
1081
+ token.concat getc
1082
+ token_c = TkSYMBOL
1083
+ end
947
1084
  return Token(token_c, token)
948
1085
  end
949
1086
  end
950
1087
 
951
1088
  if @lex_state == :EXPR_FNAME
952
1089
  @lex_state = :EXPR_END
953
- if peek(0) == '='
1090
+ if peek(0) == '=' and peek(1) != '>'
954
1091
  token.concat getc
955
1092
  end
956
1093
  elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||
957
- @lex_state == :EXPR_ARG
1094
+ @lex_state == :EXPR_ARG || @lex_state == :EXPR_MID
958
1095
  @lex_state = :EXPR_ARG
959
1096
  else
960
1097
  @lex_state = :EXPR_END
961
1098
  end
962
1099
 
963
1100
  if token[0, 1] =~ /[A-Z]/
964
- return Token(TkCONSTANT, token)
1101
+ if token[-1] =~ /[!?]/
1102
+ token_c = TkIDENTIFIER
1103
+ else
1104
+ token_c = TkCONSTANT
1105
+ end
965
1106
  elsif token[token.size - 1, 1] =~ /[!?]/
966
- return Token(TkFID, token)
1107
+ token_c = TkFID
1108
+ else
1109
+ token_c = TkIDENTIFIER
1110
+ end
1111
+ if peek(0) == ':' and !peek_match?(/^::/)
1112
+ token.concat getc
1113
+ return Token(TkSYMBOL, token)
967
1114
  else
968
- return Token(TkIDENTIFIER, token)
1115
+ return Token(token_c, token)
969
1116
  end
970
1117
  end
971
1118
 
972
- def identify_here_document
1119
+ def identify_here_document(op)
973
1120
  ch = getc
1121
+ start_token = op
974
1122
  # if lt = PERCENT_LTYPE[ch]
975
- if ch == "-"
1123
+ if ch == "-" or ch == "~"
1124
+ start_token.concat ch
976
1125
  ch = getc
977
1126
  indent = true
978
1127
  end
979
1128
  if /['"`]/ =~ ch
1129
+ start_token.concat ch
980
1130
  user_quote = lt = ch
981
1131
  quoted = ""
982
1132
  while (c = getc) && c != lt
983
1133
  quoted.concat c
984
1134
  end
1135
+ start_token.concat quoted
1136
+ start_token.concat lt
985
1137
  else
986
1138
  user_quote = nil
987
1139
  lt = '"'
@@ -989,57 +1141,38 @@ class RDoc::RubyLex
989
1141
  while (c = getc) && c =~ /\w/
990
1142
  quoted.concat c
991
1143
  end
1144
+ start_token.concat quoted
992
1145
  ungetc
993
1146
  end
994
1147
 
995
- ltback, @ltype = @ltype, lt
996
- reserve = []
997
- while ch = getc
998
- reserve.push ch
999
- if ch == "\\"
1000
- reserve.push ch = getc
1001
- elsif ch == "\n"
1002
- break
1003
- end
1004
- end
1005
-
1006
- output_heredoc = reserve.join =~ /\A\r?\n\z/
1148
+ @heredoc_queue << {
1149
+ quoted: quoted,
1150
+ lt: lt,
1151
+ indent: indent,
1152
+ started: false
1153
+ }
1154
+ @lex_state = :EXPR_END
1155
+ Token(RDoc::RubyLex::TkHEREDOCBEG, start_token)
1156
+ end
1007
1157
 
1008
- if output_heredoc then
1009
- doc = '<<'
1010
- doc << '-' if indent
1011
- doc << "#{user_quote}#{quoted}#{user_quote}\n"
1012
- else
1013
- doc = '"'
1014
- end
1158
+ def identify_here_document_body(quoted, lt, indent)
1159
+ ltback, @ltype = @ltype, lt
1015
1160
 
1016
- @current_readed = @readed
1161
+ doc = ""
1162
+ heredoc_end = nil
1017
1163
  while l = gets
1018
1164
  l = l.sub(/(:?\r)?\n\z/, "\n")
1019
1165
  if (indent ? l.strip : l.chomp) == quoted
1166
+ heredoc_end = l
1020
1167
  break
1021
1168
  end
1022
1169
  doc << l
1023
1170
  end
1171
+ raise Error, "Missing terminating #{quoted} for string" unless heredoc_end
1024
1172
 
1025
- if output_heredoc then
1026
- raise Error, "Missing terminating #{quoted} for string" unless l
1027
-
1028
- doc << l.chomp
1029
- else
1030
- doc << '"'
1031
- end
1032
-
1033
- @current_readed = @here_readed
1034
- @here_readed.concat reserve
1035
- while ch = reserve.pop
1036
- ungetc ch
1037
- end
1038
-
1039
- token_class = output_heredoc ? RDoc::RubyLex::TkHEREDOC : Ltype2Token[lt]
1040
1173
  @ltype = ltback
1041
- @lex_state = :EXPR_END
1042
- Token(token_class, doc)
1174
+ @lex_state = :EXPR_BEG
1175
+ [Token(RDoc::RubyLex::TkHEREDOC, doc), heredoc_end]
1043
1176
  end
1044
1177
 
1045
1178
  def identify_quotation
@@ -1066,7 +1199,7 @@ class RDoc::RubyLex
1066
1199
 
1067
1200
  num = op
1068
1201
 
1069
- if peek(0) == "0" && peek(1) !~ /[.eE]/
1202
+ if peek(0) == "0" && peek(1) !~ /[.eEri]/
1070
1203
  num << getc
1071
1204
 
1072
1205
  case peek(0)
@@ -1125,6 +1258,7 @@ class RDoc::RubyLex
1125
1258
  type = TkINTEGER
1126
1259
  allow_point = true
1127
1260
  allow_e = true
1261
+ allow_ri = true
1128
1262
  non_digit = false
1129
1263
  while ch = getc
1130
1264
  num << ch
@@ -1154,8 +1288,25 @@ class RDoc::RubyLex
1154
1288
  num << getc
1155
1289
  end
1156
1290
  allow_e = false
1291
+ allow_ri = false
1157
1292
  allow_point = false
1158
1293
  non_digit = ch
1294
+ when allow_ri && "r"
1295
+ if non_digit
1296
+ raise Error, "trailing `#{non_digit}' in number"
1297
+ end
1298
+ type = TkRATIONAL
1299
+ if peek(0) == 'i'
1300
+ type = TkIMAGINARY
1301
+ num << getc
1302
+ end
1303
+ break
1304
+ when allow_ri && "i"
1305
+ if non_digit && non_digit != "r"
1306
+ raise Error, "trailing `#{non_digit}' in number"
1307
+ end
1308
+ type = TkIMAGINARY
1309
+ break
1159
1310
  else
1160
1311
  if non_digit
1161
1312
  raise Error, "trailing `#{non_digit}' in number"
@@ -1174,10 +1325,10 @@ class RDoc::RubyLex
1174
1325
  @ltype = ltype
1175
1326
  @quoted = quoted
1176
1327
 
1177
- str = if ltype == quoted and %w[" ' /].include? ltype then
1328
+ str = if ltype == quoted and %w[" ' / `].include? ltype and type.nil? then
1178
1329
  ltype.dup
1179
1330
  else
1180
- "%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}"
1331
+ "%#{type}#{PERCENT_PAREN_REV[quoted]||quoted}"
1181
1332
  end
1182
1333
 
1183
1334
  subtype = nil
@@ -1191,21 +1342,21 @@ class RDoc::RubyLex
1191
1342
  break
1192
1343
  elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
1193
1344
  ch = getc
1194
- subtype = true
1195
1345
  if ch == "{" then
1346
+ subtype = true
1196
1347
  str << ch << skip_inner_expression
1197
1348
  next
1198
1349
  else
1199
1350
  ungetc
1200
1351
  end
1201
1352
  elsif ch == '\\'
1202
- if %w[' /].include? @ltype then
1353
+ case @ltype
1354
+ when "'" then
1203
1355
  case ch = getc
1204
- when "\\", "\n", "'"
1205
- when @ltype
1356
+ when "'", '\\' then
1206
1357
  str << ch
1207
1358
  else
1208
- ungetc
1359
+ str << ch
1209
1360
  end
1210
1361
  else
1211
1362
  str << read_escape
@@ -1227,7 +1378,10 @@ class RDoc::RubyLex
1227
1378
  end
1228
1379
  end
1229
1380
 
1230
- if subtype
1381
+ if peek(0) == ':' and !peek_match?(/^::/) and :EXPR_BEG == @lex_state and !@after_question
1382
+ str.concat getc
1383
+ return Token(TkSYMBOL, str)
1384
+ elsif subtype
1231
1385
  Token(DLtype2Token[ltype], str)
1232
1386
  else
1233
1387
  Token(Ltype2Token[ltype], str)