Skip to content

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Nov 23, 2025

No description provided.

@matzbot
Copy link
Collaborator

matzbot commented Nov 23, 2025

🚀 Preview deployment available at: https://a7caabcf.rdoc-6cd.pages.dev (commit: 1433d3f)

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

super(code)
# Returns tokens parsed from +code+.
def self.parse(code)
lex = self.new(code)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self. is redundant here.

Suggested change
lex = self.new(code)
lex = new(code)

Comment on lines +23 to 28
begin
while tk = lex.get_squashed_tk
tokens.push tk
end
rescue StopIteration
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we can remove begin/rescue StopIteration/end here because 2b96a8b removed Enumerator.

tk[:state] = EXPR_ARG
tk[:kind] = :on_ident
elsif tk[:text] =~ /^[-+]$/ then
elsif tk[:text] =~ /^[-+]$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elsif tk[:text] =~ /^[-+]$/
elsif tk[:text] =~ /\A[-+]\z/

@tompng
Copy link
Member

tompng commented Nov 24, 2025

I think creating a new syntax highlighter based on Prism.lex is another option.
Syntax highlighting doesn't need state bits. These are used in rdoc/parser/ruby.rb to parse ruby code.
I think ripper_state_lex.rb is a bit complicated to be used as a prototype of prism based syntax highlighter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants