Skip to content

Commit

Permalink
unaryifexpr should allow indexing by IntNum
Browse files Browse the repository at this point in the history
  • Loading branch information
sozysozbot committed Jul 27, 2020
1 parent 9acf7ec commit 2e88b19
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions not_found_in_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ for_enum_statement : FOR_START_ENUM (INT_NUM|IDENTIFIER) FOR_MID_ENUM
```

Actual behavior: seems to allow `INT_NUM|IDENTIFIER|'其'` in the second argument.

### unary_if_expression

spec:
```
unary_if_expression : data|(IDENTIFIER '之'('長'|STRING_LITERAL|IDENTIFIER))|'其' ;
```

Actual behavior: seems to allow `'長'|STRING_LITERAL|IDENTIFIER|INT_NUM`.
4 changes: 4 additions & 0 deletions src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ fn parse_unary_if_expression(mut iter: &mut LexIter<'_>) -> Result<UnaryIfExpr,
Data::Identifier(Identifier(i.to_string())),
Identifier(indexer.to_string()),
))),
lex::Lex::IntNum(int_num) => Ok(UnaryIfExpr::Complex(Value::Index(
Data::Identifier(Identifier(i.to_string())),
interpret_intnum(int_num),
))), // not found in spec.html but exists
_ => Err(Error::SomethingWentWrong(here!())),
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ fn test087() {
fn test088() {
test("test088")
}
#[test]
fn test089() {
test("test089")
}
/// note that fail000.rs currently does not compile as a valid Rust program because of:
/// * `{}` on `Vec<f64>`
/// * ownership
Expand Down
10 changes: 10 additions & 0 deletions test089.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
let mut JIA3 = vec![];
JIA3.push(3.0);
JIA3.push(5.0);
let YI3 = 1.0;
if YI3 < JIA3[2 - 1] {
let _ans1 = YI3;
println!("{}", _ans1);
}
}
7 changes: 7 additions & 0 deletions test089.wy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
吾有一列。名之曰「甲」。充「甲」以三。充「甲」以五。


有數一。名之曰「乙」。
若「乙」小於「甲」之二者。
夫「乙」。書之。
也。

0 comments on commit 2e88b19

Please sign in to comment.