Skip to content

Commit 062efe8

Browse files
committed
Fix lexing of a bb <<-HEREDOC. Issue #75
1 parent 5a78452 commit 062efe8

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

History.rdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
* The C parser now understands classes defined with
8787
+rb_struct_define_without_accessor+ (like Range). Pull Request #73 by Dan
8888
Bernier
89+
* Fixed lexing of <code>a b <<-HEREDOC</code>. Issue #75 by John Mair.
8990

9091
=== 3.9.2 / 2011-08-11
9192

TODO.rdoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Some file contains some things that might happen in RDoc, or might not
1111
* Add direct accessor to RDoc::Options to RDoc::Task
1212
* Remove Public in HTML output if there are only public methods
1313
* Method markup support for rd documentation
14+
* Improve SIGINFO handling
15+
* Global variable support
16+
* Page support for ri
1417

1518
=== 4
1619

lib/rdoc/ruby_lex.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def self.debug?
5555
end
5656

5757
self.debug_level = 0
58-
58+
5959
# :startdoc:
6060

6161
##
@@ -69,7 +69,7 @@ def self.tokenize ruby, options
6969
scanner.exception_on_syntax_error = true
7070

7171
while token = scanner.token do
72-
tokens << token
72+
tokens << token
7373
end
7474

7575
tokens
@@ -960,7 +960,8 @@ def identify_identifier
960960
if peek(0) == '='
961961
token.concat getc
962962
end
963-
elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT
963+
elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT ||
964+
@lex_state == EXPR_ARG
964965
@lex_state = EXPR_ARG
965966
else
966967
@lex_state = EXPR_END

test/test_rdoc_ruby_lex.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ def test_class_tokenize_heredoc
5050
assert_equal expected, tokens
5151
end
5252

53+
def test_class_tokenize_heredoc_percent_N
54+
tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil
55+
a b <<-U
56+
%N
57+
U
58+
RUBY
59+
60+
expected = [
61+
@TK::TkIDENTIFIER.new( 0, 1, 0, 'a'),
62+
@TK::TkSPACE .new( 1, 1, 1, ' '),
63+
@TK::TkIDENTIFIER.new( 2, 1, 2, 'b'),
64+
@TK::TkSPACE .new( 3, 1, 3, ' '),
65+
@TK::TkSTRING .new( 4, 1, 4, %Q{"%N\n"}),
66+
@TK::TkNL .new(13, 3, 14, "\n"),
67+
]
68+
69+
assert_equal expected, tokens
70+
end
71+
5372
def test_unary_minus
5473
ruby_lex = RDoc::RubyLex.new("-1", nil)
5574
assert_equal("-1", ruby_lex.token.value)

0 commit comments

Comments
 (0)