get basic parsing and formatting working

This commit is contained in:
Brendan Hansknecht 2023-03-22 16:31:50 -07:00
parent 99547086ee
commit 8f238046be
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 11 additions and 3 deletions

View file

@ -510,7 +510,7 @@ fn fmt_imports_entry<'a, 'buf>(buf: &mut Buf<'buf>, entry: &ImportsEntry<'a>, in
IngestedFile(file_name, typed_ident) => {
fmt_str_literal(buf, *file_name, indent);
buf.push_str(" as ");
buf.push_str_allow_spaces(" as ");
typed_ident.format(buf, 0);
}
}

View file

@ -643,7 +643,8 @@ fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports
Spaced::Item(entry)
}
),
)
.trace("normal_import"),
map!(
and!(
and!(
@ -651,7 +652,13 @@ fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports
// TODO: str literal allows for multiline strings. We probably don't want that for file names.
specialize(|_, pos| EImports::StrLiteral(pos), parse_str_literal()),
// e.g. as
word2(b'a', b's', EImports::AsKeyword)
and!(
and!(
space0_e(EImports::AsKeyword),
word2(b'a', b's', EImports::AsKeyword)
),
space0_e(EImports::AsKeyword)
)
),
// e.g. file : Str
specialize(|_, pos| EImports::TypedIdent(pos), typed_ident())
@ -660,6 +667,7 @@ fn imports_entry<'a>() -> impl Parser<'a, Spaced<'a, ImportsEntry<'a>>, EImports
Spaced::Item(ImportsEntry::IngestedFile(file_name, typed_ident))
}
)
.trace("ingest_file_import")
)
.trace("imports_entry")
}