From: Ben Pfaff Date: Mon, 8 Jul 2024 01:03:45 +0000 (-0700) Subject: more segmentation X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83c74cd90a824b4c48541518a63d7cfe8ef8c30a;p=pspp more segmentation --- diff --git a/rust/src/lex/segment.rs b/rust/src/lex/segment.rs index d52dd888fc..ccede6c473 100644 --- a/rust/src/lex/segment.rs +++ b/rust/src/lex/segment.rs @@ -707,13 +707,17 @@ impl Segmenter { } } else if id_match("BEGIN", identifier) { let (next_id, rest2) = self.next_id_in_command(rest, eof)?; + println!("next_id={next_id:?}"); if id_match("DATA", next_id) { + println!("{}:{}", file!(), line!()); let rest2 = skip_spaces_and_comments(rest2, eof)?; + println!("{}:{} {rest2:?}", file!(), line!()); let rest2 = if let Some(s) = rest2.strip_prefix('.') { - skip_spaces(s, eof)? + skip_spaces_and_comments(s, eof)? } else { rest2 }; + println!("{}:{}", file!(), line!()); if is_end_of_line(rest2, eof)? { let s = &input[..input.len() - rest2.len()]; self.state = ( @@ -724,8 +728,10 @@ impl Segmenter { }, Substate::empty(), ); + println!("{}:{}", file!(), line!()); return Ok((rest, Type::Identifier)); } + println!("{}:{}", file!(), line!()); } } } @@ -1506,9 +1512,10 @@ FILE /* ); } - #[test] + #[test] fn test_begin_data() { - print_segmentation(r#"begin data. + print_segmentation( + r#"begin data. end data. begin data. /* @@ -1532,6 +1539,25 @@ begin data "xxx". begin data 123. not data +"#, + ); + } + + #[test] + fn test_do_repeat() { + print_segmentation(r#"do repeat x=a b c + y=d e f. + do repeat a=1 thru 5. +another command. +second command ++ third command. +end /* x */ /* y */ repeat print. +end + repeat. +do + repeat #a=1. + inner command. +end repeat. "#); }