Move parsing of literals under new 'literal' parser module group

Also moved the logic for 'int' and 'string' there though it is trivial. Yet, for bytearray, it tidies things nicely by removing them from the 'utils' module.
This commit is contained in:
KtorZ
2023-07-05 14:36:23 +02:00
parent e15cdaf248
commit 66296df9c3
9 changed files with 123 additions and 96 deletions

View File

@@ -2,7 +2,9 @@ use chumsky::prelude::*;
use crate::{
ast,
parser::{annotation, error::ParseError, expr::bytearray::bytearray, token::Token, utils},
parser::{
annotation, error::ParseError, literal::bytearray::parser as bytearray, token::Token, utils,
},
};
pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError> {
@@ -48,7 +50,7 @@ pub fn value() -> impl Parser<Token, ast::Constant, Error = ParseError> {
});
let constant_bytearray_parser =
bytearray().map_with_span(|(preferred_format, bytes), span| ast::Constant::ByteArray {
bytearray(|bytes, preferred_format, span| ast::Constant::ByteArray {
location: span,
bytes,
preferred_format,