Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move collecting up tokens for a symbol to RubyLex #462

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions lib/rdoc/parser/ruby_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,6 @@ def get_tk

tk = nil if TkEND_OF_SCRIPT === tk

if TkSYMBEG === tk then
set_token_position tk.line_no, tk.char_no

case tk1 = get_tk
when TkId, TkOp, TkSTRING, TkDSTRING, TkSTAR, TkAMPER then
if tk1.respond_to?(:name) then
tk = Token(TkSYMBOL).set_text(":" + tk1.name)
else
tk = Token(TkSYMBOL).set_text(":" + tk1.text)
end

# remove the identifier we just read to replace it with a symbol
@token_listeners.each do |obj|
obj.pop_token
end if @token_listeners
else
tk = tk1
end
end

# inform any listeners of our shiny new token
@token_listeners.each do |obj|
obj.add_token(tk)
Expand Down
16 changes: 16 additions & 0 deletions lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,22 @@ def token
if @readed_auto_clean_up
get_readed
end

if TkSYMBEG === tk then
tk1 = token
set_token_position tk.line_no, tk.char_no

case tk1
when TkId, TkOp, TkSTRING, TkDSTRING, TkSTAR, TkAMPER then
if tk1.respond_to?(:name) then
tk = Token(TkSYMBOL, ":" + tk1.name)
else
tk = Token(TkSYMBOL, ":" + tk1.text)
end
else
tk = tk1
end
end
# Tracer.off
tk
end
Expand Down
6 changes: 2 additions & 4 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def test_class_tokenize_hash_symbol
@TK::TkLBRACE .new( 0, 1, 0, '{'),
@TK::TkSPACE .new( 1, 1, 1, ' '),
@TK::TkIDENTIFIER.new( 2, 1, 2, 'class'),
@TK::TkSYMBEG .new( 7, 1, 7, ':'),
@TK::TkSTRING .new( 8, 1, 8, '"foo"'),
@TK::TkSYMBOL .new( 7, 1, 7, ':"foo"'),
@TK::TkSPACE .new(13, 1, 13, ' '),
@TK::TkRBRACE .new(14, 1, 14, '}'),
@TK::TkNL .new(15, 1, 15, "\n"),
Expand Down Expand Up @@ -393,8 +392,7 @@ def test_class_tokenize_symbol
@TK::TkIDENTIFIER.new( 6, 1, 6, 'module'),
@TK::TkCOLON .new(12, 1, 12, ':'),
@TK::TkSPACE .new(13, 1, 13, ' '),
@TK::TkSYMBEG .new(14, 1, 14, ':'),
@TK::TkIDENTIFIER.new(15, 1, 15, 'v1'),
@TK::TkSYMBOL .new(14, 1, 14, ':v1'),
@TK::TkNL .new(17, 1, 17, "\n"),
]

Expand Down