Skip to content

Commit 080cbf2

Browse files
committed
Support safe navigation operator
The safe navigation operator is an operator from the name, but it's a variety of dot token for method calling. So TkSAFENAV class inherited Token class instead of TkOp class.
1 parent e752c73 commit 080cbf2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,16 +668,16 @@ def lex_init()
668668
end
669669
end
670670

671-
@OP.def_rule(".") do
671+
@OP.def_rules(".", "&.") do
672672
|op, io|
673673
@lex_state = :EXPR_BEG
674674
if peek(0) =~ /[0-9]/
675675
ungetc
676676
identify_number
677677
else
678-
# for "obj.if" etc.
678+
# for "obj.if" or "obj&.if" etc.
679679
@lex_state = :EXPR_DOT
680-
Token(TkDOT)
680+
Token(op)
681681
end
682682
end
683683

lib/rdoc/ruby_token.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ def Token(token, value = nil)
401401

402402
[:TkASSIGN, Token, "="],
403403
[:TkDOT, Token, "."],
404+
[:TkSAFENAV, Token, "&."],
404405
[:TkLPAREN, Token, "("], #(exp)
405406
[:TkLBRACK, Token, "["], #[arry]
406407
[:TkLBRACE, Token, "{"], #{hash}

0 commit comments

Comments
 (0)