aboutsummaryrefslogtreecommitdiff
path: root/manifest
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-16 14:15:42 +0100
committerCharles <sircharlesaze@gmail.com>2020-03-16 14:15:42 +0100
commit8c8f6155f1b05230c271059c52a503211aec872b (patch)
tree53626fa32ad3f6178b42a9dc5db588ee01277cd5 /manifest
parentd17423cba7c15a26f835a6fa578ecb48b80d8aab (diff)
downloadcomputorv2-8c8f6155f1b05230c271059c52a503211aec872b.tar.gz
computorv2-8c8f6155f1b05230c271059c52a503211aec872b.tar.bz2
computorv2-8c8f6155f1b05230c271059c52a503211aec872b.zip
file Renaming, basic REPL
Diffstat (limited to 'manifest')
-rw-r--r--manifest96
1 files changed, 96 insertions, 0 deletions
diff --git a/manifest b/manifest
new file mode 100644
index 0000000..7216fa7
--- /dev/null
+++ b/manifest
@@ -0,0 +1,96 @@
+Data struct:
+ - expression
+ - matrix
+ - complex
+
+ - polynomial
+
+State Data struct:
+ - function
+ - variable
+
+
+
+Instruction/line:
+ if is '?' evaluate label else declare label.
+
+instruction ::= <label> '=' (<expr> | '?')
+
+
+Declaration:
+ label is a declaration of function or variable name
+
+label ::= <funcDecl> | <var>
+funcDecl ::= <var> '(' <var> ')'
+var ::= [a-zA-Z]+
+
+
+Expression:
+
+5. real imag matrix
+4. + -
+3. * / % **
+2. ^
+1. ( ) -- not an operator
+
+expr ::= <sum> | <imag> | <matrix> | <real> | <var> | <funcExpr>
+
+Arithmetic:
+
+sum ::= <term> (+ | -) <sum> | <term>
+term ::= <factor> (* | / | % | **)? <term> | <factor> -- default to '*'
+factor ::= <base> '^' <factor> | <base>
+base ::= '(' <expr> ')' | <expr>
+
+Leaf:
+
+real ::= [0-9]+(\.[0-9]+)?
+imag ::= <real> '*'? 'i'
+matrix ::= '[' (<matrixRow> ';')* ']'
+matrixRow ::= '[' (<expr> ',')* ']'
+fundExpr ::= <var> '(' <expr> ')'
+
+REPL:
+
+1. read user input
+2. parse it into an ast
+3. reduce the ast to the minimum possible form
+4.
+
+every expression is a binary tree, except () which can be interpreted by changing the
+structure of the tree.
+
+operators and operand are both expression (tree nodes).
+
+operators always need 2 operand (not leaf node)
+operand need 0 (leaf node)
+
+evaluation of operand return the operand
+evaluation of operator, evaluate his childs, perform the operation on them, return the result
+
+fold?
+!monoid
+
+ +
+ / \
+ * \
+ / \ \ 3 * 4 + (5 - 3i)
+3 4 -
+ / \
+ 5 3i
+
+Node +
+|_ Node *
+| |_ Leaf 3
+| |_ Leaf 4
+|
+|_ Node -
+ |_ Leaf 5
+ |_ Leaf 3i
+
+
+i^0 = 1
+i^1 = sqrt(-1) = i
+i^2 = -1
+i^3 = -sqrt(-1) = -i
+i^4 = 1