Skip to content

Commit 0997493

Browse files
authored
Merge pull request #5376 from cakebaker/expr_add_empty_lines
expr: add some empty lines
2 parents 94f5fa9 + 7e08562 commit 0997493

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/uu/expr/src/syntax_tree.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ pub enum AstNode {
3131
operands: OperandsList,
3232
},
3333
}
34+
3435
impl AstNode {
3536
fn debug_dump(&self) {
3637
self.debug_dump_impl(1);
3738
}
39+
3840
fn debug_dump_impl(&self, depth: usize) {
3941
for _ in 0..depth {
4042
print!("\t",);
@@ -71,12 +73,14 @@ impl AstNode {
7173
operands,
7274
})
7375
}
76+
7477
fn new_leaf(token_idx: usize, value: &str) -> Box<Self> {
7578
Box::new(Self::Leaf {
7679
token_idx,
7780
value: value.into(),
7881
})
7982
}
83+
8084
pub fn evaluate(&self) -> Result<String, String> {
8185
match self {
8286
Self::Leaf { value, .. } => Ok(value.clone()),
@@ -154,6 +158,7 @@ impl AstNode {
154158
},
155159
}
156160
}
161+
157162
pub fn operand_values(&self) -> Result<Vec<String>, String> {
158163
if let Self::Node {
159164
operands, op_type, ..
@@ -257,6 +262,7 @@ fn ast_from_rpn(rpn: &mut TokenStack) -> Result<Box<AstNode>, String> {
257262
}
258263
}
259264
}
265+
260266
fn maybe_ast_node(
261267
token_idx: usize,
262268
op_type: &str,
@@ -520,13 +526,15 @@ fn prefix_operator_substr(values: &[String]) -> String {
520526
fn bool_as_int(b: bool) -> u8 {
521527
u8::from(b)
522528
}
529+
523530
fn bool_as_string(b: bool) -> String {
524531
if b {
525532
"1".to_string()
526533
} else {
527534
"0".to_string()
528535
}
529536
}
537+
530538
fn value_as_bool(s: &str) -> bool {
531539
if s.is_empty() {
532540
return false;

src/uu/expr/src/tokens.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub enum Token {
3838
value: String,
3939
},
4040
}
41+
4142
impl Token {
4243
fn new_infix_op(v: &str, left_assoc: bool, precedence: u8) -> Self {
4344
Self::InfixOp {
@@ -46,6 +47,7 @@ impl Token {
4647
value: v.into(),
4748
}
4849
}
50+
4951
fn new_value(v: &str) -> Self {
5052
Self::Value { value: v.into() }
5153
}
@@ -56,12 +58,14 @@ impl Token {
5658
_ => false,
5759
}
5860
}
61+
5962
fn is_a_number(&self) -> bool {
6063
match self {
6164
Self::Value { value, .. } => value.parse::<BigInt>().is_ok(),
6265
_ => false,
6366
}
6467
}
68+
6569
fn is_a_close_paren(&self) -> bool {
6670
matches!(*self, Self::ParClose)
6771
}

0 commit comments

Comments
 (0)