various work

This commit is contained in:
Greg Shuflin 2021-11-17 03:40:43 -08:00
parent a2d5f380a8
commit b4b1a0cf63

View File

@ -3,10 +3,10 @@ use nom::{
branch::alt,
bytes::complete::{take_till, tag},
character::complete::{alpha1, alphanumeric0, not_line_ending,none_of, char, one_of, space0, space1, multispace0, line_ending},
combinator::{peek, not, value, map, recognize},
combinator::{opt, peek, not, value, map, recognize},
error::{context, VerboseError, ParseError},
multi::{fold_many1, many1, many0, separated_list1, separated_list0},
sequence::{tuple, preceded},
sequence::{pair, tuple, preceded},
IResult, Parser,
};
use std::rc::Rc;
@ -90,13 +90,37 @@ fn block(input: &str) -> ParseResult<Block> {
fn statement(input: &str) -> ParseResult<Statement> {
context("Parsing-statement",
map(expression_kind, |kind| Statement {
map(expression, |expr| Statement {
id: Default::default(),
location: Default::default(),
kind: StatementKind::Expression(Expression::new(Default::default(), kind)),
kind: StatementKind::Expression(expr),
}))(input)
}
fn expression(input: &str) -> ParseResult<Expression> {
map(pair(expression_kind, opt(type_anno)), |(kind, maybe_anno)| {
Expression::new(Default::default(), kind)
})(input)
}
fn type_anno(input: &str) -> ParseResult<TypeIdentifier> {
preceded(kw(":"), type_identifier)(input)
}
fn type_identifier(input: &str) -> ParseResult<TypeIdentifier> {
/*
alt((
tuple((kw("("), separated_list0(kw(","), type_identifier), kw(")"))),
type_singleton_name
))(input)
*/
unimplemented!()
}
fn type_singleton_name(input: &str) -> ParseResult<TypeSingletonName> {
unimplemented!()
}
pub fn expression_kind(input: &str) -> ParseResult<ExpressionKind> {
context("expression-kind", primary_expr)(input)
}