book_string_simple/
book_string_simple.rs1fn main() -> trivet::errors::ParseResult<()> {
2 let mut parser = trivet::parse_from_stdin();
3 while !parser.is_at_eof() {
4 let loc = parser.loc();
6 let string = match parser.peek() {
8 '"' | '\'' => parser.parse_string_match_delimiter_ws()?,
10 '«' => {
12 parser.consume();
13 parser.parse_string_until_delimiter_ws('»')?
14 }
15 ch => {
17 return Err(trivet::errors::syntax_error(
18 loc,
19 &format!("Invalid delimiter: '{}'", ch),
20 ));
21 }
22 };
23 println!(" --> {:?}", string);
24 }
25 Ok(())
26}