Skip to content

Commit

Permalink
Gave TkEND_OF_SCRIPT#text a value
Browse files Browse the repository at this point in the history
This allows __END__ to be shown in HTML verbatim blocks

Conflicts:
	History.rdoc
  • Loading branch information
drbrain committed Feb 24, 2013
1 parent 976d31f commit 24efb01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Fixed lexing of character syntax (<code>?x</code>). Reported by Xavier
Noria.
* Fixed tokenization of % when it is not followed by a $-string type
* Fixed display of __END__ in documentation examples in HTML output


=== 3.12.1 / 2013-02-05

Expand Down
5 changes: 3 additions & 2 deletions lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def token
def lex_init()
@OP = IRB::SLex.new
@OP.def_rules("\0", "\004", "\032") do |op, io|
Token(TkEND_OF_SCRIPT)
Token(TkEND_OF_SCRIPT, '')
end

@OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io|
Expand Down Expand Up @@ -808,7 +808,8 @@ def lex_int2

@OP.def_rule("_") do
if peek_match?(/_END__/) and @lex_state == EXPR_BEG then
Token(TkEND_OF_SCRIPT)
6.times { getc }
Token(TkEND_OF_SCRIPT, '__END__')
else
ungetc
identify_identifier
Expand Down
11 changes: 11 additions & 0 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def test_class_tokenize
assert_equal expected, tokens
end

def test_class_tokenize___END__
tokens = RDoc::RubyLex.tokenize '__END__', nil

expected = [
@TK::TkEND_OF_SCRIPT.new(0, 1, 0, '__END__'),
@TK::TkNL .new(7, 1, 7, "\n"),
]

assert_equal expected, tokens
end

def test_class_tokenize_character_literal
tokens = RDoc::RubyLex.tokenize "?\\", nil

Expand Down

0 comments on commit 24efb01

Please sign in to comment.