lib UML complete (I think)
This commit is contained in:
parent
f09e00cdba
commit
6c15d52d3b
1 changed files with 51 additions and 37 deletions
|
@ -1,9 +1,8 @@
|
|||
@startuml "bliplib class diagram"
|
||||
|
||||
left to right direction
|
||||
|
||||
package std {
|
||||
interface Iterator<type Item> {
|
||||
next(&mut self): Self::Item
|
||||
}
|
||||
interface From<T> {
|
||||
from(value: T): Self
|
||||
}
|
||||
|
@ -14,39 +13,38 @@ package nom {
|
|||
}
|
||||
|
||||
package parser {
|
||||
struct TokenParser<I, T> {
|
||||
phantom: PhantomData<I>
|
||||
inner: T
|
||||
}
|
||||
note right of TokenParser {
|
||||
where T: for<'i> nom::Parser<nom_locate::LocatedSpan<&'i I>, Output = Self, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
}
|
||||
interface TokenParser<I>
|
||||
interface Token {
|
||||
apply(&self, context: Context): Context
|
||||
-apply(&self, context: Context): Context
|
||||
}
|
||||
struct Silence {
|
||||
parser<I>(): TokenParser<I, ??>
|
||||
-parser<I>(): impl TokenParser<I>
|
||||
}
|
||||
struct Marker {
|
||||
parser<I>(): impl for<'i> nom::Parser<nom_locate::LocatedSpan<&'i I>, Output = Self, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
-parser<I>(): impl TokenParser<I>
|
||||
}
|
||||
struct Note {
|
||||
n: u8
|
||||
parser<I: nom::Input + nom::Compare<T>, T: nom::Input>(notes: Vec<T>): impl for<'i> nom::Parser<nom_locate::LocatedSpan<&'i I>, Output = Self, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
+n: u8
|
||||
-parser<'a, I: nom::Input + nom::Compare<I> + Clone>(notes: &'a [I]): impl TokenParser<I>
|
||||
}
|
||||
struct VariableChange {
|
||||
name: char,
|
||||
change: String
|
||||
+name: char,
|
||||
+change: String
|
||||
-parser<'a, I, C: Into<char> + Clone>(variables: &'a [C]): impl TokenParser<I>
|
||||
}
|
||||
struct Loop {
|
||||
times: usize
|
||||
inner: Vec<Box<dyn Token>>
|
||||
+times: usize
|
||||
+inner: Vec<Box<dyn Token>>
|
||||
-parser<'n, 's, 'v, I: Input + Clone + nom::Compare<I>, C: Into<char>>(parametters: ParserParametters<'n, 's, 'v, I, C>): impl TokenParser<I>
|
||||
}
|
||||
struct Tuplet {
|
||||
inner: Vec<Box<dyn Token>>
|
||||
+inner: Vec<Box<dyn Token>>
|
||||
-parser<'n, 's, 'v, I: Input + Clone + nom::Compare<I>, C: Into<char>>(parametters: ParserParametters<'n, 's, 'v, I, C>): impl TokenParser<I>
|
||||
}
|
||||
struct Slope {
|
||||
each_frame: VariableChange
|
||||
+inner: Vec<Box<dyn Token>>
|
||||
+each_frame: VariableChange
|
||||
-parser<'n, 's, 'v, I: Input + Clone + nom::Compare<I>, C: Into<char>>(parametters: ParserParametters<'n, 's, 'v, I, C>): impl TokenParser<I>
|
||||
}
|
||||
Silence ..|> Token
|
||||
Marker ..|> Token
|
||||
|
@ -55,18 +53,35 @@ package parser {
|
|||
Loop ..|> Token
|
||||
Tuplet ..|> Token
|
||||
Slope ..|> Token
|
||||
struct Parser<'i, 'n, 's, I: Input + Clone> {
|
||||
input: &'i I
|
||||
notes: &'n [I]
|
||||
slopes: &'s HashMap<I, VariableChange>
|
||||
Silence --> TokenParser
|
||||
Marker --> TokenParser
|
||||
Note --> TokenParser
|
||||
VariableChange --> TokenParser
|
||||
Loop --> TokenParser
|
||||
Tuplet --> TokenParser
|
||||
Slope --> TokenParser
|
||||
struct ParserParametters<'n, 's, 'v, I: Input + Clone + nom::Compare<I>, C: Into<char>> {
|
||||
+notes: &'n [I]
|
||||
+slopes: &'s HashMap<I, VariableChange>
|
||||
+variables: &'v [C]
|
||||
}
|
||||
struct ParserBuilder<'i, 'n, 's, I: Input + Clone> {
|
||||
input: Option<&'i I>
|
||||
notes: Option<&'n [I]>
|
||||
slopes: Option<&'s HashMap<I, String>>
|
||||
input(self, input: &'i I): Self
|
||||
notes(self, notes: &'n [I])
|
||||
slopes(self, slopes: &'s HashMap<I, VariableChange>)
|
||||
Loop --> ParserParametters
|
||||
Tuplet --> ParserParametters
|
||||
Slope --> ParserParametters
|
||||
struct Parser<'i, 'n, 's, 'v, I: Input + Clone, C: Into<char>> {
|
||||
-input: &'i I
|
||||
-parametters: ParserParametters<'n, 's, 'v, I, C>
|
||||
+parse_all(): Result<Vec<Box<dyn Token>>, nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
}
|
||||
struct ParserBuilder<'i, 'n, 's, 'v, I: Input + Clone, C: Into<char>> {
|
||||
-input: Option<&'i I>
|
||||
-notes: Option<&'n [I]>
|
||||
-slopes: Option<&'s HashMap<I, VariableChange>>
|
||||
-variables: Option<&'v [C]>
|
||||
+input(self, input: &'i I): Self
|
||||
+notes(self, notes: &'n [I]): Self
|
||||
+slopes(self, slopes: &'s HashMap<I, VariableChange>): Self
|
||||
+variables(self, variables: &'v [C]): Self
|
||||
}
|
||||
Token --> Parser
|
||||
Parser --> VariableChange
|
||||
|
@ -83,16 +98,15 @@ package compiler {
|
|||
|
||||
interface "From<ParserBuilder>" as from_parserbuilder
|
||||
interface "nom::Parser<nom_locate::LocatedSpan<&'i I>>" as nomparser_locatedspan
|
||||
interface "From<T>" as from_t
|
||||
|
||||
from_parserbuilder --> parser.ParserBuilder
|
||||
from_parserbuilder --> parser.ParserParametters
|
||||
from_parserbuilder --|> std.From
|
||||
nomparser_locatedspan --|> nom.Parser
|
||||
from_t --|> std.From
|
||||
parser.Parser --> nomparser_locatedspan
|
||||
parser.Parser ..|> from_parserbuilder
|
||||
parser.TokenParser ..|> nomparser_locatedspan: Output = T, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>
|
||||
parser.TokenParser ..|> from_t: where T: for<'i> nom::Parser<nom_locate::LocatedSpan<&'i I>, Output = Self, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
parser.Parser ..|> std.Iterator: Item = Result<Box<dyn Token>, nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
||||
parser.TokenParser --|> nomparser_locatedspan: Output = Self, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>
|
||||
nomparser_locatedspan ..|> parser.TokenParser: for any T
|
||||
parser.Slope --> parser.VariableChange
|
||||
parser.Token --> compiler.Context
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue