finish #214, add needed ambiguity checks if 0 is the final character

This commit is contained in:
Mark Thom
2019-10-27 19:23:35 -06:00
parent 0dcd9e5805
commit e594ade84d
4 changed files with 28 additions and 18 deletions

View File

@@ -329,8 +329,7 @@ pub fn requires_space(atom: &str, op: &str) -> bool {
.next()
.map(|oc| {
if ac == '0' {
oc == 'b' || oc == 'x' || oc == 'o' || oc == '\''
|| oc == '(' || alpha_numeric_char!(oc)
oc == '\'' || oc == '(' || alpha_numeric_char!(oc)
} else if alpha_numeric_char!(ac) {
oc == '(' || alpha_numeric_char!(oc)
} else if graphic_token_char!(ac) {

View File

@@ -1015,8 +1015,8 @@ fn compile_work_impl(
if let Some(mut module) = compiler.module.take() {
if module.is_impromptu_module {
module.module_decl.exports = indices.code_dir.keys().cloned()
.filter(|(name, _)| name.owning_module().as_str() != "builtins")
.collect();
.filter(|(name, _)| name.owning_module().as_str() != "builtins")
.collect();
}
let mut clause_code_generator =
@@ -1030,9 +1030,18 @@ fn compile_work_impl(
wam.indices.remove_module(clause_name!("user"), module);
}
add_module_code(wam, module, module_code, indices);
add_toplevel_code(wam, toplvl_code, results.toplevel_indices);
if module.is_impromptu_module {
add_module_code(wam, module, module_code, indices);
let module = wam.indices.take_module(compiler.listing_src.clone()).unwrap();
wam.indices.use_module(&mut wam.code_repo, wam.machine_st.flags, &module)?;
wam.indices.insert_module(module);
} else {
add_module_code(wam, module, module_code, indices);
}
add_toplevel_code(wam, toplvl_code, results.toplevel_indices);
clause_code_generator.add_clause_code(wam, results.dynamic_clause_map);
} else {
add_non_module_code(

View File

@@ -456,14 +456,15 @@ impl Machine {
};
let result = load_result.and_then(|name| {
let module = self.indices.take_module(name.clone()).unwrap();
let module = self.indices.take_module(name.clone()).unwrap();
self.indices.use_module(&mut self.code_repo, self.machine_st.flags,
&module)?;
Ok(self.indices.insert_module(module))
if !module.is_impromptu_module {
self.indices.use_module(&mut self.code_repo, self.machine_st.flags, &module)?;
}
Ok(self.indices.insert_module(module))
});
self.code_repo.cached_query = cached_query;
if let Err(e) = result {
@@ -502,10 +503,12 @@ impl Machine {
let result = load_result.and_then(|name| {
let module = self.indices.take_module(name.clone()).unwrap();
self.indices.use_qualified_module(&mut self.code_repo,
self.machine_st.flags,
&module,
&exports)?;
if !module.is_impromptu_module {
self.indices.use_qualified_module(&mut self.code_repo,
self.machine_st.flags,
&module,
&exports)?;
}
Ok(self.indices.insert_module(module))
});

View File

@@ -28,9 +28,8 @@
'$$compile_batch' :- '$compile_batch'.
'$instruction_match'([Item], []) :-
( atom(Item) ->
( atom(Item) -> !,
( Item == user ->
!,
catch('$$compile_batch', E, '$print_exception_with_check'(E))
; consult(Item)
)