[m-rev.] for review: merge integer token representations in the lexer

Julien Fischer jfischer at opturion.com
Sat Apr 22 15:19:47 AEST 2017


For review by anyone.

This builds on my earlier uncommitted change; I haven't yet update
the expected outputs for the Java and C# grades, but will do so before
I commit this change.

-------------------------------

Merge integer token representations in the lexer.

library/lexer.m:
      Merge the 'integer' and 'big_integer' tokens and extend them to include
      signedness and size information.  This conforms to recent changes to
      the rest of the system and is another step towards supporting additional
      types of integer literal.

library/parser.m:
mdbcomp/trace_counts.m:
      Conform to the above change.

tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_zero.exp:
tests/hard_coded/parse_number_from_string.exp:
      Update these expected outputs.

Julien.

diff --git a/library/lexer.m b/library/lexer.m
index 822f2de..c48a800 100644
--- a/library/lexer.m
+++ b/library/lexer.m
@@ -30,11 +30,7 @@
  :- type token
      --->    name(string)
      ;       variable(string)
-    ;       integer(integer_base, int)
-
-    ;       big_integer(integer_base, integer)
-            % An integer that is too big for `int'.
-
+    ;       integer(integer_base, integer, signedness, integer_size)
      ;       float(float)
      ;       string(string)      % "...."
      ;       implementation_defined(string) % $name
@@ -53,7 +49,7 @@
      ;       io_error(io.error)  % error reading from the input stream
      ;       eof                 % end-of-file

-    ;       integer_dot(int).
+    ;       integer_dot(integer).
              % The lexer will never return integer_dot. This token is used
              % internally in the lexer, to keep the grammar LL(1) so that
              % only one character of pushback is needed. But the lexer will
@@ -66,6 +62,17 @@
      ;       base_10
      ;       base_16.

+:- type signedness
+    --->    signed
+    ;       unsigned.
+
+:- type integer_size
+    --->    size_word.
+    %;       size_8_bit
+    %;       size_16_bit
+    %;       size_32_bit
+    %;       size_64_bit
+
      % For every token, we record the line number of the line on
      % which the token occurred.
      %
@@ -191,17 +198,17 @@ get_token_list_2(Stream, Token0, Context0, Tokens, !IO) :-
          ),
          Tokens = token_cons(Token0, Context0, token_nil)
      ;
-        Token0 = integer_dot(Int),
+        Token0 = integer_dot(Integer),
          get_context(Stream, Context1, !IO),
          get_dot(Stream, Token1, !IO),
          get_token_list_2(Stream, Token1, Context1, Tokens1, !IO),
-        Tokens = token_cons(integer(base_10, Int), Context0, Tokens1)
+        Tokens = token_cons(integer(base_10, Integer, signed, size_word),
+            Context0, Tokens1)
      ;
          ( Token0 = float(_)
          ; Token0 = string(_)
          ; Token0 = variable(_)
-        ; Token0 = integer(_, _)
-        ; Token0 = big_integer(_, _)
+        ; Token0 = integer(_, _, _, _)
          ; Token0 = implementation_defined(_)
          ; Token0 = junk(_)
          ; Token0 = name(_)
@@ -235,8 +242,7 @@ string_get_token_list_max(String, Len, Tokens, !Posn) :-
          ( Token = float(_)
          ; Token = string(_)
          ; Token = variable(_)
-        ; Token = integer(_, _)
-        ; Token = big_integer(_, _)
+        ; Token = integer(_, _, _, _)
          ; Token = integer_dot(_)
          ; Token = implementation_defined(_)
          ; Token = junk(_)
@@ -1955,7 +1961,7 @@ get_zero(Stream, Token, !IO) :-
          Token = io_error(Error)
      ;
          Result = eof,
-        Token = integer(base_10, 0)
+        Token = integer(base_10, integer.zero, signed, size_word)
      ;
          Result = ok,
          ( if char.is_digit(Char) then
@@ -1979,7 +1985,7 @@ get_zero(Stream, Token, !IO) :-
              get_float_exponent(Stream, [Char, '0'], Token, !IO)
          else
              io.putback_char(Stream, Char, !IO),
-            Token = integer(base_10, 0)
+            Token = integer(base_10, integer.zero, signed, size_word)
          )
      ).

@@ -2026,11 +2032,11 @@ string_get_zero(String, Len, Posn0, Token, Context, !Posn) :-
          else
              string_ungetchar(String, !Posn),
              string_get_context(Posn0, Context, !Posn),
-            Token = integer(base_10, 0)
+            Token = integer(base_10, integer.zero, signed, size_word)
          )
      else
          string_get_context(Posn0, Context, !Posn),
-        Token = integer(base_10, 0)
+        Token = integer(base_10, integer.zero, signed, size_word)
      ).

  :- pred get_char_code(io.input_stream::in, token::out, io::di, io::uo) is det.
@@ -2046,7 +2052,7 @@ get_char_code(Stream, Token, !IO) :-
      ;
          Result = ok,
          char.to_int(Char, CharCode),
-        Token = integer(base_10, CharCode)
+        Token = integer(base_10, integer(CharCode), signed, size_word)
      ).

  :- pred string_get_char_code(string::in, int::in, posn::in, token::out,
@@ -2055,7 +2061,7 @@ get_char_code(Stream, Token, !IO) :-
  string_get_char_code(String, Len, Posn0, Token, Context, !Posn) :-
      ( if string_read_char(String, Len, Char, !Posn) then
          char.to_int(Char, CharCode),
-        Token = integer(base_10, CharCode),
+        Token = integer(base_10, integer(CharCode), signed, size_word),
          string_get_context(Posn0, Context, !Posn)
      else
          Token = error("unterminated char code literal"),
@@ -2574,8 +2580,8 @@ get_int_dot(Stream, !.LastDigit, !.RevChars, Token, !IO) :-
              (
                  !.LastDigit = last_digit_is_not_underscore,
                  rev_char_list_to_int(!.RevChars, base_10, Token0),
-                ( if Token0 = integer(_, Int) then
-                    Token = integer_dot(Int)
+                ( if Token0 = integer(_, Integer, _, _) then
+                    Token = integer_dot(Integer)
                  else
                      Token = Token0
                  )
@@ -2910,10 +2916,8 @@ rev_char_list_to_int(RevChars, Base, Token) :-

  conv_string_to_int(String, Base, Token) :-
      BaseInt = integer_base_int(Base),
-    ( if string.base_string_to_int_underscore(BaseInt, String, Int) then
-        Token = integer(Base, Int)
-    else if integer.from_base_string_underscore(BaseInt, String, Integer) then
-        Token = big_integer(Base, Integer)
+    ( if integer.from_base_string_underscore(BaseInt, String, Integer) then
+        Token = integer(Base, Integer, signed, size_word)
      else
          Token = error("invalid character in int")
      ).
@@ -2963,12 +2967,7 @@ token_to_string(Token, String) :-
          Token = variable(Var),
          string.append_list(["variable `", Var, "'"], String)
      ;
-        Token = integer(Base, Int),
-        base_to_int_and_prefix(Base, BaseInt, Prefix),
-        string.int_to_base_string(Int, BaseInt, IntString),
-        string.append_list(["integer `", Prefix, IntString, "'"], String)
-    ;
-        Token = big_integer(Base, Integer),
+        Token = integer(Base, Integer, _Signedness, _Size),
          base_to_int_and_prefix(Base, BaseInt, Prefix),
          IntString = integer.to_base_string(Integer, BaseInt),
          string.append_list(["integer `", Prefix, IntString, "'"], String)
@@ -3028,8 +3027,8 @@ token_to_string(Token, String) :-
          Token = error(Message),
          string.append_list(["illegal token (", Message, ")"], String)
      ;
-        Token = integer_dot(Int),
-        string.int_to_string(Int, IntString),
+        Token = integer_dot(Integer),
+        IntString = integer.to_string(Integer),
          string.append_list(["integer `", IntString, "'."], String)
      ).

diff --git a/library/parser.m b/library/parser.m
index dbfb3f5..39edb59 100644
--- a/library/parser.m
+++ b/library/parser.m
@@ -310,8 +310,7 @@ check_for_bad_token(token_cons(Token, LineNum0, Tokens), Message, LineNum) :-
      ;
          ( Token = name(_)
          ; Token = variable(_)
-        ; Token = integer(_, _)
-        ; Token = big_integer(_, _)
+        ; Token = integer(_, _, _, _)
          ; Token = float(_)
          ; Token = string(_)
          ; Token = implementation_defined(_)
@@ -423,16 +422,11 @@ parse_left_term(MaxPriority, TermKind, OpPriority, Term, !TokensLeft, !PS) :-
              !.TokensLeft =
                  token_cons(NextToken, _NextContext, !:TokensLeft),
              (
-                NextToken = integer(LexerBase, X),
-                NegX = integer(0 - X),
+                NextToken = integer(LexerBase, X, signed, LexerSize),
+                NegX = -X,
                  Base = lexer_base_to_term_base(LexerBase),
-                NewFunctor = integer(Base, NegX, signed, size_word)
-            ;
-                NextToken = big_integer(LexerBase, X),
-                -X = integer(min_int),
-                NegX = integer(int.min_int),
-                Base = lexer_base_to_term_base(LexerBase),
-                NewFunctor = integer(Base, NegX, signed, size_word)
+                Size = lexer_size_to_term_size(LexerSize),
+                NewFunctor = integer(Base, NegX, signed, Size)
              ;
                  NextToken = float(F),
                  NegF = 0.0 - F,
@@ -736,29 +730,12 @@ parse_simple_term(Token, Context, Prec, TermParse, !TokensLeft, !PS) :-
          BaseTerm = term.variable(Var, TermContext),
          BaseTermParse = ok(BaseTerm)
      ;
-        Token = integer(LexerBase, Int),
-        parser_get_term_context(!.PS, Context, TermContext),
+        Token = integer(LexerBase, Integer, LexerSignedness, LexerSize),
          Base = lexer_base_to_term_base(LexerBase),
-        BaseTerm = functor(integer(Base, integer(Int), signed, size_word), [],
-            TermContext),
-        BaseTermParse = ok(BaseTerm)
-    ;
-        Token = big_integer(LexerBase, Integer),
+        Signedness = lexer_signedness_to_term_signedness(LexerSignedness),
+        Size = lexer_size_to_term_size(LexerSize),
          parser_get_term_context(!.PS, Context, TermContext),
-        (
-            LexerBase = base_2,
-            TermBase = base_2
-        ;
-            LexerBase = base_8,
-            TermBase = base_8
-        ;
-            LexerBase = base_10,
-            TermBase = base_10
-        ;
-            LexerBase = base_16,
-            TermBase = base_16
-        ),
-        BaseTerm = functor(integer(TermBase, Integer, signed, size_word), [],
+        BaseTerm = functor(integer(Base, Integer, Signedness, Size), [],
              TermContext),
          BaseTermParse = ok(BaseTerm)
      ;
@@ -1131,8 +1108,7 @@ parser_get_term_context(ParserState, TokenContext, TermContext) :-

  could_start_term(name(_), yes).
  could_start_term(variable(_), yes).
-could_start_term(integer(_, _), yes).
-could_start_term(big_integer(_, _), yes).
+could_start_term(integer(_, _, _, _), yes).
  could_start_term(float(_), yes).
  could_start_term(string(_), yes).
  could_start_term(implementation_defined(_), yes).
@@ -1161,6 +1137,16 @@ lexer_base_to_term_base(base_8) = base_8.
  lexer_base_to_term_base(base_10) = base_10.
  lexer_base_to_term_base(base_16) = base_16.

+:- func lexer_signedness_to_term_signedness(lexer.signedness)
+    = term.signedness.
+
+lexer_signedness_to_term_signedness(unsigned) = unsigned.
+lexer_signedness_to_term_signedness(signed) = signed.
+
+:- func lexer_size_to_term_size(lexer.integer_size) = term.integer_size.
+
+lexer_size_to_term_size(size_word) = size_word.
+
  %---------------------------------------------------------------------------%
  %---------------------------------------------------------------------------%
  %
diff --git a/mdbcomp/trace_counts.m b/mdbcomp/trace_counts.m
index 0dbddbd..21b4eec 100644
--- a/mdbcomp/trace_counts.m
+++ b/mdbcomp/trace_counts.m
@@ -188,6 +188,7 @@

  :- import_module exception.
  :- import_module int.
+:- import_module integer.
  :- import_module lexer.
  :- import_module require.
  :- import_module string.
@@ -547,18 +548,22 @@ read_proc_trace_counts(HeaderLineNumber, HeaderLine, CurModuleNameSym,
                  TokenName = "pproc",
                  TokenListRest =
                      token_cons(name(Name), _,
-                    token_cons(integer(base_10, Arity), _,
-                    token_cons(integer(base_10, Mode), _,
+                    token_cons(ArityToken, _,
+                    token_cons(ModeToken, _,
                      token_nil))),
+                decimal_token_to_int(ArityToken, Arity),
+                decimal_token_to_int(ModeToken, Mode),
                  ProcLabel = ordinary_proc_label(CurModuleNameSym, pf_predicate,
                      CurModuleNameSym, Name, Arity, Mode)
              ;
                  TokenName = "fproc",
                  TokenListRest =
                      token_cons(name(Name), _,
-                    token_cons(integer(base_10, Arity), _,
-                    token_cons(integer(base_10, Mode), _,
+                    token_cons(ArityToken, _,
+                    token_cons(ModeToken, _,
                      token_nil))),
+                decimal_token_to_int(ArityToken, Arity),
+                decimal_token_to_int(ModeToken, Mode),
                  ProcLabel = ordinary_proc_label(CurModuleNameSym, pf_function,
                      CurModuleNameSym, Name, Arity, Mode)
              ;
@@ -566,9 +571,11 @@ read_proc_trace_counts(HeaderLineNumber, HeaderLine, CurModuleNameSym,
                  TokenListRest =
                      token_cons(name(DeclModuleName), _,
                      token_cons(name(Name), _,
-                    token_cons(integer(base_10, Arity), _,
-                    token_cons(integer(base_10, Mode), _,
+                    token_cons(ArityToken, _,
+                    token_cons(ModeToken, _,
                      token_nil)))),
+                decimal_token_to_int(ArityToken, Arity),
+                decimal_token_to_int(ModeToken, Mode),
                  DeclModuleNameSym = string_to_sym_name(DeclModuleName),
                  ProcLabel = ordinary_proc_label(CurModuleNameSym, pf_predicate,
                      DeclModuleNameSym, Name, Arity, Mode)
@@ -577,9 +584,11 @@ read_proc_trace_counts(HeaderLineNumber, HeaderLine, CurModuleNameSym,
                  TokenListRest =
                      token_cons(name(DeclModuleName), _,
                      token_cons(name(Name), _,
-                    token_cons(integer(base_10, Arity), _,
-                    token_cons(integer(base_10, Mode), _,
+                    token_cons(ArityToken, _,
+                    token_cons(ModeToken, _,
                      token_nil)))),
+                decimal_token_to_int(ArityToken, Arity),
+                decimal_token_to_int(ModeToken, Mode),
                  DeclModuleNameSym = string_to_sym_name(DeclModuleName),
                  ProcLabel = ordinary_proc_label(CurModuleNameSym, pf_function,
                      DeclModuleNameSym, Name, Arity, Mode)
@@ -737,6 +746,12 @@ make_path_port(GoalPath, port_disj_later) = path_only(GoalPath).
  make_path_port(GoalPath, port_switch) = path_only(GoalPath).
  make_path_port(_GoalPath, port_user) = port_only(port_user).

+:- pred decimal_token_to_int(token::in, int::out) is semidet.
+
+decimal_token_to_int(Token, Int) :-
+    Token = integer(base_10, Integer, signed, size_word),
+    integer.to_int(Integer, Int).
+
  %-----------------------------------------------------------------------------%

  read_and_union_trace_counts(ShowProgress, Files, NumTests, TestKinds,
diff --git a/tests/hard_coded/impl_def_lex.exp b/tests/hard_coded/impl_def_lex.exp
index 3aae974..91332d3 100644
--- a/tests/hard_coded/impl_def_lex.exp
+++ b/tests/hard_coded/impl_def_lex.exp
@@ -7,4 +7,4 @@ name("$!$") 5
  name("$") 6
  comma 6
  name("$") 7
-integer(base_10, 0) 7
+integer(base_10, i(0, []), signed, size_word) 7
diff --git a/tests/hard_coded/impl_def_lex_string.exp b/tests/hard_coded/impl_def_lex_string.exp
index 1f709aa..d70fc2a 100644
--- a/tests/hard_coded/impl_def_lex_string.exp
+++ b/tests/hard_coded/impl_def_lex_string.exp
@@ -4,4 +4,4 @@
  {token_cons(name("$"), 1, token_nil), posn(1, 0, 1)}
  {token_cons(name("$!$"), 1, token_nil), posn(1, 0, 3)}
  {token_cons(name("$"), 1, token_cons(comma, 1, token_nil)), posn(1, 0, 2)}
-{token_cons(name("$"), 1, token_cons(integer(base_10, 0), 1, token_nil)), posn(1, 0, 2)}
+{token_cons(name("$"), 1, token_cons(integer(base_10, i(0, []), signed, size_word), 1, token_nil)), posn(1, 0, 2)}
diff --git a/tests/hard_coded/lexer_bigint.exp b/tests/hard_coded/lexer_bigint.exp
index ede0670..d2ab6e3 100644
--- a/tests/hard_coded/lexer_bigint.exp
+++ b/tests/hard_coded/lexer_bigint.exp
@@ -1,51 +1,51 @@
-integer(base_10, 2147483646)
-integer(base_10, 2147483647)
-big_integer(base_10, i(3, [8, 0, 0]))
+integer(base_10, i(3, [7, 16383, 16382]), signed, size_word)
+integer(base_10, i(3, [7, 16383, 16383]), signed, size_word)
+integer(base_10, i(3, [8, 0, 0]), signed, size_word)
  name("-")
-integer(base_10, 2147483647)
+integer(base_10, i(3, [7, 16383, 16383]), signed, size_word)
  name("-")
-big_integer(base_10, i(3, [8, 0, 0]))
+integer(base_10, i(3, [8, 0, 0]), signed, size_word)
  name("-")
-big_integer(base_10, i(3, [8, 0, 1]))
-big_integer(base_2, i(3, [15, 16383, 16383]))
-big_integer(base_8, i(3, [15, 16383, 16383]))
-big_integer(base_16, i(3, [15, 16383, 16383]))
-big_integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]))
-big_integer(base_10, i(5, [128, 0, 0, 0, 0]))
-big_integer(base_10, i(5, [128, 0, 0, 0, 1]))
+integer(base_10, i(3, [8, 0, 1]), signed, size_word)
+integer(base_2, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_8, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_16, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_10, i(5, [128, 0, 0, 0, 0]), signed, size_word)
+integer(base_10, i(5, [128, 0, 0, 0, 1]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]))
+integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [128, 0, 0, 0, 0]))
+integer(base_10, i(5, [128, 0, 0, 0, 0]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [128, 0, 0, 0, 1]))
-big_integer(base_2, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_8, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_16, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_10, i(8, [3155, 7268, 4662, 4920, 12374, 12447, 15630, 7857]))
+integer(base_10, i(5, [128, 0, 0, 0, 1]), signed, size_word)
+integer(base_2, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_8, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_16, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_10, i(8, [3155, 7268, 4662, 4920, 12374, 12447, 15630, 7857]), signed, size_word)

-integer(base_10, 2147483646)
-integer(base_10, 2147483647)
-big_integer(base_10, i(3, [8, 0, 0]))
+integer(base_10, i(3, [7, 16383, 16382]), signed, size_word)
+integer(base_10, i(3, [7, 16383, 16383]), signed, size_word)
+integer(base_10, i(3, [8, 0, 0]), signed, size_word)
  name("-")
-integer(base_10, 2147483647)
+integer(base_10, i(3, [7, 16383, 16383]), signed, size_word)
  name("-")
-big_integer(base_10, i(3, [8, 0, 0]))
+integer(base_10, i(3, [8, 0, 0]), signed, size_word)
  name("-")
-big_integer(base_10, i(3, [8, 0, 1]))
-big_integer(base_2, i(3, [15, 16383, 16383]))
-big_integer(base_8, i(3, [15, 16383, 16383]))
-big_integer(base_16, i(3, [15, 16383, 16383]))
-big_integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]))
-big_integer(base_10, i(5, [128, 0, 0, 0, 0]))
-big_integer(base_10, i(5, [128, 0, 0, 0, 1]))
+integer(base_10, i(3, [8, 0, 1]), signed, size_word)
+integer(base_2, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_8, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_16, i(3, [15, 16383, 16383]), signed, size_word)
+integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_10, i(5, [128, 0, 0, 0, 0]), signed, size_word)
+integer(base_10, i(5, [128, 0, 0, 0, 1]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]))
+integer(base_10, i(5, [127, 16383, 16383, 16383, 16383]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [128, 0, 0, 0, 0]))
+integer(base_10, i(5, [128, 0, 0, 0, 0]), signed, size_word)
  name("-")
-big_integer(base_10, i(5, [128, 0, 0, 0, 1]))
-big_integer(base_2, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_8, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_16, i(5, [255, 16383, 16383, 16383, 16383]))
-big_integer(base_10, i(8, [3155, 7268, 4662, 4920, 12374, 12447, 15630, 7857]))
+integer(base_10, i(5, [128, 0, 0, 0, 1]), signed, size_word)
+integer(base_2, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_8, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_16, i(5, [255, 16383, 16383, 16383, 16383]), signed, size_word)
+integer(base_10, i(8, [3155, 7268, 4662, 4920, 12374, 12447, 15630, 7857]), signed, size_word)
diff --git a/tests/hard_coded/lexer_zero.exp b/tests/hard_coded/lexer_zero.exp
index dfe7505..5e08feb 100644
--- a/tests/hard_coded/lexer_zero.exp
+++ b/tests/hard_coded/lexer_zero.exp
@@ -1,20 +1,20 @@
-integer(base_10, 0)
-integer(base_10, 12345678)
-integer(base_10, 10)
-integer(base_10, 97)
-integer(base_10, 97)
+integer(base_10, i(0, []), signed, size_word)
+integer(base_10, i(2, [753, 8526]), signed, size_word)
+integer(base_10, i(1, [10]), signed, size_word)
+integer(base_10, i(1, [97]), signed, size_word)
+integer(base_10, i(1, [97]), signed, size_word)
  name("bc")
-integer(base_2, 0)
-integer(base_2, 1)
-integer(base_2, 3)
-integer(base_2, 7)
-integer(base_8, 0)
-integer(base_8, 1)
-integer(base_8, 342391)
-integer(base_16, 1)
-integer(base_16, 305419896)
-integer(base_16, 162254319)
-integer(base_16, 162254319)
+integer(base_2, i(0, []), signed, size_word)
+integer(base_2, i(1, [1]), signed, size_word)
+integer(base_2, i(1, [3]), signed, size_word)
+integer(base_2, i(1, [7]), signed, size_word)
+integer(base_8, i(0, []), signed, size_word)
+integer(base_8, i(1, [1]), signed, size_word)
+integer(base_8, i(2, [20, 14711]), signed, size_word)
+integer(base_16, i(1, [1]), signed, size_word)
+integer(base_16, i(3, [1, 2257, 5752]), signed, size_word)
+integer(base_16, i(2, [9903, 3567]), signed, size_word)
+integer(base_16, i(2, [9903, 3567]), signed, size_word)
  float(0.123)
  float(1.23e+44)
  float(0.0)
@@ -22,23 +22,23 @@ float(0.0)
  float(0.0)
  float(0.0)

-integer(base_10, 0)
-integer(base_10, 12345678)
-integer(base_10, 10)
-integer(base_10, 97)
-integer(base_10, 97)
+integer(base_10, i(0, []), signed, size_word)
+integer(base_10, i(2, [753, 8526]), signed, size_word)
+integer(base_10, i(1, [10]), signed, size_word)
+integer(base_10, i(1, [97]), signed, size_word)
+integer(base_10, i(1, [97]), signed, size_word)
  name("bc")
-integer(base_2, 0)
-integer(base_2, 1)
-integer(base_2, 3)
-integer(base_2, 7)
-integer(base_8, 0)
-integer(base_8, 1)
-integer(base_8, 342391)
-integer(base_16, 1)
-integer(base_16, 305419896)
-integer(base_16, 162254319)
-integer(base_16, 162254319)
+integer(base_2, i(0, []), signed, size_word)
+integer(base_2, i(1, [1]), signed, size_word)
+integer(base_2, i(1, [3]), signed, size_word)
+integer(base_2, i(1, [7]), signed, size_word)
+integer(base_8, i(0, []), signed, size_word)
+integer(base_8, i(1, [1]), signed, size_word)
+integer(base_8, i(2, [20, 14711]), signed, size_word)
+integer(base_16, i(1, [1]), signed, size_word)
+integer(base_16, i(3, [1, 2257, 5752]), signed, size_word)
+integer(base_16, i(2, [9903, 3567]), signed, size_word)
+integer(base_16, i(2, [9903, 3567]), signed, size_word)
  float(0.123)
  float(1.23e+44)
  float(0.0)
diff --git a/tests/hard_coded/parse_number_from_string.exp b/tests/hard_coded/parse_number_from_string.exp
index 226c8fb..3f57069 100644
--- a/tests/hard_coded/parse_number_from_string.exp
+++ b/tests/hard_coded/parse_number_from_string.exp
@@ -10,7 +10,7 @@ read_term("-1_0.") = functor(integer(base_10, i(-1, [-10]), signed, size_word),
  read_term("01.") = functor(integer(base_10, i(1, [1]), signed, size_word), [], context("", 1))
  read_term("0_1.") = functor(integer(base_10, i(1, [1]), signed, size_word), [], context("", 1))
  read_term("1_000_000_000_000_000_000_000.") = functor(integer(base_10, i(5, [13877, 12907, 7261, 14976, 0]), signed, size_word), [], context("", 1))
-read_term("-1_000_000_000_000_000_000_000.") = functor(atom("-"), [functor(integer(base_10, i(5, [13877, 12907, 7261, 14976, 0]), signed, size_word), [], context("", 1))], context("", 1))
+read_term("-1_000_000_000_000_000_000_000.") = functor(integer(base_10, i(-5, [-13877, -12907, -7261, -14976, 0]), signed, size_word), [], context("", 1))

  Invalid decimal literals:
  read_term("123_.") = Syntax error: unterminated decimal literal
@@ -61,7 +61,7 @@ read_term("-0xf_f.") = functor(integer(base_16, i(-1, [-255]), signed, size_word
  read_term("0x_f_f__f.") = functor(integer(base_16, i(1, [4095]), signed, size_word), [], context("", 1))
  read_term("-0x_f_f__f.") = functor(integer(base_16, i(-1, [-4095]), signed, size_word), [], context("", 1))
  read_term("0xfffffffffffffffffffffffff.") = functor(integer(base_16, i(8, [3, 16383, 16383, 16383, 16383, 16383, 16383, 16383]), signed, size_word), [], context("", 1))
-read_term("-0xfffffffffffffffffffffffff.") = functor(atom("-"), [functor(integer(base_16, i(8, [3, 16383, 16383, 16383, 16383, 16383, 16383, 16383]), signed, size_word), [], context("", 1))], context("", 1))
+read_term("-0xfffffffffffffffffffffffff.") = functor(integer(base_16, i(-8, [-3, -16383, -16383, -16383, -16383, -16383, -16383, -16383]), signed, size_word), [], context("", 1))

  Invalid hexadecimal literals:
  read_term("0x.") = Syntax error: unterminated hexadecimal literal


More information about the reviews mailing list