Skip to content

Commit 1118182

Browse files
committed
Small adjustments for integration
1 parent 228d10a commit 1118182

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl std::fmt::Debug for Span {
3232
}
3333

3434
#[rustfmt::skip]
35-
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, strum::EnumString, strum::Display)]
35+
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug, strum::EnumString, strum::Display)]
3636
pub enum BinOp {
3737
#[strum(serialize = "+") ] Plus,
3838
#[strum(serialize = "-") ] Minus,
@@ -49,13 +49,13 @@ pub enum BinOp {
4949
#[strum(serialize = "=~")] RegexMatch,
5050
}
5151

52-
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, strum::EnumString, strum::Display)]
52+
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug, strum::EnumString, strum::Display)]
5353
pub enum UnaryOp {
5454
#[strum(serialize = "!")]
5555
Not,
5656
}
5757

58-
#[derive(Clone, PartialEq, Serialize, Deserialize)]
58+
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
5959
pub enum SimplExpr {
6060
Literal(Span, DynVal),
6161
VarRef(Span, String),

src/dynval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl ConversionError {
2323
}
2424
}
2525

26-
#[derive(Clone, Deserialize, Serialize, Default)]
26+
#[derive(Clone, Deserialize, Serialize, Default, Eq)]
2727
pub struct DynVal(pub String, pub Option<Span>);
2828

2929
impl MaybeSpanned for DynVal {

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ pub mod dynval;
66
pub mod error;
77
pub mod eval;
88
pub mod parser;
9+
use ast::SimplExpr;
910
use lalrpop_util::lalrpop_mod;
1011

1112
lalrpop_mod!(pub simplexpr_parser);
13+
14+
pub fn parse_string(s: &str) -> Result<SimplExpr, error::Error> {
15+
parser::parse_string(s)
16+
}
17+
pub use ast::Span;

src/parser/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use logos::Logos;
22

33
#[rustfmt::skip]
4-
#[derive(Logos, Debug, PartialEq, Eq, Clone, strum::Display)]
4+
#[derive(Logos, Debug, PartialEq, Eq, Clone, strum::Display, strum::EnumString)]
55
pub enum Token {
66
#[strum(serialize = "+") ] #[token("+") ] Plus,
77
#[strum(serialize = "-") ] #[token("-") ] Minus,

0 commit comments

Comments
 (0)