Skip to content

Commit

Permalink
eliminate Constant::CharCode
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed May 17, 2020
1 parent 7b51a9d commit 11d692d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prolog_parser"
version = "0.8.57"
version = "0.8.58"
authors = ["Mark Thom <[email protected]>"]
repository = "https://github.com/mthom/prolog_parser"
description = " An operator precedence parser for rusty-wam, an up and coming ISO Prolog implementation."
Expand Down
14 changes: 0 additions & 14 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ impl Hash for SharedOpDesc {
pub enum Constant {
Atom(ClauseName, Option<SharedOpDesc>),
Char(char),
CharCode(u32),
EmptyList,
Fixnum(isize),
Integer(Rc<Integer>),
Expand All @@ -527,8 +526,6 @@ impl fmt::Display for Constant {
},
&Constant::Char(c) =>
write!(f, "'{}'", c as u32),
&Constant::CharCode(c) =>
write!(f, "{}", c),
&Constant::EmptyList =>
write!(f, "[]"),
&Constant::Fixnum(n) =>
Expand Down Expand Up @@ -558,17 +555,6 @@ impl PartialEq for Constant {
a1.as_str() == a2.as_str(),
(&Constant::Char(c1), &Constant::Char(c2)) =>
c1 == c2,
(&Constant::CharCode(c1), &Constant::CharCode(c2)) =>
c1 == c2,
(&Constant::Char(c1), &Constant::CharCode(c2))
| (&Constant::CharCode(c2), &Constant::Char(c1)) =>
c1 as u32 == c2,
(&Constant::CharCode(c1), &Constant::Integer(ref c2))
| (&Constant::Integer(ref c2), &Constant::CharCode(c1)) =>
match c2.to_u32() {
Some(c2) => c1 == c2,
None => false
},
(&Constant::Fixnum(n1), &Constant::Fixnum(n2)) =>
n1 == n2,
(&Constant::Fixnum(n1), &Constant::Integer(ref n2)) |
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl<'a, R: Read> Lexer<'a, R> {
} else if single_quote_char!(c) {
self.skip_char()?;
self.get_single_quoted_char()
.map(|c| Token::Constant(Constant::CharCode(c as u32)))
.map(|c| Token::Constant(Constant::Fixnum(c as isize)))
.or_else(|_| {
self.return_char(c);

Expand Down

0 comments on commit 11d692d

Please sign in to comment.