Skip to content

Commit cc4776d

Browse files
authored
Fix missing paren in text (#7)
2 parents 87c71eb + d5a5504 commit cc4776d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/parser.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ fn parse_items(input: Vec<LexItem>) -> Result<Vec<GrammarItem>, ParseError> {
148148
*text += "\n"
149149
}
150150
}
151-
_ => {}
151+
LexItem::Paren(v) => {
152+
if let Some(GrammarItem::Text(text)) = grammar_items.last_mut() {
153+
*text += &v.to_string()
154+
}
155+
}
152156
}
153157
}
154158

@@ -175,6 +179,22 @@ mod test {
175179
);
176180
}
177181

182+
#[test]
183+
pub fn paren_in_notation() {
184+
let result = parse("@note hoge_t = {a, b, c}".into()).unwrap();
185+
assert_eq!(
186+
result,
187+
vec![
188+
GrammarItem::Notation {
189+
meta: vec![],
190+
params: vec![],
191+
tag: "note".into(),
192+
},
193+
GrammarItem::Text("hoge_t = {a, b, c}".into())
194+
]
195+
);
196+
}
197+
178198
#[test]
179199
pub fn param() {
180200
let result =

0 commit comments

Comments
 (0)