Extend the lexer to recognise uint literals, optional signedness suffixes on
ints and the literals for all of the proposed fixed size integer types.
Fix XXX UINTs in the library and compiler.
library/lexer.m:
Uncomment the other alternatives in the integer_size/0 type.
Handle signedness and size suffixes in integer literals.
library/parser.m
library/term.m:
Conform to the above changes.
library/stream.string_writer.m:
Fix an XXX UINT: make write handle uints properly.
library/term_io.m:
Fix an XXX UINT: output integer signedness and size suffixes for
integers when appropriate.
compiler/superhomogeneous.m:
Print an error message if we encounter a fixed size integer literal
as the rest of the compiler does not yet support them.
compiler/hlds_out_util.m:
compiler/parse_tree_out_info.m:
Output the 'u' suffix on uint values.
test/hard_coded/lexer_zero.{m,inp,exp*}:
Extend this test to cover zeros of varying signedness and size.
Prefix each line of the output with the input line number of the
token -- this makes it easier to relate the output back to the
input.
tests/hard_coded/Mmakefile:
Add the new test case.
tests/hard_coded/lexer_ints.{m,inp,exp}:
Test the lexer on non-zero integer literals.
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.
In preparation for supporting uint literals and literals for the fixed size
integer types, generalise the representation of integers in the term module, so
that for every integer literal we record its base, value (as an arbitrary
precision integer), signedness and size (the latter two based on the literal's
suffix or lack thereof).
Have the lexer attach information about the integer base to machine sized ints;
we already did this for the 'big_integer' alternative but not the normal one.
In conjunction with the first change, this fixes a problem where the compiler
was accepting non-decimal integers in like arity specifications. (The
resulting error messages could be improved, but that's a separate change.)
Support uints in more places; mark other places which require further work with
XXX UINT.
library/term.m:
Generalise the representation of integer terms so that we can store
the base, signedness and size of a integer along with its value.
In the new design the value is always stored as an arbitrary precision
integer so we no longer require the big_integer/2 alternative; delete it.
Add some utility predicates that make it easier to work with integer terms.
library/term_conversion.m:
library/term_io.m:
Conform to the above changes,
Add missing handling for uints in some spots; add XXX UINT comments
in others -- these will be addressed later.
library/lexer.m:
Record the base of word sized integer literals.
library/parser.m:
compiler/analysis_file.m:
compiler/fact_table.m:
compiler/get_dependencies.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/parse_class.m:
compiler/parse_inst_mode_name.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
mdbcomp/trace_counts.m:
samples/calculator2.m:
extras/moose/moose.m:
Conform to the above changes.
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*:
tests/hard_coded/term_to_unit_test.exp:
Update these expected outputs.
Branches: main, 11.07
library/lexer.m:
Fix tokenisation of binary, octal and hexadecimal integer literals
in strings. It did not work at all.
tests/hard_coded/Mmakefile:
tests/hard_coded/lexer_zero.exp:
tests/hard_coded/lexer_zero.inp:
tests/hard_coded/lexer_zero.m:
Add test case.