use crate::prompt::PromptStyle;
-use super::{Mode, Segmenter, Type};
+use super::{Mode, Segmenter, Segment};
-fn push_segment<'a>(segmenter: &mut Segmenter, input: &'a str, one_byte: bool) -> (&'a str, Type) {
+fn push_segment<'a>(segmenter: &mut Segmenter, input: &'a str, one_byte: bool) -> (&'a str, Segment) {
if one_byte {
for len in input.char_indices().map(|(pos, _c)| pos) {
- if let Ok((rest, type_)) = segmenter.push(&input[..len], false) {
- return (&input[len - rest.len()..], type_);
+ if let Ok((rest, segment)) = segmenter.push(&input[..len], false) {
+ return (&input[len - rest.len()..], segment);
}
}
}
fn _check_segmentation(
mut input: &str,
mode: Mode,
- expect_segments: &[(Type, &str)],
+ expect_segments: &[(Segment, &str)],
expect_prompts: &[PromptStyle],
one_byte: bool,
) {
let mut prompts = Vec::new();
let mut segmenter = Segmenter::new(mode, false);
loop {
- let (rest, type_) = push_segment(&mut segmenter, input, one_byte);
+ let (rest, segment) = push_segment(&mut segmenter, input, one_byte);
let len = input.len() - rest.len();
let token = &input[..len];
- segments.push((type_, token));
- match type_ {
- Type::End => break,
- Type::Newline => prompts.push(segmenter.prompt()),
+ segments.push((segment, token));
+ match segment {
+ Segment::End => break,
+ Segment::Newline => prompts.push(segmenter.prompt()),
_ => (),
}
input = rest;
fn check_segmentation(
input: &str,
mode: Mode,
- expect_segments: &[(Type, &str)],
+ expect_segments: &[(Segment, &str)],
expect_prompts: &[PromptStyle],
) {
for (one_byte, one_byte_name) in [(false, "full-string"), (true, "byte-by-byte")] {
mode,
&expect_segments
.iter()
- .map(|(type_, s)| match *type_ {
- Type::Newline => (Type::Newline, "\r\n"),
- _ => (*type_, *s),
+ .map(|(segment, s)| match *segment {
+ Segment::Newline => (Segment::Newline, "\r\n"),
+ _ => (*segment, *s),
})
.collect::<Vec<_>>(),
expect_prompts,
if let Some(input) = input.strip_suffix('\n') {
println!("running {one_byte_name} segmentation test without final newline...");
let mut expect_segments: Vec<_> = expect_segments.iter().copied().collect();
- assert_eq!(expect_segments.pop(), Some((Type::End, "")));
- assert_eq!(expect_segments.pop(), Some((Type::Newline, "\n")));
- while let Some((Type::SeparateCommands | Type::EndCommand, "")) = expect_segments.last()
+ assert_eq!(expect_segments.pop(), Some((Segment::End, "")));
+ assert_eq!(expect_segments.pop(), Some((Segment::Newline, "\n")));
+ while let Some((Segment::SeparateCommands | Segment::EndCommand, "")) = expect_segments.last()
{
expect_segments.pop();
}
- expect_segments.push((Type::End, ""));
+ expect_segments.push((Segment::End, ""));
_check_segmentation(
input,
mode,
}
}
+#[allow(dead_code)]
fn print_segmentation(mut input: &str) {
let mut segmenter = Segmenter::new(Mode::Auto, false);
loop {
- let (rest, type_) = segmenter.push(input, true).unwrap();
+ let (rest, segment) = segmenter.push(input, true).unwrap();
let len = input.len() - rest.len();
let token = &input[..len];
- print!("{type_:?} {token:?}");
- match type_ {
- Type::Newline => print!(" ({:?})", segmenter.prompt()),
- Type::End => break,
+ print!("{segment:?} {token:?}");
+ match segment {
+ Segment::Newline => print!(" ({:?})", segmenter.prompt()),
+ Segment::End => break,
_ => (),
}
println!();
"#,
Mode::Auto,
&[
- (Type::Identifier, "a"),
- (Type::Spaces, " "),
- (Type::Identifier, "ab"),
- (Type::Spaces, " "),
- (Type::Identifier, "abc"),
- (Type::Spaces, " "),
- (Type::Identifier, "abcd"),
- (Type::Spaces, " "),
- (Type::MacroId, "!abcd"),
- (Type::Newline, "\n"),
- (Type::Identifier, "A"),
- (Type::Spaces, " "),
- (Type::Identifier, "AB"),
- (Type::Spaces, " "),
- (Type::Identifier, "ABC"),
- (Type::Spaces, " "),
- (Type::Identifier, "ABCD"),
- (Type::Spaces, " "),
- (Type::MacroId, "!ABCD"),
- (Type::Newline, "\n"),
- (Type::Identifier, "aB"),
- (Type::Spaces, " "),
- (Type::Identifier, "aBC"),
- (Type::Spaces, " "),
- (Type::Identifier, "aBcD"),
- (Type::Spaces, " "),
- (Type::MacroId, "!aBcD"),
- (Type::Newline, "\n"),
- (Type::Identifier, "$x"),
- (Type::Spaces, " "),
- (Type::Identifier, "$y"),
- (Type::Spaces, " "),
- (Type::Identifier, "$z"),
- (Type::Spaces, " "),
- (Type::MacroId, "!$z"),
- (Type::Newline, "\n"),
- (Type::Identifier, "grève"),
- (Type::Spaces, "\u{00a0}"),
- (Type::Identifier, "Ângstrom"),
- (Type::Spaces, "\u{00a0}"),
- (Type::Identifier, "poté"),
- (Type::Newline, "\n"),
- (Type::Identifier, "#a"),
- (Type::Spaces, " "),
- (Type::Identifier, "#b"),
- (Type::Spaces, " "),
- (Type::Identifier, "#c"),
- (Type::Spaces, " "),
- (Type::Identifier, "##"),
- (Type::Spaces, " "),
- (Type::Identifier, "#d"),
- (Type::Spaces, " "),
- (Type::MacroId, "!#d"),
- (Type::Newline, "\n"),
- (Type::Identifier, "@efg"),
- (Type::Spaces, " "),
- (Type::Identifier, "@"),
- (Type::Spaces, " "),
- (Type::Identifier, "@@."),
- (Type::Spaces, " "),
- (Type::Identifier, "@#@"),
- (Type::Spaces, " "),
- (Type::MacroId, "!@"),
- (Type::Spaces, " "),
- (Type::Newline, "\n"),
- (Type::Identifier, "##"),
- (Type::Spaces, " "),
- (Type::Identifier, "#"),
- (Type::Spaces, " "),
- (Type::Identifier, "#12345"),
- (Type::Spaces, " "),
- (Type::Identifier, "#.#"),
- (Type::Newline, "\n"),
- (Type::Identifier, "f@#_.#6"),
- (Type::Newline, "\n"),
- (Type::Identifier, "GhIjK"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::Identifier, "y"),
- (Type::Spaces, " "),
- (Type::Punct, "_"),
- (Type::Identifier, "z"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "a"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ab"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "abc"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "abcd"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!abcd"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "A"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "AB"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ABC"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ABCD"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!ABCD"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "aB"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "aBC"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "aBcD"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!aBcD"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "$x"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "$y"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "$z"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!$z"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "grève"),
+ (Segment::Spaces, "\u{00a0}"),
+ (Segment::Identifier, "Ângstrom"),
+ (Segment::Spaces, "\u{00a0}"),
+ (Segment::Identifier, "poté"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "#a"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#b"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#c"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "##"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#d"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!#d"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "@efg"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "@"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "@@."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "@#@"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!@"),
+ (Segment::Spaces, " "),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "##"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#12345"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#.#"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "f@#_.#6"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "GhIjK"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::Identifier, "y"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "_"),
+ (Segment::Identifier, "z"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Auto,
&[
- (Type::Identifier, "abcd."),
- (Type::Spaces, " "),
- (Type::Identifier, "abcd"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "ABCD."),
- (Type::Spaces, " "),
- (Type::Identifier, "ABCD"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "aBcD."),
- (Type::Spaces, " "),
- (Type::Identifier, "aBcD"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Newline, "\n"),
- (Type::Identifier, "$y."),
- (Type::Spaces, " "),
- (Type::Identifier, "$z."),
- (Type::Spaces, " "),
- (Type::Identifier, "あいうえお"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "#c."),
- (Type::Spaces, " "),
- (Type::Identifier, "#d."),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "@@."),
- (Type::Spaces, " "),
- (Type::Identifier, "@@..."),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "#.#"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "#abcd"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Spaces, " "),
- (Type::Newline, "\n"),
- (Type::Identifier, "LMNOP"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Newline, "\n"),
- (Type::Identifier, "QRSTUV"),
- (Type::EndCommand, "."),
- (Type::Comment, "/* end of line comment */"),
- (Type::Newline, "\n"),
- (Type::Identifier, "qrstuv"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, "/* end of line comment */"),
- (Type::Newline, "\n"),
- (Type::Identifier, "QrStUv"),
- (Type::EndCommand, "."),
- (Type::Comment, "/* end of line comment */"),
- (Type::Spaces, " "),
- (Type::Newline, "\n"),
- (Type::Identifier, "wxyz"),
- (Type::EndCommand, "."),
- (Type::Comment, "/* unterminated end of line comment"),
- (Type::Newline, "\n"),
- (Type::Identifier, "WXYZ"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, "/* unterminated end of line comment"),
- (Type::Newline, "\n"),
- (Type::Identifier, "WxYz"),
- (Type::EndCommand, "."),
- (Type::Comment, "/* unterminated end of line comment "),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "abcd."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "abcd"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "ABCD."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ABCD"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "aBcD."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "aBcD"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "$y."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "$z."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "あいうえお"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "#c."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#d."),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "@@."),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "@@..."),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "#.#"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "#abcd"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "LMNOP"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "QRSTUV"),
+ (Segment::EndCommand, "."),
+ (Segment::Comment, "/* end of line comment */"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "qrstuv"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* end of line comment */"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "QrStUv"),
+ (Segment::EndCommand, "."),
+ (Segment::Comment, "/* end of line comment */"),
+ (Segment::Spaces, " "),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "wxyz"),
+ (Segment::EndCommand, "."),
+ (Segment::Comment, "/* unterminated end of line comment"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "WXYZ"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* unterminated end of line comment"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "WxYz"),
+ (Segment::EndCommand, "."),
+ (Segment::Comment, "/* unterminated end of line comment "),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::First,
"#,
Mode::Auto,
&[
- (Type::ReservedWord, "and"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "or"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "not"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "eq"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "ge"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "gt"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "le"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "lt"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "ne"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "all"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "by"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "to"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "with"),
- (Type::Newline, "\n"),
- (Type::ReservedWord, "AND"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "OR"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "NOT"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "EQ"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "GE"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "GT"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "LE"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "LT"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "NE"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "ALL"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "BY"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "TO"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "WITH"),
- (Type::Newline, "\n"),
- (Type::Identifier, "andx"),
- (Type::Spaces, " "),
- (Type::Identifier, "orx"),
- (Type::Spaces, " "),
- (Type::Identifier, "notx"),
- (Type::Spaces, " "),
- (Type::Identifier, "eqx"),
- (Type::Spaces, " "),
- (Type::Identifier, "gex"),
- (Type::Spaces, " "),
- (Type::Identifier, "gtx"),
- (Type::Spaces, " "),
- (Type::Identifier, "lex"),
- (Type::Spaces, " "),
- (Type::Identifier, "ltx"),
- (Type::Spaces, " "),
- (Type::Identifier, "nex"),
- (Type::Spaces, " "),
- (Type::Identifier, "allx"),
- (Type::Spaces, " "),
- (Type::Identifier, "byx"),
- (Type::Spaces, " "),
- (Type::Identifier, "tox"),
- (Type::Spaces, " "),
- (Type::Identifier, "withx"),
- (Type::Newline, "\n"),
- (Type::Identifier, "and."),
- (Type::Spaces, " "),
- (Type::ReservedWord, "with"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::ReservedWord, "and"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "or"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "not"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "eq"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "ge"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "gt"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "le"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "lt"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "ne"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "all"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "by"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "to"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "with"),
+ (Segment::Newline, "\n"),
+ (Segment::ReservedWord, "AND"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "OR"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "NOT"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "EQ"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "GE"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "GT"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "LE"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "LT"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "NE"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "ALL"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "BY"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "TO"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "WITH"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "andx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "orx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "notx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "eqx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "gex"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "gtx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "lex"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ltx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "nex"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "allx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "byx"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "tox"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "withx"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "and."),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "with"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Auto,
&[
- (Type::Punct, "~"),
- (Type::Spaces, " "),
- (Type::Punct, "&"),
- (Type::Spaces, " "),
- (Type::Punct, "|"),
- (Type::Spaces, " "),
- (Type::Punct, "="),
- (Type::Spaces, " "),
- (Type::Punct, ">="),
- (Type::Spaces, " "),
- (Type::Punct, ">"),
- (Type::Spaces, " "),
- (Type::Punct, "<="),
- (Type::Spaces, " "),
- (Type::Punct, "<"),
- (Type::Spaces, " "),
- (Type::Punct, "~="),
- (Type::Spaces, " "),
- (Type::Punct, "<>"),
- (Type::Spaces, " "),
- (Type::Punct, "("),
- (Type::Spaces, " "),
- (Type::Punct, ")"),
- (Type::Spaces, " "),
- (Type::Punct, ","),
- (Type::Spaces, " "),
- (Type::Punct, "-"),
- (Type::Spaces, " "),
- (Type::Punct, "+"),
- (Type::Spaces, " "),
- (Type::Punct, "*"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Spaces, " "),
- (Type::Punct, "["),
- (Type::Spaces, " "),
- (Type::Punct, "]"),
- (Type::Spaces, " "),
- (Type::Punct, "**"),
- (Type::Newline, "\n"),
- (Type::Punct, "~"),
- (Type::Punct, "&"),
- (Type::Punct, "|"),
- (Type::Punct, "="),
- (Type::Punct, ">="),
- (Type::Punct, ">"),
- (Type::Punct, "<="),
- (Type::Punct, "<"),
- (Type::Punct, "~="),
- (Type::Punct, "<>"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Punct, ","),
- (Type::Punct, "-"),
- (Type::Punct, "+"),
- (Type::Punct, "*"),
- (Type::Punct, "/"),
- (Type::Punct, "["),
- (Type::Punct, "]"),
- (Type::Punct, "**"),
- (Type::MacroId, "!*"),
- (Type::Newline, "\n"),
- (Type::Punct, "%"),
- (Type::Spaces, " "),
- (Type::Punct, ":"),
- (Type::Spaces, " "),
- (Type::Punct, ";"),
- (Type::Spaces, " "),
- (Type::Punct, "?"),
- (Type::Spaces, " "),
- (Type::Punct, "_"),
- (Type::Spaces, " "),
- (Type::Punct, "`"),
- (Type::Spaces, " "),
- (Type::Punct, "{"),
- (Type::Spaces, " "),
- (Type::Punct, "}"),
- (Type::Spaces, " "),
- (Type::Punct, "~"),
- (Type::Spaces, " "),
- (Type::MacroId, "!*"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Punct, "~"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "&"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "|"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "="),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ">="),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ">"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "<="),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "<"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "~="),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "<>"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "("),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ")"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ","),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "-"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "*"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "["),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "]"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "**"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, "~"),
+ (Segment::Punct, "&"),
+ (Segment::Punct, "|"),
+ (Segment::Punct, "="),
+ (Segment::Punct, ">="),
+ (Segment::Punct, ">"),
+ (Segment::Punct, "<="),
+ (Segment::Punct, "<"),
+ (Segment::Punct, "~="),
+ (Segment::Punct, "<>"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ","),
+ (Segment::Punct, "-"),
+ (Segment::Punct, "+"),
+ (Segment::Punct, "*"),
+ (Segment::Punct, "/"),
+ (Segment::Punct, "["),
+ (Segment::Punct, "]"),
+ (Segment::Punct, "**"),
+ (Segment::MacroId, "!*"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, "%"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ":"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ";"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "?"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "_"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "`"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "{"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "}"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "~"),
+ (Segment::Spaces, " "),
+ (Segment::MacroId, "!*"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Later, PromptStyle::Later, PromptStyle::Later],
);
"#,
Mode::Auto,
&[
- (Type::Number, "0"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::Spaces, " "),
- (Type::Number, "01"),
- (Type::Spaces, " "),
- (Type::Number, "001."),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Number, "123"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, "/* comment 1 */"),
- (Type::Spaces, " "),
- (Type::Comment, "/* comment 2 */"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Number, "1"),
- (Type::Spaces, " "),
- (Type::Number, "0.1"),
- (Type::Spaces, " "),
- (Type::Number, "00.1"),
- (Type::Spaces, " "),
- (Type::Number, "00.10"),
- (Type::Newline, "\n"),
- (Type::Number, "5e1"),
- (Type::Spaces, " "),
- (Type::Number, "6E-1"),
- (Type::Spaces, " "),
- (Type::Number, "7e+1"),
- (Type::Spaces, " "),
- (Type::Number, "6E+01"),
- (Type::Spaces, " "),
- (Type::Number, "6e-03"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Number, "3E1"),
- (Type::Spaces, " "),
- (Type::Number, ".4e-1"),
- (Type::Spaces, " "),
- (Type::Number, ".5E+1"),
- (Type::Spaces, " "),
- (Type::Number, ".6e+01"),
- (Type::Spaces, " "),
- (Type::Number, ".7E-03"),
- (Type::Newline, "\n"),
- (Type::Number, "1.23e1"),
- (Type::Spaces, " "),
- (Type::Number, "45.6E-1"),
- (Type::Spaces, " "),
- (Type::Number, "78.9e+1"),
- (Type::Spaces, " "),
- (Type::Number, "99.9E+01"),
- (Type::Spaces, " "),
- (Type::Number, "11.2e-03"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "1e"),
- (Type::Spaces, " "),
- (Type::Identifier, "e1"),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "1e+"),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "1e-"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Number, "0"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "001."),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Number, "123"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* comment 1 */"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* comment 2 */"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Number, "1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "0.1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "00.1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "00.10"),
+ (Segment::Newline, "\n"),
+ (Segment::Number, "5e1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "6E-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "7e+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "6E+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "6e-03"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Number, "3E1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, ".4e-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, ".5E+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, ".6e+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, ".7E-03"),
+ (Segment::Newline, "\n"),
+ (Segment::Number, "1.23e1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "45.6E-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "78.9e+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "99.9E+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "11.2e-03"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "1e"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "e1"),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "1e+"),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "1e-"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::First,
"#,
Mode::Auto,
&[
- (Type::Spaces, " "),
- (Type::Number, "-0"),
- (Type::Spaces, " "),
- (Type::Number, "-1"),
- (Type::Spaces, " "),
- (Type::Number, "-01"),
- (Type::Spaces, " "),
- (Type::Number, "-001."),
- (Type::Spaces, " "),
- (Type::Number, "-1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Number, "-123"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, "/* comment 1 */"),
- (Type::Spaces, " "),
- (Type::Comment, "/* comment 2 */"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Number, "-.1"),
- (Type::Spaces, " "),
- (Type::Number, "-0.1"),
- (Type::Spaces, " "),
- (Type::Number, "-00.1"),
- (Type::Spaces, " "),
- (Type::Number, "-00.10"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Number, "-5e1"),
- (Type::Spaces, " "),
- (Type::Number, "-6E-1"),
- (Type::Spaces, " "),
- (Type::Number, "-7e+1"),
- (Type::Spaces, " "),
- (Type::Number, "-6E+01"),
- (Type::Spaces, " "),
- (Type::Number, "-6e-03"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Number, "-.3E1"),
- (Type::Spaces, " "),
- (Type::Number, "-.4e-1"),
- (Type::Spaces, " "),
- (Type::Number, "-.5E+1"),
- (Type::Spaces, " "),
- (Type::Number, "-.6e+01"),
- (Type::Spaces, " "),
- (Type::Number, "-.7E-03"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Number, "-1.23e1"),
- (Type::Spaces, " "),
- (Type::Number, "-45.6E-1"),
- (Type::Spaces, " "),
- (Type::Number, "-78.9e+1"),
- (Type::Spaces, " "),
- (Type::Number, "-99.9E+01"),
- (Type::Spaces, " "),
- (Type::Number, "-11.2e-03"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Punct, "-"),
- (Type::Comment, "/**/"),
- (Type::Number, "1"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Punct, "-"),
- (Type::Punct, "."),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "-1e"),
- (Type::Spaces, " "),
- (Type::Punct, "-"),
- (Type::Identifier, "e1"),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "-1e+"),
- (Type::Spaces, " "),
- (Type::ExpectedExponent, "-1e-"),
- (Type::Spaces, " "),
- (Type::Number, "-1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-0"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-001."),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-123"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* comment 1 */"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* comment 2 */"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-0.1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-00.1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-00.10"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-5e1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-6E-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-7e+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-6E+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-6e-03"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.3E1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.4e-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.5E+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.6e+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-.7E-03"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-1.23e1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-45.6E-1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-78.9e+1"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-99.9E+01"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-11.2e-03"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "-"),
+ (Segment::Comment, "/**/"),
+ (Segment::Number, "1"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "-"),
+ (Segment::Punct, "."),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "-1e"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "-"),
+ (Segment::Identifier, "e1"),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "-1e+"),
+ (Segment::Spaces, " "),
+ (Segment::ExpectedExponent, "-1e-"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "-1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::First,
"#,
Mode::Auto,
&[
- (Type::QuotedString, "'x'"),
- (Type::Spaces, " "),
- (Type::QuotedString, "\"y\""),
- (Type::Spaces, " "),
- (Type::QuotedString, "'abc'"),
- (Type::Newline, "\n"),
- (Type::QuotedString, "'Don''t'"),
- (Type::Spaces, " "),
- (Type::QuotedString, "\"Can't\""),
- (Type::Spaces, " "),
- (Type::QuotedString, "'Won''t'"),
- (Type::Newline, "\n"),
- (Type::QuotedString, "\"\"\"quoted\"\"\""),
- (Type::Spaces, " "),
- (Type::QuotedString, "'\"quoted\"'"),
- (Type::Newline, "\n"),
- (Type::QuotedString, "''"),
- (Type::Spaces, " "),
- (Type::QuotedString, "\"\""),
- (Type::Newline, "\n"),
- (Type::ExpectedQuote, "'missing end quote"),
- (Type::Newline, "\n"),
- (Type::ExpectedQuote, "\"missing double quote"),
- (Type::Newline, "\n"),
- (Type::HexString, "x\"4142\""),
- (Type::Spaces, " "),
- (Type::HexString, "X'5152'"),
- (Type::Newline, "\n"),
- (Type::UnicodeString, "u'fffd'"),
- (Type::Spaces, " "),
- (Type::UnicodeString, "U\"041\""),
- (Type::Newline, "\n"),
- (Type::StartCommand, "+"),
- (Type::Spaces, " "),
- (Type::Identifier, "new"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::Punct, "+"),
- (Type::Spaces, " "),
- (Type::Comment, "/* comment */"),
- (Type::Spaces, " "),
- (Type::QuotedString, "'string continuation'"),
- (Type::Newline, "\n"),
- (Type::Punct, "+"),
- (Type::Spaces, " "),
- (Type::Comment, "/* also a punctuator on blank line"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "-"),
- (Type::Spaces, " "),
- (Type::QuotedString, "'new command'"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::QuotedString, "'x'"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "\"y\""),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'abc'"),
+ (Segment::Newline, "\n"),
+ (Segment::QuotedString, "'Don''t'"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "\"Can't\""),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'Won''t'"),
+ (Segment::Newline, "\n"),
+ (Segment::QuotedString, "\"\"\"quoted\"\"\""),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'\"quoted\"'"),
+ (Segment::Newline, "\n"),
+ (Segment::QuotedString, "''"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "\"\""),
+ (Segment::Newline, "\n"),
+ (Segment::ExpectedQuote, "'missing end quote"),
+ (Segment::Newline, "\n"),
+ (Segment::ExpectedQuote, "\"missing double quote"),
+ (Segment::Newline, "\n"),
+ (Segment::HexString, "x\"4142\""),
+ (Segment::Spaces, " "),
+ (Segment::HexString, "X'5152'"),
+ (Segment::Newline, "\n"),
+ (Segment::UnicodeString, "u'fffd'"),
+ (Segment::Spaces, " "),
+ (Segment::UnicodeString, "U\"041\""),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "new"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* comment */"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'string continuation'"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/* also a punctuator on blank line"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "-"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'new command'"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Interactive,
&[
- (Type::Shbang, "#! /usr/bin/pspp"),
- (Type::Newline, "\n"),
- (Type::Identifier, "title"),
- (Type::Spaces, " "),
- (Type::Identifier, "my"),
- (Type::Spaces, " "),
- (Type::Identifier, "title"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "#"),
- (Type::MacroId, "!"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "usr"),
- (Type::Punct, "/"),
- (Type::Identifier, "bin"),
- (Type::Punct, "/"),
- (Type::Identifier, "pspp"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Shbang, "#! /usr/bin/pspp"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "title"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "my"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "title"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "#"),
+ (Segment::MacroId, "!"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "usr"),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "bin"),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "pspp"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::First, PromptStyle::First, PromptStyle::Later],
);
"#,
Mode::Interactive,
&[
- (Type::CommentCommand, "* Comment commands \"don't"),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "have to contain valid tokens"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "** Check ambiguity with ** token"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "****************"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "comment keyword works too"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "COMM also"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "com"),
- (Type::Spaces, " "),
- (Type::Identifier, "is"),
- (Type::Spaces, " "),
- (Type::Identifier, "ambiguous"),
- (Type::Spaces, " "),
- (Type::ReservedWord, "with"),
- (Type::Spaces, " "),
- (Type::Identifier, "COMPUTE"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
+ (Segment::CommentCommand, "* Comment commands \"don't"),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "have to contain valid tokens"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "** Check ambiguity with ** token"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "****************"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "comment keyword works too"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "COMM also"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "com"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "is"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "ambiguous"),
+ (Segment::Spaces, " "),
+ (Segment::ReservedWord, "with"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "COMPUTE"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
(
- Type::CommentCommand,
+ Segment::CommentCommand,
"* Comment need not start at left margin",
),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::CommentCommand, "* Comment ends with blank line"),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "next"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::CommentCommand, "* Comment ends with blank line"),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "next"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Comment,
"#,
Mode::Interactive,
&[
- (Type::StartDocument, ""),
- (Type::Document, "DOCUMENT one line."),
- (Type::EndCommand, ""),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::StartDocument, ""),
- (Type::Document, "DOC more"),
- (Type::Newline, "\n"),
- (Type::Document, " than"),
- (Type::Newline, "\n"),
- (Type::Document, " one"),
- (Type::Newline, "\n"),
- (Type::Document, " line."),
- (Type::EndCommand, ""),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::StartDocument, ""),
- (Type::Document, "docu"),
- (Type::Newline, "\n"),
- (Type::Document, "first.paragraph"),
- (Type::Newline, "\n"),
- (Type::Document, "isn't parsed as tokens"),
- (Type::Newline, "\n"),
- (Type::Document, ""),
- (Type::Newline, "\n"),
- (Type::Document, "second paragraph."),
- (Type::EndCommand, ""),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::StartDocument, ""),
+ (Segment::Document, "DOCUMENT one line."),
+ (Segment::EndCommand, ""),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::StartDocument, ""),
+ (Segment::Document, "DOC more"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, " than"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, " one"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, " line."),
+ (Segment::EndCommand, ""),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::StartDocument, ""),
+ (Segment::Document, "docu"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, "first.paragraph"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, "isn't parsed as tokens"),
+ (Segment::Newline, "\n"),
+ (Segment::Document, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Document, "second paragraph."),
+ (Segment::EndCommand, ""),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::First,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "FIL"),
- (Type::Spaces, " "),
- (Type::Identifier, "label"),
- (Type::Spaces, " "),
- (Type::UnquotedString, "isn't quoted"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "FILE"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "lab"),
- (Type::Spaces, " "),
- (Type::QuotedString, "'is quoted'"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "FILE"),
- (Type::Spaces, " "),
- (Type::Comment, "/*"),
- (Type::Newline, "\n"),
- (Type::Comment, "/**/"),
- (Type::Spaces, " "),
- (Type::Identifier, "lab"),
- (Type::Spaces, " "),
- (Type::UnquotedString, "not quoted here either"),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "FIL"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "label"),
+ (Segment::Spaces, " "),
+ (Segment::UnquotedString, "isn't quoted"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "FILE"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "lab"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "'is quoted'"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "FILE"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/*"),
+ (Segment::Newline, "\n"),
+ (Segment::Comment, "/**/"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "lab"),
+ (Segment::Spaces, " "),
+ (Segment::UnquotedString, "not quoted here either"),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::First,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "begin"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "begin"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, "/*"),
- (Type::Newline, "\n"),
- (Type::InlineData, "123"),
- (Type::Newline, "\n"),
- (Type::InlineData, "xxx"),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "BEG"),
- (Type::Spaces, " "),
- (Type::Comment, "/**/"),
- (Type::Spaces, " "),
- (Type::Identifier, "DAT"),
- (Type::Spaces, " "),
- (Type::Comment, "/*"),
- (Type::Newline, "\n"),
- (Type::InlineData, "5 6 7 /* x"),
- (Type::Newline, "\n"),
- (Type::InlineData, ""),
- (Type::Newline, "\n"),
- (Type::InlineData, "end data"),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "begin"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::InlineData, "data"),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "begin"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::QuotedString, "\"xxx\""),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "begin"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Number, "123"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::ReservedWord, "not"),
- (Type::Spaces, " "),
- (Type::Identifier, "data"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "begin"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "begin"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/*"),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, "123"),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, "xxx"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "BEG"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/**/"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "DAT"),
+ (Segment::Spaces, " "),
+ (Segment::Comment, "/*"),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, "5 6 7 /* x"),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, ""),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, "end data"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "begin"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::InlineData, "data"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "begin"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::QuotedString, "\"xxx\""),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "begin"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "123"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::ReservedWord, "not"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "data"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Data,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "do"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Spaces, " "),
- (Type::Identifier, "x"),
- (Type::Punct, "="),
- (Type::Identifier, "a"),
- (Type::Spaces, " "),
- (Type::Identifier, "b"),
- (Type::Spaces, " "),
- (Type::Identifier, "c"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "y"),
- (Type::Punct, "="),
- (Type::Identifier, "d"),
- (Type::Spaces, " "),
- (Type::Identifier, "e"),
- (Type::Spaces, " "),
- (Type::Identifier, "f"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, " do repeat a=1 thru 5."),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "another command."),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "second command"),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "+ third command."),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "end /* x */ /* y */ repeat print."),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "do"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Spaces, " "),
- (Type::Identifier, "#a"),
- (Type::Punct, "="),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, " inner command."),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "do"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "x"),
+ (Segment::Punct, "="),
+ (Segment::Identifier, "a"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "b"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "c"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "y"),
+ (Segment::Punct, "="),
+ (Segment::Identifier, "d"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "e"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "f"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, " do repeat a=1 thru 5."),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "another command."),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "second command"),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "+ third command."),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "end /* x */ /* y */ repeat print."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "do"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#a"),
+ (Segment::Punct, "="),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, " inner command."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
.map(|s| s.as_str())
.collect();
let mut expect_output = vec![
- (Type::Identifier, "do"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Spaces, " "),
- (Type::Identifier, "v0"),
- (Type::Punct, "="),
- (Type::Number, "0"),
- (Type::Spaces, " "),
- (Type::Identifier, "thru"),
- (Type::Spaces, " "),
- (Type::Number, "5"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
+ (Segment::Identifier, "do"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "v0"),
+ (Segment::Punct, "="),
+ (Segment::Number, "0"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "thru"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "5"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
];
for i in 1..N {
- expect_output.push((Type::DoRepeatCommand, &do_repeat[i].trim_end()));
+ expect_output.push((Segment::DoRepeatCommand, &do_repeat[i].trim_end()));
if i >= 255 {
- expect_output.push((Type::DoRepeatOverflow, ""));
+ expect_output.push((Segment::DoRepeatOverflow, ""));
}
- expect_output.push((Type::Newline, "\n"));
+ expect_output.push((Segment::Newline, "\n"));
}
for i in 0..254 {
- expect_output.push((Type::DoRepeatCommand, &end_repeat[i].trim_end()));
- expect_output.push((Type::Newline, "\n"));
+ expect_output.push((Segment::DoRepeatCommand, &end_repeat[i].trim_end()));
+ expect_output.push((Segment::Newline, "\n"));
}
let comments: Vec<String> = (0..(N - 254)).rev().map(|i| format!("/* {i}")).collect();
for comment in &comments {
expect_output.extend([
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::EndCommand, "."),
- (Type::Spaces, " "),
- (Type::Comment, comment),
- (Type::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::EndCommand, "."),
+ (Segment::Spaces, " "),
+ (Segment::Comment, comment),
+ (Segment::Newline, "\n"),
]);
}
- expect_output.push((Type::End, ""));
+ expect_output.push((Segment::End, ""));
let expect_prompts: Vec<_> = (0..N * 2 - 3)
.map(|_| PromptStyle::DoRepeat)
"#,
Mode::Batch,
&[
- (Type::Identifier, "do"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Spaces, " "),
- (Type::Identifier, "x"),
- (Type::Punct, "="),
- (Type::Identifier, "a"),
- (Type::Spaces, " "),
- (Type::Identifier, "b"),
- (Type::Spaces, " "),
- (Type::Identifier, "c"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "y"),
- (Type::Punct, "="),
- (Type::Identifier, "d"),
- (Type::Spaces, " "),
- (Type::Identifier, "e"),
- (Type::Spaces, " "),
- (Type::Identifier, "f"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::DoRepeatCommand, "do repeat a=1 thru 5"),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "another command"),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "second command"),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "+ third command"),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, "end /* x */ /* y */ repeat print"),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::Identifier, "do"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Spaces, " "),
- (Type::Identifier, "#a"),
- (Type::Punct, "="),
- (Type::Number, "1"),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::DoRepeatCommand, " inner command"),
- (Type::Newline, "\n"),
- (Type::Identifier, "end"),
- (Type::Spaces, " "),
- (Type::Identifier, "repeat"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "do"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "x"),
+ (Segment::Punct, "="),
+ (Segment::Identifier, "a"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "b"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "c"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "y"),
+ (Segment::Punct, "="),
+ (Segment::Identifier, "d"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "e"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "f"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::DoRepeatCommand, "do repeat a=1 thru 5"),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "another command"),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "second command"),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "+ third command"),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, "end /* x */ /* y */ repeat print"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::Identifier, "do"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "#a"),
+ (Segment::Punct, "="),
+ (Segment::Number, "1"),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::DoRepeatCommand, " inner command"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "end"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "repeat"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
mod define {
use crate::{
- lex::segment::{Mode, Type},
+ lex::segment::{Mode, Segment},
prompt::PromptStyle,
};
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "var1 var2 var3 \"!enddefine\""),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "var1 var2 var3 \"!enddefine\""),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define, PromptStyle::Define, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::MacroBody, " var1 var2 var3 /* !enddefine"),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::MacroBody, " var1 var2 var3 /* !enddefine"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "var1 var2 var3"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "var1 var2 var3"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::MacroBody, "var1 var2 var3"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::MacroBody, "var1 var2 var3"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroBody, ""),
- (Type::Newline, "\n"),
- (Type::MacroBody, ""),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, ""),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, ""),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Define,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Identifier, "a"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Punct, ","),
- (Type::Spaces, " "),
- (Type::Identifier, "b"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Punct, ","),
- (Type::Spaces, " "),
- (Type::Identifier, "c"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Identifier, "a"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ","),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "b"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ","),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "c"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "a"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Punct, ","),
- (Type::Spaces, " "),
- (Type::Identifier, "b"),
- (Type::Punct, "("),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Punct, ")"),
- (Type::Punct, ","),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "c"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "a"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ","),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "b"),
+ (Segment::Punct, "("),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, ")"),
+ (Segment::Punct, ","),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "c"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Newline, "\n"),
- (Type::Punct, "("),
- (Type::Identifier, "x"),
- (Type::Punct, ","),
- (Type::Identifier, "y"),
- (Type::Punct, ","),
- (Type::Identifier, "z"),
- (Type::Newline, "\n"),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "content 1"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "content 2"),
- (Type::Newline, "\n"),
- (Type::MacroId, "!enddefine"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, "("),
+ (Segment::Identifier, "x"),
+ (Segment::Punct, ","),
+ (Segment::Identifier, "y"),
+ (Segment::Punct, ","),
+ (Segment::Identifier, "z"),
+ (Segment::Newline, "\n"),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "content 1"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "content 2"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroId, "!enddefine"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Identifier, "list"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "list"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::First, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Newline, "\n"),
- (Type::Identifier, "x"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Identifier, "list"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "x"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "list"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Later, PromptStyle::First, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "x"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Identifier, "list"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "x"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "list"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::First, PromptStyle::First, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Identifier, "list"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "list"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::First, PromptStyle::First],
);
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "content line 1"),
- (Type::Newline, "\n"),
- (Type::MacroBody, "content line 2"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "content line 1"),
+ (Segment::Newline, "\n"),
+ (Segment::MacroBody, "content line 2"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Define,
"#,
Mode::Interactive,
&[
- (Type::Identifier, "define"),
- (Type::Spaces, " "),
- (Type::MacroName, "!macro1"),
- (Type::Punct, "("),
- (Type::Punct, ")"),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "define"),
+ (Segment::Spaces, " "),
+ (Segment::MacroName, "!macro1"),
+ (Segment::Punct, "("),
+ (Segment::Punct, ")"),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[PromptStyle::Define],
);
"#,
Mode::Batch,
&[
- (Type::Identifier, "first"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "another"),
- (Type::Spaces, " "),
- (Type::Identifier, "line"),
- (Type::Spaces, " "),
- (Type::Identifier, "of"),
- (Type::Spaces, " "),
- (Type::Identifier, "first"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "+"),
- (Type::Spaces, " "),
- (Type::Identifier, "second"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::Identifier, "third"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "fourth"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "fifth"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "first"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "another"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "line"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "of"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "first"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "second"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::Identifier, "third"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "fourth"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "fifth"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,
"#,
Mode::Auto,
&[
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "another"),
- (Type::Spaces, " "),
- (Type::Identifier, "line"),
- (Type::Spaces, " "),
- (Type::Identifier, "of"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::Number, "2"),
- (Type::Identifier, "sls"),
- (Type::Newline, "\n"),
- (Type::StartCommand, "+"),
- (Type::Spaces, " "),
- (Type::Identifier, "another"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::Identifier, "another"),
- (Type::Spaces, " "),
- (Type::Identifier, "line"),
- (Type::Spaces, " "),
- (Type::Identifier, "of"),
- (Type::Spaces, " "),
- (Type::Identifier, "second"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::Identifier, "data"),
- (Type::Spaces, " "),
- (Type::Identifier, "list"),
- (Type::Spaces, " "),
- (Type::Punct, "/"),
- (Type::Identifier, "x"),
- (Type::Spaces, " "),
- (Type::Number, "1"),
- (Type::Newline, "\n"),
- (Type::StartCommand, ""),
- (Type::Identifier, "aggregate"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "print"),
- (Type::Spaces, " "),
- (Type::Identifier, "eject"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Identifier, "twostep"),
- (Type::Spaces, " "),
- (Type::Identifier, "cluster"),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::SeparateCommands, ""),
- (Type::Newline, "\n"),
- (Type::Identifier, "fourth"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::Spaces, " "),
- (Type::Identifier, "fifth"),
- (Type::Spaces, " "),
- (Type::Identifier, "command"),
- (Type::EndCommand, "."),
- (Type::Newline, "\n"),
- (Type::End, ""),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "another"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "line"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "of"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::Number, "2"),
+ (Segment::Identifier, "sls"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, "+"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "another"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "another"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "line"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "of"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "second"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::Identifier, "data"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "list"),
+ (Segment::Spaces, " "),
+ (Segment::Punct, "/"),
+ (Segment::Identifier, "x"),
+ (Segment::Spaces, " "),
+ (Segment::Number, "1"),
+ (Segment::Newline, "\n"),
+ (Segment::StartCommand, ""),
+ (Segment::Identifier, "aggregate"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "print"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "eject"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "twostep"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "cluster"),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::SeparateCommands, ""),
+ (Segment::Newline, "\n"),
+ (Segment::Identifier, "fourth"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "fifth"),
+ (Segment::Spaces, " "),
+ (Segment::Identifier, "command"),
+ (Segment::EndCommand, "."),
+ (Segment::Newline, "\n"),
+ (Segment::End, ""),
],
&[
PromptStyle::Later,