remove WrapperType enum to ease parsing
This commit is contained in:
parent
98100d3465
commit
040bb4ecb3
3 changed files with 10 additions and 22 deletions
|
@ -10,8 +10,10 @@ pub(super) enum Atom {
|
|||
StartHere,
|
||||
Modifier(Modifier),
|
||||
QuickModifier(QuickModifier),
|
||||
Wrapper(WrapperKind, Vec<Atom>),
|
||||
EmptyWrapper(WrapperKind),
|
||||
Loop(u8, Vec<Atom>),
|
||||
Tuple(Vec<Atom>),
|
||||
Slope(SlopeModifier, Instruction, Vec<Atom>),
|
||||
Comment,
|
||||
}
|
||||
|
||||
#[derive(ModifierParser)]
|
||||
|
@ -30,13 +32,6 @@ pub(super) enum QuickModifier {
|
|||
Pizz(bool),
|
||||
}
|
||||
|
||||
pub(super) enum WrapperKind {
|
||||
Loop(u8),
|
||||
Tuple,
|
||||
Slope(SlopeModifier, Instruction),
|
||||
Comment,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, SlopeModifierParser)]
|
||||
pub(super) enum SlopeModifier {
|
||||
Note,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{Atom, Modifier, QuickModifier, SlopeModifier, WrapperKind};
|
||||
use super::{Atom, Modifier, QuickModifier, SlopeModifier};
|
||||
|
||||
pub(super) mod lexer;
|
||||
|
||||
|
@ -23,17 +23,6 @@ pub(super) trait Token<T> {
|
|||
fn token(self) -> T;
|
||||
}
|
||||
|
||||
impl Token<(char, char)> for WrapperKind {
|
||||
fn token(self) -> (char, char) {
|
||||
match self {
|
||||
Self::Loop(_) => WrappingTokens::PARENTHESES,
|
||||
Self::Tuple => WrappingTokens::SQUARE_BRACKETS,
|
||||
Self::Slope(_, _) => WrappingTokens::BRACKETS,
|
||||
WrapperKind::Comment => WrappingTokens::SEMICOLON_COMMA,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Token<(char, char)> for QuickModifier {
|
||||
fn token(self) -> (char, char) {
|
||||
match self {
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
use nom::{branch::alt, character::complete::char, combinator::value, IResult, Parser};
|
||||
use nom::{
|
||||
branch::alt, character::complete::char, combinator::value, sequence::delimited, IResult, Parser,
|
||||
};
|
||||
|
||||
use crate::bng::score::QuickModifier;
|
||||
|
||||
use super::Token;
|
||||
|
||||
pub(crate) trait Parse: Sized {
|
||||
fn parse(input: &str) -> IResult<&str, Self>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue