mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
Add support for "implementation-defined literals" $file, $line, $module,
Estimated hours taken: 16 Branches: main Add support for "implementation-defined literals" $file, $line, $module, $pred, $grade which are replaced constants by the compiler. library/lexer.m: Add a new type of token. Read "$foo" as a `implementation_defined' token instead of two name tokens. library/term.m: library/term_io.m: Add a new type of constant, `implementation_defined'. library/parser.m: Handle `implementation_defined' tokens from the lexer. compiler/check_hlds.m: compiler/implementation_defined_literals.m: compiler/mercury_compile.m: Add a new pass to replace implementation-defined literals in program clauses. Call the new pass. compiler/notes/compiler_design.html: Document the new module. compiler/prog_data.m: Add a new option to `cons_id', namely `implementation_defined_const'. compiler/typecheck.m: Tell the typechecker the types of the supported implementation-defined literals. compiler/prog_io_util.m: Make `convert_bound_inst' fail if implementation-defined literals appear in inst definitions so that an error will be issued. compiler/bytecode_gen.m: compiler/ctgc.selector.m: compiler/dead_proc_elim.m: compiler/dependency_graph.m: compiler/erl_unify_gen.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_code_util.m: compiler/hlds_out.m: compiler/inst_check.m: compiler/mercury_to_mercury.m: compiler/mode_util.m: compiler/module_qual.m: compiler/prog_rep.m: compiler/prog_type.m: compiler/prog_util.m: compiler/rbmm.execution_path.m: compiler/unused_imports.m: compiler/xml_documentation.m: Conform to addition of `implementation_defined_const'. doc/reference_manual.texi: Document implementation-defined literals. NEWS: Announce the new feature. tests/hard_coded/Mmakefile: tests/hard_coded/impl_def_lex.exp: tests/hard_coded/impl_def_lex.m: tests/hard_coded/impl_def_lex_string.exp: tests/hard_coded/impl_def_lex_string.m: tests/hard_coded/impl_def_literal.exp: tests/hard_coded/impl_def_literal.m: tests/invalid/Mmakefile: tests/invalid/impl_def_literal_syntax.err_exp: tests/invalid/impl_def_literal_syntax.m: tests/invalid/undef_impl_def_literal.err_exp: tests/invalid/undef_impl_def_literal.m: Add test cases.
This commit is contained in:
@@ -669,6 +669,7 @@ cons_id_arity(cons(_, Arity)) = Arity.
|
||||
cons_id_arity(int_const(_)) = 0.
|
||||
cons_id_arity(string_const(_)) = 0.
|
||||
cons_id_arity(float_const(_)) = 0.
|
||||
cons_id_arity(implementation_defined_const(_)) = 0.
|
||||
cons_id_arity(pred_const(_, _)) =
|
||||
unexpected(this_file, "cons_id_arity: can't get arity of pred_const").
|
||||
cons_id_arity(type_ctor_info_const(_, _, _)) =
|
||||
@@ -696,6 +697,7 @@ cons_id_maybe_arity(cons(_, Arity)) = yes(Arity).
|
||||
cons_id_maybe_arity(int_const(_)) = yes(0).
|
||||
cons_id_maybe_arity(string_const(_)) = yes(0).
|
||||
cons_id_maybe_arity(float_const(_)) = yes(0).
|
||||
cons_id_maybe_arity(implementation_defined_const(_)) = yes(0).
|
||||
cons_id_maybe_arity(pred_const(_, _)) = no.
|
||||
cons_id_maybe_arity(type_ctor_info_const(_, _, _)) = no.
|
||||
cons_id_maybe_arity(base_typeclass_info_const(_, _, _, _)) = no.
|
||||
@@ -709,6 +711,8 @@ make_functor_cons_id(term.atom(Name), Arity) = cons(unqualified(Name), Arity).
|
||||
make_functor_cons_id(term.integer(Int), _) = int_const(Int).
|
||||
make_functor_cons_id(term.string(String), _) = string_const(String).
|
||||
make_functor_cons_id(term.float(Float), _) = float_const(Float).
|
||||
make_functor_cons_id(term.implementation_defined(Name), _) =
|
||||
implementation_defined_const(Name).
|
||||
|
||||
make_cons_id(SymName0, Args, TypeCtor) = cons(SymName, Arity) :-
|
||||
% Use the module qualifier on the SymName, if there is one,
|
||||
|
||||
Reference in New Issue
Block a user