fix broken conformity tests, quote left paren

This commit is contained in:
Mark Thom
2020-03-08 16:49:47 -06:00
parent c7591045af
commit eee10d3ee7
7 changed files with 38 additions and 5 deletions

View File

@@ -241,6 +241,7 @@ pub enum SystemClauseType {
GetDoubleQuotes,
InstallNewBlock,
Maybe,
QuotedToken,
RawInputReadChar,
ResetBlock,
ReturnFromVerifyAttr,
@@ -359,6 +360,9 @@ impl SystemClauseType {
&SystemClauseType::PointsToContinuationResetMarker => {
clause_name!("$points_to_cont_reset_marker")
}
&SystemClauseType::QuotedToken => {
clause_name!("$quoted_token")
}
&SystemClauseType::RawInputReadChar => clause_name!("$raw_input_read_char"),
&SystemClauseType::RedoAttrVarBinding => clause_name!("$redo_attr_var_binding"),
&SystemClauseType::RemoveCallPolicyCheck => clause_name!("$remove_call_policy_check"),
@@ -494,6 +498,7 @@ impl SystemClauseType {
("$get_current_block", 1) => Some(SystemClauseType::GetCurrentBlock),
("$get_cp", 1) => Some(SystemClauseType::GetCutPoint),
("$install_new_block", 1) => Some(SystemClauseType::InstallNewBlock),
("$quoted_token", 1) => Some(SystemClauseType::QuotedToken),
("$raw_input_read_char", 1) => Some(SystemClauseType::RawInputReadChar),
("$nextEP", 3) => Some(SystemClauseType::NextEP),
("$read_query_term", 2) => Some(SystemClauseType::ReadQueryTerm),

View File

@@ -396,6 +396,7 @@ fn non_quoted_graphic_token<Iter: Iterator<Item = char>>(mut iter: Iter, c: char
}
}
pub(super)
fn non_quoted_token<Iter: Iterator<Item = char>>(mut iter: Iter) -> bool {
if let Some(c) = iter.next() {
if small_letter_char!(c) {
@@ -411,7 +412,7 @@ fn non_quoted_token<Iter: Iterator<Item = char>>(mut iter: Iter) -> bool {
} else if c == '{' {
(iter.next() == Some('}') && iter.next().is_none())
} else if solo_char!(c) {
!(c == ')' || c == '}' || c == ']' || c == ',' || c == '%' || c == '|')
!(c == '(' || c == ')' || c == '}' || c == ']' || c == ',' || c == '%' || c == '|')
} else {
false
}

View File

@@ -194,6 +194,7 @@ impl SubModuleUser for IndexStore {
#[inline]
fn current_dir() -> std::path::PathBuf {
let mut path_buf = std::path::PathBuf::from(PROJECT_DIR);
// file!() always produces a path relative to PROJECT_DIR.
path_buf = path_buf.join(std::path::PathBuf::from(file!()));

View File

@@ -2342,6 +2342,31 @@ impl MachineState {
self.fail = true;
return Ok(());
}
&SystemClauseType::QuotedToken => {
let addr = self.store(self.deref(self[temp_v!(1)].clone()));
match addr {
Addr::Con(Constant::CharCode(c)) => {
self.fail = match std::char::from_u32(c) {
Some(c) => {
non_quoted_token(once(c))
}
None => {
true
}
};
}
Addr::Con(Constant::Char(c)) => {
self.fail = non_quoted_token(once(c));
}
Addr::Con(Constant::Atom(atom, _)) => {
self.fail = non_quoted_token(atom.as_str().chars());
}
_ => {
self.fail = true;
}
}
}
&SystemClauseType::ReadQueryTerm => {
readline::set_prompt(true);
let result = self.read_term(current_input_stream, indices);

View File

@@ -60,6 +60,7 @@
_,
false),
( EqPrec < FPrec -> true
; '$quoted_token'(F) -> true
; EqPrec == FPrec,
memberchk(EqSpec, [fx,xfx,yfx])
).