Skip to content

Commit 06382ed

Browse files
authored
Merge pull request #550 from aycabta/support-ripper-lexer-state
Support Ripper::Lexer::State
2 parents ff81732 + 8a8e8f6 commit 06382ed

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/rdoc/parser/ripper_state_lex.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ def get_squashed_tk
315315
when :on_tstring_beg then
316316
tk = get_string_tk(tk)
317317
when :on_backtick then
318-
if ((EXPR_FNAME | EXPR_ENDFN) & tk[:state]) != 0
318+
if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0
319319
@inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
320320
tk[:kind] = :on_ident
321-
tk[:state] = EXPR_ARG
321+
tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
322322
else
323323
tk = get_string_tk(tk)
324324
end
@@ -558,9 +558,9 @@ def get_squashed_tk
558558

559559
private def get_op_tk(tk)
560560
redefinable_operators = %w[! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> [] []= ^ ` | ~]
561-
if redefinable_operators.include?(tk[:text]) and EXPR_ARG == tk[:state] then
561+
if redefinable_operators.include?(tk[:text]) and tk[:state] == EXPR_ARG then
562562
@inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
563-
tk[:state] = EXPR_ARG
563+
tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
564564
tk[:kind] = :on_ident
565565
elsif tk[:text] =~ /^[-+]$/ then
566566
tk_ahead = get_squashed_tk

lib/rdoc/parser/ruby.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
945945
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
946946
nest += 1
947947
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
948-
if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0
948+
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
949949
nest += 1
950950
end
951951
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
@@ -1538,7 +1538,7 @@ def parse_method_or_yield_parameters(method = nil,
15381538
when :on_comment, :on_embdoc then
15391539
@read.pop
15401540
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
1541-
(!continue or (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) != 0) then
1541+
(!continue or (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) != 0) then
15421542
if method && method.block_params.nil? then
15431543
unget_tk tk
15441544
read_documentation_modifiers method, modifiers
@@ -1743,7 +1743,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
17431743
end
17441744

17451745
when 'until', 'while' then
1746-
if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0
1746+
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
17471747
nest += 1
17481748
skip_optional_do_after_expression
17491749
end
@@ -1759,7 +1759,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
17591759
skip_optional_do_after_expression
17601760

17611761
when 'case', 'do', 'if', 'unless', 'begin' then
1762-
if (RDoc::RipperStateLex::EXPR_LABEL & tk[:state]) == 0
1762+
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
17631763
nest += 1
17641764
end
17651765

0 commit comments

Comments
 (0)