Skip to content

Commit

Permalink
Always consider maybe and else as keywords
Browse files Browse the repository at this point in the history
Summary: Based on D45180059, applied to the latest version of the scanner.

Reviewed By: alanz

Differential Revision: D57834821

fbshipit-source-id: 9e69de9267e82163e574f85e976b993b5af22032
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Jun 26, 2024
1 parent 599cf89 commit f156ab6
Showing 1 changed file with 30 additions and 39 deletions.
69 changes: 30 additions & 39 deletions erlang_service/src/erl_scan_otp27.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1583,45 +1583,36 @@ lists_duplicate(N, X, L) -> lists_duplicate(N - 1, X, [X | L]).
lists_foldl_reverse(Lists, Acc) ->
lists:foldl(fun lists:reverse/2, Acc, Lists).

%% Dynamic version of reserved_word that knows about the possibility
%% that enabled features might change the set of reserved words.
-spec reserved_word(Atom :: atom()) -> boolean().
reserved_word(Atom) ->
case f_reserved_word(Atom) of
true -> true;
false -> lists:member(Atom, erl_features:keywords())
end.

%% Static version of reserved_words. These represent the fixed set of
%% reserved words.
f_reserved_word('after') -> true;
f_reserved_word('begin') -> true;
f_reserved_word('case') -> true;
f_reserved_word('try') -> true;
f_reserved_word('cond') -> true;
f_reserved_word('catch') -> true;
f_reserved_word('andalso') -> true;
f_reserved_word('orelse') -> true;
f_reserved_word('end') -> true;
f_reserved_word('fun') -> true;
f_reserved_word('if') -> true;
f_reserved_word('let') -> true;
f_reserved_word('of') -> true;
f_reserved_word('receive') -> true;
f_reserved_word('when') -> true;
f_reserved_word('bnot') -> true;
f_reserved_word('not') -> true;
f_reserved_word('div') -> true;
f_reserved_word('rem') -> true;
f_reserved_word('band') -> true;
f_reserved_word('and') -> true;
f_reserved_word('bor') -> true;
f_reserved_word('bxor') -> true;
f_reserved_word('bsl') -> true;
f_reserved_word('bsr') -> true;
f_reserved_word('or') -> true;
f_reserved_word('xor') -> true;
f_reserved_word(_) -> false.
reserved_word('after') -> true;
reserved_word('begin') -> true;
reserved_word('case') -> true;
reserved_word('try') -> true;
reserved_word('cond') -> true;
reserved_word('catch') -> true;
reserved_word('andalso') -> true;
reserved_word('orelse') -> true;
reserved_word('end') -> true;
reserved_word('fun') -> true;
reserved_word('if') -> true;
reserved_word('let') -> true;
reserved_word('of') -> true;
reserved_word('receive') -> true;
reserved_word('when') -> true;
reserved_word('bnot') -> true;
reserved_word('not') -> true;
reserved_word('div') -> true;
reserved_word('rem') -> true;
reserved_word('band') -> true;
reserved_word('and') -> true;
reserved_word('bor') -> true;
reserved_word('bxor') -> true;
reserved_word('bsl') -> true;
reserved_word('bsr') -> true;
reserved_word('or') -> true;
reserved_word('xor') -> true;
reserved_word('maybe') -> true;
reserved_word('else') -> true;
reserved_word(_) -> false.

char_byte_size(C) ->
%% TODO: more efficient implementation
Expand Down

0 comments on commit f156ab6

Please sign in to comment.