Add ast::Expr::parse

This commit is contained in:
DropDemBits 2024-03-08 21:45:35 -05:00
parent c4573b26f6
commit e989f22015
No known key found for this signature in database
GPG key ID: 7FE02A6C1EDFA075
2 changed files with 32 additions and 0 deletions

View file

@ -18,6 +18,15 @@ pub(crate) fn parse_text(text: &str, edition: parser::Edition) -> (GreenNode, Ve
(node, errors)
}
pub(crate) fn parse_text_at(text: &str, entry: parser::TopEntryPoint, edition: parser::Edition) -> (GreenNode, Vec<SyntaxError>) {
let _p = tracing::span!(tracing::Level::INFO, "parse_text_at").entered();
let lexed = parser::LexedStr::new(text);
let parser_input = lexed.to_input();
let parser_output = entry.parse(&parser_input, edition);
let (node, errors, _eof) = build_tree(lexed, parser_output);
(node, errors)
}
pub(crate) fn build_tree(
lexed: parser::LexedStr<'_>,
parser_output: parser::Output,