summaryrefslogtreecommitdiff
path: root/lib/parsetools
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2019-09-24 08:48:57 +0200
committerBjörn Gustavsson <bjorn@erlang.org>2019-09-25 10:38:50 +0200
commit25f50dd7bcd5b6fb4a2016dadd792408f19fb0d6 (patch)
tree4872cff4dabfc59e3c106c0b9a031a0bdfbb2898 /lib/parsetools
parent59d4182054866e1bfb68bdc8529df236ee94c7b3 (diff)
downloaderlang-25f50dd7bcd5b6fb4a2016dadd792408f19fb0d6.tar.gz
yecc: Eliminate the use of the dict module
Diffstat (limited to 'lib/parsetools')
-rw-r--r--lib/parsetools/src/yecc.erl30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl
index 3343a4282b..f44b1da861 100644
--- a/lib/parsetools/src/yecc.erl
+++ b/lib/parsetools/src/yecc.erl
@@ -1345,7 +1345,7 @@ make_rule_pointer_info(StC, RpRhs, RuleIndex) ->
rp_info([], _SymbolTab, _LcTab, _RuleIndex) ->
[];
rp_info([Category | Followers], SymbolTab, LcTab, RuleIndex) ->
- case dict:find(Category, RuleIndex) of
+ case maps:find(Category, RuleIndex) of
error -> % terminal
[];
{ok, ExpandingRules} when Followers =:= [] ->
@@ -1364,7 +1364,7 @@ rp_info([Category | Followers], SymbolTab, LcTab, RuleIndex) ->
make_lookahead([], _, _, LA) ->
{empty, LA};
make_lookahead([Symbol | Symbols], SymbolTab, LcTab, LA) ->
- case dict:find(Symbol, LcTab) of
+ case maps:find(Symbol, LcTab) of
{ok, LeftCorner} -> % nonterminal
case empty_member(LeftCorner) of
true ->
@@ -1377,7 +1377,7 @@ make_lookahead([Symbol | Symbols], SymbolTab, LcTab, LA) ->
set_add(Symbol, LA)
end.
-%% -> dict-of({Nonterminal, [Terminal]}).
+%% -> map-of({Nonterminal, [Terminal]}).
%% The algorithm FIRST/1 from the Dragon Book.
%% Left corner table, all terminals (including '$empty') that can
%% begin strings generated by Nonterminal.
@@ -1386,15 +1386,15 @@ make_left_corner_table(#yecc{rules_list = RulesList} = St) ->
Rules = map(fun(#rule{symbols = [Lhs | Rhs]}) ->
{Lhs,{Lhs, Rhs}}
end, RulesList),
- LeftHandTab = dict:from_list(family(Rules)),
+ LeftHandTab = maps:from_list(family(Rules)),
X0 = [{S,H} || {H,{H,Rhs}} <- Rules,
S <- Rhs,
not is_terminal(SymbolTab, S)],
XL = family_with_domain(X0, St#yecc.nonterminals),
- X = dict:from_list(XL),
- Xref = fun(NT) -> dict:fetch(NT, X) end,
+ X = maps:from_list(XL),
+ Xref = fun(NT) -> maps:get(NT, X) end,
E = set_empty(),
- LC0 = dict:from_list([{H, E} || {H,_} <- XL]),
+ LC0 = maps:from_list([{H, E} || {H,_} <- XL]),
%% Handle H -> a S, where a is a terminal ('$empty' inclusive).
{Q, LC1} =
foldl(fun({H,{H,[S | _]}}, {Q0, LC}) ->
@@ -1413,7 +1413,7 @@ left_corners(Q0, LC0, LeftHandTab, SymbolTab, Xref) ->
[] ->
LC0;
Q1 ->
- Rs = flatmap(fun(NT) -> dict:fetch(NT, LeftHandTab) end, Q1),
+ Rs = flatmap(fun(NT) -> maps:get(NT, LeftHandTab) end, Q1),
{LC, Q} = left_corners2(Rs, LC0, [], SymbolTab, Xref),
left_corners(Q, LC, LeftHandTab, SymbolTab, Xref)
end.
@@ -1422,7 +1422,7 @@ left_corners2([], LC, Q, _SymbolTab, _Xref) ->
{LC, Q};
left_corners2([{Head,Rhs} | Rs], LC, Q0, SymbolTab, Xref) ->
Ts = left_corner_rhs(Rhs, Head, LC, set_empty(), SymbolTab),
- First0 = dict:fetch(Head, LC),
+ First0 = maps:get(Head, LC),
case set_is_subset(Ts, First0) of
true ->
left_corners2(Rs, LC, Q0, SymbolTab, Xref);
@@ -1432,14 +1432,14 @@ left_corners2([{Head,Rhs} | Rs], LC, Q0, SymbolTab, Xref) ->
end.
upd_first(NT, Ts, LC) ->
- dict:update(NT, fun(First) -> set_union(First, Ts) end, LC).
+ maps:update_with(NT, fun(First) -> set_union(First, Ts) end, LC).
left_corner_rhs([S | Ss], Head, LC, Ts, SymbolTab) ->
case ets:lookup(SymbolTab, S) of
[{_,Num}=SymbolAndNum] when Num >= 0 ->
set_add_terminal(SymbolAndNum, Ts);
[_NonTerminalSymbol] ->
- First = dict:fetch(S, LC),
+ First = maps:get(S, LC),
case empty_member(First) of
true ->
NTs = set_union(empty_delete(First), Ts),
@@ -1466,7 +1466,7 @@ make_rule_index(#yecc{nonterminals = Nonterminals,
Symbol2Rule = [{Foo,R} || #rule{symbols = Symbols}=R <- RulesListNoCodes,
Foo <- Symbols],
Pointer2Rule = [{I, R} || {{_Foo,R},I} <- count(1, Symbol2Rule)],
- {dict:from_list(IndexedTab), dict:from_list(Pointer2Rule)}.
+ {maps:from_list(IndexedTab), maps:from_list(Pointer2Rule)}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Computing parse action table from list of states and goto table:
@@ -2309,14 +2309,14 @@ function_name(St, Name, Suf) ->
rule(RulePointer, St) ->
#rule{n = N, anno = Anno, symbols = Symbols} =
- dict:fetch(RulePointer, St#yecc.rule_pointer2rule),
+ maps:get(RulePointer, St#yecc.rule_pointer2rule),
{Symbols, Anno, N}.
get_rule(RuleNmbr, St) ->
- dict:fetch(RuleNmbr, St#yecc.rule_pointer2rule).
+ maps:get(RuleNmbr, St#yecc.rule_pointer2rule).
tokens(RuleNmbr, St) ->
- Rule = dict:fetch(RuleNmbr, St#yecc.rule_pointer2rule),
+ Rule = maps:get(RuleNmbr, St#yecc.rule_pointer2rule),
Rule#rule.tokens.
goto(From, Symbol, St) ->