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"
|
@startuml "bliplib class diagram"
|
||||||
|
|
||||||
|
left to right direction
|
||||||
|
|
||||||
package std {
|
package std {
|
||||||
interface Iterator<type Item> {
|
|
||||||
next(&mut self): Self::Item
|
|
||||||
}
|
|
||||||
interface From<T> {
|
interface From<T> {
|
||||||
from(value: T): Self
|
from(value: T): Self
|
||||||
}
|
}
|
||||||
|
@ -14,39 +13,38 @@ package nom {
|
||||||
}
|
}
|
||||||
|
|
||||||
package parser {
|
package parser {
|
||||||
struct TokenParser<I, T> {
|
interface TokenParser<I>
|
||||||
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 Token {
|
interface Token {
|
||||||
apply(&self, context: Context): Context
|
-apply(&self, context: Context): Context
|
||||||
}
|
}
|
||||||
struct Silence {
|
struct Silence {
|
||||||
parser<I>(): TokenParser<I, ??>
|
-parser<I>(): impl TokenParser<I>
|
||||||
}
|
}
|
||||||
struct Marker {
|
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 {
|
struct Note {
|
||||||
n: u8
|
+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>>>
|
-parser<'a, I: nom::Input + nom::Compare<I> + Clone>(notes: &'a [I]): impl TokenParser<I>
|
||||||
}
|
}
|
||||||
struct VariableChange {
|
struct VariableChange {
|
||||||
name: char,
|
+name: char,
|
||||||
change: String
|
+change: String
|
||||||
|
-parser<'a, I, C: Into<char> + Clone>(variables: &'a [C]): impl TokenParser<I>
|
||||||
}
|
}
|
||||||
struct Loop {
|
struct Loop {
|
||||||
times: usize
|
+times: usize
|
||||||
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 Tuplet {
|
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 {
|
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
|
Silence ..|> Token
|
||||||
Marker ..|> Token
|
Marker ..|> Token
|
||||||
|
@ -55,18 +53,35 @@ package parser {
|
||||||
Loop ..|> Token
|
Loop ..|> Token
|
||||||
Tuplet ..|> Token
|
Tuplet ..|> Token
|
||||||
Slope ..|> Token
|
Slope ..|> Token
|
||||||
struct Parser<'i, 'n, 's, I: Input + Clone> {
|
Silence --> TokenParser
|
||||||
input: &'i I
|
Marker --> TokenParser
|
||||||
notes: &'n [I]
|
Note --> TokenParser
|
||||||
slopes: &'s HashMap<I, VariableChange>
|
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> {
|
Loop --> ParserParametters
|
||||||
input: Option<&'i I>
|
Tuplet --> ParserParametters
|
||||||
notes: Option<&'n [I]>
|
Slope --> ParserParametters
|
||||||
slopes: Option<&'s HashMap<I, String>>
|
struct Parser<'i, 'n, 's, 'v, I: Input + Clone, C: Into<char>> {
|
||||||
input(self, input: &'i I): Self
|
-input: &'i I
|
||||||
notes(self, notes: &'n [I])
|
-parametters: ParserParametters<'n, 's, 'v, I, C>
|
||||||
slopes(self, slopes: &'s HashMap<I, VariableChange>)
|
+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
|
Token --> Parser
|
||||||
Parser --> VariableChange
|
Parser --> VariableChange
|
||||||
|
@ -83,16 +98,15 @@ package compiler {
|
||||||
|
|
||||||
interface "From<ParserBuilder>" as from_parserbuilder
|
interface "From<ParserBuilder>" as from_parserbuilder
|
||||||
interface "nom::Parser<nom_locate::LocatedSpan<&'i I>>" as nomparser_locatedspan
|
interface "nom::Parser<nom_locate::LocatedSpan<&'i I>>" as nomparser_locatedspan
|
||||||
interface "From<T>" as from_t
|
|
||||||
|
|
||||||
from_parserbuilder --> parser.ParserBuilder
|
from_parserbuilder --> parser.ParserBuilder
|
||||||
|
from_parserbuilder --> parser.ParserParametters
|
||||||
from_parserbuilder --|> std.From
|
from_parserbuilder --|> std.From
|
||||||
nomparser_locatedspan --|> nom.Parser
|
nomparser_locatedspan --|> nom.Parser
|
||||||
from_t --|> std.From
|
parser.Parser --> nomparser_locatedspan
|
||||||
parser.Parser ..|> from_parserbuilder
|
parser.Parser ..|> from_parserbuilder
|
||||||
parser.TokenParser ..|> nomparser_locatedspan: Output = T, Error = nom::Err<nom::Error<nom_locate::LocatedSpan<&'i I>
|
parser.TokenParser --|> nomparser_locatedspan: Output = Self, 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>>>
|
nomparser_locatedspan ..|> parser.TokenParser: for any T
|
||||||
parser.Parser ..|> std.Iterator: Item = Result<Box<dyn Token>, nom::Error<nom_locate::LocatedSpan<&'i I>>>
|
|
||||||
parser.Slope --> parser.VariableChange
|
parser.Slope --> parser.VariableChange
|
||||||
parser.Token --> compiler.Context
|
parser.Token --> compiler.Context
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue