diff --git a/erlang/apps/as/src/parse.erl b/erlang/apps/as/src/parse.erl index 6d69758..e2b6ddf 100644 --- a/erlang/apps/as/src/parse.erl +++ b/erlang/apps/as/src/parse.erl @@ -134,7 +134,7 @@ insn_uint(ScanState, Location, Name, Location2, UInt) -> %% Seen " " where is not "@", or followed by ",". %% is the start of the . insn_disp(ScanState, Location, Name, First) -> - case do_expr(ScanState, {ok, First}, ifiw) of + case do_expr(ScanState, {ok, First}) of {ok, Displacement} -> insn_ea_disp(ScanState, Location, Name, _AccOrDev = false, _At = false, Displacement); {error, _Reason} = Error -> Error @@ -147,7 +147,7 @@ insn_ea(ScanState, Location, Name, AccOrDev) -> make_insn(Location, Name, AccOrDev, _At = false, _Displacement = false, _Index = false); {ok, {_Location, ?T_AT}} -> insn_ea_at(ScanState, Location, Name, AccOrDev); {ok, {_Location, _Token}} = ScanRes -> - case do_expr(ScanState, ScanRes, ifiw) of + case do_expr(ScanState, ScanRes) of {ok, Displacement} -> insn_ea_disp(ScanState, Location, Name, AccOrDev, _At = false, Displacement); {error, _Reason} = Error -> Error @@ -157,7 +157,7 @@ insn_ea(ScanState, Location, Name, AccOrDev) -> %% [ ","] "@" . ["(" ")"] insn_ea_at(ScanState, Location, Name, AccOrDev) -> - case expr(ScanState, ifiw) of + case expr(ScanState) of {ok, Displacement} -> insn_ea_disp(ScanState, Location, Name, AccOrDev, _At = true, Displacement); {error, _Reason} = Error -> Error @@ -205,7 +205,7 @@ make_insn(Location, Name, AccOrDev, At, Displacement, Index) -> Stmt = #s_insn{ high13 = FinalHigh13 , at = At , address = case Displacement of - false -> mk_integer_expr(0, ifiw); + false -> mk_integer_expr(0, false); _ -> Displacement end , index = if Index =:= false -> 0; true -> Index end @@ -607,18 +607,17 @@ section_name(ScanState) -> %% | "-"? %% | ( | ) (("+" | "-") )? %% -%% ::= "ifiw" | "w" | "b" | "h" +%% ::= "w" | "b" | "h" %% -%% Note: defaults to "ifiw" in and "w" in data directives. -%% It describes how the value should be represented, which also determines -%% which relocation to use for it. +%% Note: describes how the value should be represented, which also +%% determines which relocation to use for it. %% ::= ( ("," )*)? \n expr_list(ScanState) -> case scan:token(ScanState) of {ok, {_Location, ?T_NEWLINE}} -> {ok, []}; First -> - case do_expr(ScanState, First, _DefaultModifier = w) of + case do_expr(ScanState, First) of {ok, Expr} -> expr_list(ScanState, [Expr]); {error, _Reason} = Error -> Error end @@ -627,7 +626,7 @@ expr_list(ScanState) -> expr_list(ScanState, Exprs) -> case scan:token(ScanState) of {ok, {_Location, ?T_COMMA}} -> - case expr(ScanState, _DefaultModifier = w) of + case expr(ScanState) of {ok, Expr} -> expr_list(ScanState, [Expr | Exprs]); {error, _Reason} = Error -> Error end; @@ -635,20 +634,20 @@ expr_list(ScanState, Exprs) -> ScanRes -> badtok("expected comma or newline", ScanRes) end. -expr(ScanState, DefaultModifier) -> - do_expr(ScanState, scan:token(ScanState), DefaultModifier). +expr(ScanState) -> + do_expr(ScanState, scan:token(ScanState)). -do_expr(ScanState, First, DefaultModifier) -> +do_expr(ScanState, First) -> case First of {ok, {_Location, ?T_COLON}} -> modifier_expr(ScanState); - _ -> do_plain_expr(ScanState, First, DefaultModifier) + _ -> do_plain_expr(ScanState, First, _Modifier = false) end. modifier_expr(ScanState) -> case scan:token(ScanState) of {ok, {_Location1, {?T_SYMBOL, Symbol}}} = ScanRes1 -> case symbol_modifier(Symbol) of - false -> badtok("invalid modifier", ScanRes1); + error -> badtok("invalid modifier", ScanRes1); Modifier -> case scan:token(ScanState) of {ok, {_Location2, ?T_LPAREN}} -> @@ -715,11 +714,10 @@ do_expr_offset(ScanState, Symbol, IsMinus, Modifier) -> symbol_modifier(Symbol) -> case Symbol of - "ifiw" -> ifiw; "w" -> w; "b" -> b; "h" -> h; - _ -> false + _ -> error end. mk_integer_expr(Value, Modifier) -> #expr{symbol = false, offset = Value, modifier = Modifier}. diff --git a/erlang/apps/as/src/tunit.hrl b/erlang/apps/as/src/tunit.hrl index c577d73..cc712f7 100644 --- a/erlang/apps/as/src/tunit.hrl +++ b/erlang/apps/as/src/tunit.hrl @@ -26,7 +26,7 @@ -record(expr, { symbol :: false | string() | {non_neg_integer(), $b | $f} , offset :: integer() - , modifier :: ifiw | w | b | h + , modifier :: false | w | b | h }). -type expr() :: #expr{}.