update prolog_parser, refine bracketing tests.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scryer-prolog"
|
name = "scryer-prolog"
|
||||||
version = "0.8.50"
|
version = "0.8.51"
|
||||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||||
repository = "https://github.com/mthom/scryer-prolog"
|
repository = "https://github.com/mthom/scryer-prolog"
|
||||||
description = "A modern Prolog implementation written mostly in Rust."
|
description = "A modern Prolog implementation written mostly in Rust."
|
||||||
@@ -14,7 +14,7 @@ cfg-if = "0.1.7"
|
|||||||
downcast = "0.10.0"
|
downcast = "0.10.0"
|
||||||
num = "0.2"
|
num = "0.2"
|
||||||
ordered-float = "0.5.0"
|
ordered-float = "0.5.0"
|
||||||
prolog_parser = "0.8.17"
|
prolog_parser = "0.8.18"
|
||||||
readline_rs_compat = { version = "0.1.7", optional = true }
|
readline_rs_compat = { version = "0.1.7", optional = true }
|
||||||
ref_thread_local = "0.0.0"
|
ref_thread_local = "0.0.0"
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ impl DirectedOp {
|
|||||||
name.as_str() == "-" && is_prefix!(cell.assoc())
|
name.as_str() == "-" && is_prefix!(cell.assoc())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_left(&self) -> bool {
|
||||||
|
if let &DirectedOp::Left(..) = self {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn needs_bracketing(child_spec: &SharedOpDesc, op: &DirectedOp) -> bool
|
fn needs_bracketing(child_spec: &SharedOpDesc, op: &DirectedOp) -> bool
|
||||||
@@ -62,7 +71,7 @@ fn needs_bracketing(child_spec: &SharedOpDesc, op: &DirectedOp) -> bool
|
|||||||
if child_spec.prec() > priority || (child_spec.prec() == priority && is_strict_left) {
|
if child_spec.prec() > priority || (child_spec.prec() == priority && is_strict_left) {
|
||||||
true
|
true
|
||||||
} else if (is_postfix!(spec) || is_infix!(spec)) && !is_postfix!(child_spec.assoc()) {
|
} else if (is_postfix!(spec) || is_infix!(spec)) && !is_postfix!(child_spec.assoc()) {
|
||||||
child_spec.prec() == priority
|
!SharedOpDesc::ptr_eq(&cell, &child_spec) && child_spec.prec() == priority
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -281,7 +290,9 @@ macro_rules! push_space_if_amb {
|
|||||||
fn requires_space(atom: &str, op: &str) -> bool {
|
fn requires_space(atom: &str, op: &str) -> bool {
|
||||||
match atom.chars().last() {
|
match atom.chars().last() {
|
||||||
Some(ac) => op.chars().next().map(|oc| {
|
Some(ac) => op.chars().next().map(|oc| {
|
||||||
if alpha_numeric_char!(ac) {
|
if ac == '0' {
|
||||||
|
oc == 'b' || oc == 'x' || oc == 'o' || !non_quoted_token(op.chars())
|
||||||
|
} else if alpha_numeric_char!(ac) {
|
||||||
oc == '(' || alpha_numeric_char!(oc)
|
oc == '(' || alpha_numeric_char!(oc)
|
||||||
} else if graphic_token_char!(ac) {
|
} else if graphic_token_char!(ac) {
|
||||||
graphic_token_char!(oc)
|
graphic_token_char!(oc)
|
||||||
@@ -293,8 +304,6 @@ fn requires_space(atom: &str, op: &str) -> bool {
|
|||||||
sign_char!(oc) || decimal_digit_char!(oc)
|
sign_char!(oc) || decimal_digit_char!(oc)
|
||||||
} else if single_quote_char!(ac) {
|
} else if single_quote_char!(ac) {
|
||||||
single_quote_char!(oc)
|
single_quote_char!(oc)
|
||||||
} else if ac == '0' {
|
|
||||||
oc == 'b' || oc == 'x' || oc == 'o' || !non_quoted_token(op.chars())
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -808,7 +817,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
self.state_stack.push(TokenOrRedirect::Open);
|
self.state_stack.push(TokenOrRedirect::Open);
|
||||||
|
|
||||||
if let Some(ref op) = &op {
|
if let Some(ref op) = &op {
|
||||||
if requires_space(op.as_str(), "(") {
|
if op.is_left() && requires_space(op.as_str(), "(") {
|
||||||
self.state_stack.push(TokenOrRedirect::Space);
|
self.state_stack.push(TokenOrRedirect::Space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user