Refactor ast to hold data as seperated type

This commit is contained in:
Jeong YunWon 2023-05-07 17:14:17 +09:00
parent 9f1a538eba
commit 6d7358090b
111 changed files with 23485 additions and 20218 deletions

View file

@ -46,7 +46,7 @@ pub(super) use lalrpop_util::ParseError as LalrpopError;
/// ```
pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, ParseError> {
parse(source, Mode::Module, source_path).map(|top| match top {
ast::Mod::Module { body, .. } => body,
ast::Mod::Module(ast::ModModule { body, .. }) => body,
_ => unreachable!(),
})
}
@ -94,7 +94,7 @@ pub fn parse_expression_located(
location: Location,
) -> Result<ast::Expr, ParseError> {
parse_located(source, Mode::Expression, path, location).map(|top| match top {
ast::Mod::Expression { body } => *body,
ast::Mod::Expression(ast::ModExpression { body }) => *body,
_ => unreachable!(),
})
}