switch variablechange string to fasteval instruction, add context structure for compiling
This commit is contained in:
parent
227d6bcec3
commit
f4e6bd6e3d
1 changed files with 13 additions and 4 deletions
|
@ -12,6 +12,10 @@ package nom {
|
||||||
interface Parser<I>
|
interface Parser<I>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package fasteval {
|
||||||
|
enum Instruction
|
||||||
|
}
|
||||||
|
|
||||||
package parser {
|
package parser {
|
||||||
interface TokenParser<I>
|
interface TokenParser<I>
|
||||||
interface Token {
|
interface Token {
|
||||||
|
@ -29,7 +33,7 @@ package parser {
|
||||||
}
|
}
|
||||||
struct VariableChange {
|
struct VariableChange {
|
||||||
+name: char,
|
+name: char,
|
||||||
+change: String
|
+change: Instruction
|
||||||
-parser<'a, I, C: Into<char> + Clone>(variables: &'a [C]): impl TokenParser<I>
|
-parser<'a, I, C: Into<char> + Clone>(variables: &'a [C]): impl TokenParser<I>
|
||||||
}
|
}
|
||||||
struct Loop {
|
struct Loop {
|
||||||
|
@ -90,9 +94,12 @@ package parser {
|
||||||
|
|
||||||
package compiler {
|
package compiler {
|
||||||
struct Context {
|
struct Context {
|
||||||
result: Vec<f64>
|
+result: Vec<f64>
|
||||||
variables: HashMap<char, f64>
|
+variables: HashMap<char, f64>
|
||||||
?
|
+instrument: Instruction
|
||||||
|
+slopes: HashMap<char, Instruction>
|
||||||
|
+current_length(&self): f64
|
||||||
|
+render(&self, n: Option<u8>): Vec<f64>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,5 +116,7 @@ parser.TokenParser --|> nomparser_locatedspan: Output = Self, Error = nom::Err<n
|
||||||
nomparser_locatedspan ..|> parser.TokenParser: for any T
|
nomparser_locatedspan ..|> parser.TokenParser: for any T
|
||||||
parser.Slope --> parser.VariableChange
|
parser.Slope --> parser.VariableChange
|
||||||
parser.Token --> compiler.Context
|
parser.Token --> compiler.Context
|
||||||
|
VariableChange --> Instruction
|
||||||
|
Context --> Instruction
|
||||||
|
|
||||||
@enduml
|
@enduml
|
Loading…
Add table
Add a link
Reference in a new issue