Skip to content

Commit

Permalink
Fix missing paren in text (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Techie-Pi authored May 21, 2023
2 parents 87c71eb + d5a5504 commit cc4776d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ fn parse_items(input: Vec<LexItem>) -> Result<Vec<GrammarItem>, ParseError> {
*text += "\n"
}
}
_ => {}
LexItem::Paren(v) => {
if let Some(GrammarItem::Text(text)) = grammar_items.last_mut() {
*text += &v.to_string()
}
}
}
}

Expand All @@ -175,6 +179,22 @@ mod test {
);
}

#[test]
pub fn paren_in_notation() {
let result = parse("@note hoge_t = {a, b, c}".into()).unwrap();
assert_eq!(
result,
vec![
GrammarItem::Notation {
meta: vec![],
params: vec![],
tag: "note".into(),
},
GrammarItem::Text("hoge_t = {a, b, c}".into())
]
);
}

#[test]
pub fn param() {
let result =
Expand Down

0 comments on commit cc4776d

Please # to comment.