quote solo characters wherever they lead atoms

This commit is contained in:
Mark Thom
2019-05-05 22:48:19 -04:00
parent bf8a2ab6a6
commit 3547ae2db4
7 changed files with 14 additions and 9 deletions

View File

@@ -12,6 +12,7 @@ default = ["readline_rs_compat"]
[dependencies] [dependencies]
cfg-if = "0.1.7" cfg-if = "0.1.7"
downcast = "0.10.0" downcast = "0.10.0"
indexmap = "1.0.2"
num = "0.2" num = "0.2"
ordered-float = "0.5.0" ordered-float = "0.5.0"
prolog_parser = "0.8.26" prolog_parser = "0.8.26"

View File

@@ -1,5 +1,6 @@
#[macro_use] extern crate cfg_if; #[macro_use] extern crate cfg_if;
#[macro_use] extern crate downcast; #[macro_use] extern crate downcast;
extern crate indexmap;
#[macro_use] extern crate prolog_parser; #[macro_use] extern crate prolog_parser;
#[macro_use] extern crate ref_thread_local; #[macro_use] extern crate ref_thread_local;

View File

@@ -1,3 +1,5 @@
use indexmap::IndexMap;
use prolog_parser::ast::*; use prolog_parser::ast::*;
use prolog::allocator::*; use prolog::allocator::*;
@@ -11,7 +13,7 @@ use std::collections::{BTreeSet, HashMap};
use std::rc::Rc; use std::rc::Rc;
pub struct DebrayAllocator { pub struct DebrayAllocator {
bindings: HashMap<Rc<Var>, VarData>, bindings: IndexMap<Rc<Var>, VarData>,
arg_c: usize, arg_c: usize,
temp_lb: usize, temp_lb: usize,
arity: usize, // 0 if not at head. arity: usize, // 0 if not at head.
@@ -207,7 +209,7 @@ impl<'a> Allocator<'a> for DebrayAllocator
arity: 0, arity: 0,
arg_c: 1, arg_c: 1,
temp_lb: 1, temp_lb: 1,
bindings: HashMap::new(), bindings: IndexMap::new(),
contents: HashMap::new(), contents: HashMap::new(),
in_use: BTreeSet::new() in_use: BTreeSet::new()
} }

View File

@@ -384,12 +384,12 @@ fn non_quoted_token<Iter: Iterator<Item=char>>(mut iter: Iter) -> bool {
iter.next().is_none() iter.next().is_none()
} else if cut_char!(c) { } else if cut_char!(c) {
iter.next().is_none() iter.next().is_none()
} else if solo_char!(c) {
!iter.next().is_none()
} else if c == '[' { } else if c == '[' {
(iter.next() == Some(']') && iter.next().is_none()) (iter.next() == Some(']') && iter.next().is_none())
} else if c == '{' { } else if c == '{' {
(iter.next() == Some('}') && iter.next().is_none()) (iter.next() == Some('}') && iter.next().is_none())
} else if solo_char!(c) {
false // !iter.next().is_none()
} else { } else {
false false
} }

View File

@@ -249,10 +249,9 @@ must_be_var_names_list_([]).
must_be_var_names_list_([VarName | VarNames]) :- must_be_var_names_list_([VarName | VarNames]) :-
( nonvar(VarName), VarName = (Atom = _) -> ( nonvar(VarName), VarName = (Atom = _) ->
( atom(Atom) -> must_be_var_names_list_(VarNames) ( atom(Atom) -> must_be_var_names_list_(VarNames)
; var(Atom) -> throw(error(instantiation_error, write_term/2))
; throw(error(domain_error(write_options, variable_names(VarName)), write_term/2)) ; throw(error(domain_error(write_options, variable_names(VarName)), write_term/2))
) )
; throw(error(instantiation_error, write_term/2)) ; throw(error(domain_error(write_options, variable_names(VarName)), write_term/2))
). ).
write_term(_, Options) :- write_term(_, Options) :-

View File

@@ -1,3 +1,5 @@
use indexmap::IndexMap;
use prolog_parser::ast::*; use prolog_parser::ast::*;
use prolog_parser::tabled_rc::*; use prolog_parser::tabled_rc::*;
@@ -412,8 +414,8 @@ impl AddAssign<usize> for CodePtr {
} }
} }
pub type HeapVarDict = HashMap<Rc<Var>, Addr>; pub type HeapVarDict = IndexMap<Rc<Var>, Addr>;
pub type AllocVarDict = HashMap<Rc<Var>, VarData>; pub type AllocVarDict = IndexMap<Rc<Var>, VarData>;
#[derive(Clone)] #[derive(Clone)]
pub struct DynamicPredicateInfo { pub struct DynamicPredicateInfo {

View File

@@ -1558,7 +1558,7 @@ impl MachineState {
let mut list_of_var_eqs = vec![]; let mut list_of_var_eqs = vec![];
for (var, binding) in term_write_result.var_dict { for (var, binding) in term_write_result.var_dict.into_iter().rev() {
let var_atom = clause_name!(var.to_string(), indices.atom_tbl); let var_atom = clause_name!(var.to_string(), indices.atom_tbl);
let var_atom = Constant::Atom(var_atom, None); let var_atom = Constant::Atom(var_atom, None);