Commit Graph

4 Commits

Author SHA1 Message Date
Julien Fischer
8a6756d307 Update expected outputs for hard_coded/parse_number_from_string.
The expected outputs for the Java and C# grades were not updated after commit
ac57c2f70.

tests/hard_coded/parse_number_from_string.exp[23]:
     Update the expected outputs for this test for Java and C# grades.

tests/hard_coded/parse_number_from_string.m:
     Document what the expected outputs are for.
2025-10-01 16:31:40 +10:00
Zoltan Somogyi
b64f0fbedc Add a "mercury_term_" prefix to lexer.m/parser.m.
library/mercury_term_lexer.m:
library/mercury_term_parser.m:
    As above.

NEWS:
    Announce the change.

browser/interactive_query.m:
compiler/analysis.file.m:
compiler/fact_table.m:
compiler/make.module_dep_file.m:
compiler/parse_module.m:
compiler/parse_tree_out_term.m:
compiler/recompilation.used_file.m:
library/MODULES_DOC:
library/char.m:
library/integer.m:
library/io.m:
library/library.m:
library/ops.m:
library/term.m:
library/term_io.m:
mdbcomp/trace_counts.m:
tests/hard_coded/impl_def_lex.m:
tests/hard_coded/impl_def_lex_string.m:
tests/hard_coded/lco_pack_args_3.m:
tests/hard_coded/lexer_bigint.m:
tests/hard_coded/lexer_ints.m:
tests/hard_coded/lexer_zero.m:
tests/hard_coded/parse_number_from_string.m:
tests/valid_seq/nested_module_bug.m:
    Conform to the change.
2021-12-31 02:38:07 +11:00
Julien Fischer
b3835dd826 Fix bug #430.
The lexer was not allowing underscores between leading zeros in decimal integer
literals and float literals (e.g. 0_0 or 0_0.0).

library/lexer.m:
     Allow underscores in the above cases.

tests/hard_coded/parse_number_from_io.{m,exp,exp2,exp3}:
tests/hard_coded/parse_number_from_string.{m,exp,exp2,exp3}:
     Extend these tests to cover the above cases.

tests/invalid/invalid_binary_literal.err_exp:
tests/invalid/invalid_octal_literal.err_exp:
tests/invalid/invalid_hex_literal.err_exp:
     Conform to the above change.
2017-01-29 14:38:26 +11:00
Julien Fischer
61c4ef7e50 Allow optional underscores in numeric literals.
Allow the optional use of underscores in numeric literals for the purpose of
improving their readability (e.g. by grouping digits etc).  We allow any number
of underscores between digits and also between the radix prefix (if present) and
the initial digit.  (When integer type suffixes are supported we will also
allow them to be preceded by any number of underscores.)  The following are
*not* allowed:

   1. Leading underscores.
   2. Trailing underscores.
   3. Underscores inside the components of a radix prefix (e.g.
      0_xffff or 0__b101010.)
   4. Underscores immediately adjacent to the decimal point in a float
      literal (e.g. 123_._123.)
   5. Underscores immediately adjacent to the exponent ('e' or 'E) in
      a float literal (e.g. 123_e12 or 123E_12.)
   6. Underscores immediately adjacent to the optional sign of an exponent
      in a float literal (e.g. 123_+e12 or 123-_E12.)
   7. Underscores between the optional sign of an exponent and the exponent
      indicator (e.g. 123+_e12.)

library/lexer.m:
    Modify the scanner to account of underscores in numeric literals according
    to the scheme above.

library/string.m:
library/integer.m:
    Export undocumented functions for converting strings containing underscores
    into ints or integers respectively.

tests/hard_coded/parse_number_from_io.{m,exp}:
     Test parsing of valid numeric literals from file streams.

tests/hard_coed/parse_number_from_string.{m,exp}:
     Test parsing of valid and invalid numeric literal from string.

tests/invalid/invalid_binary_literal.{m,err_exp}:
tests/invalid/invalid_decimal_literal.{m,err_exp}:
tests/invalid/invalid_octal_literal.{m,err_exp}:
tests/invalid/invalid_hex_literal.{m,err_exp}:
tests/invalid/invalid_float_literal.{m,err_exp}:
      Test parsing of invalid numeric literals from file streams.

tests/hard_coded/parse_number_from_{io,string}.m:
tests/hard_coded/parse_number_from_{io,string}.exp:
     Test parsing of valid numeric literals.

tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
     Add the new test cases.
2017-01-12 01:10:31 +11:00