Parser and interpreter for the while programming language
The while programming language is a verry simplified language, which is turing complete!
The set of WHILE programs is the language generated by the following grammar
where
(the set of non terminal Symbols)
(the set of terminal symbols)
(the start non terminal)
(the set of production rules)
as expected, i guess … lol
NOTE: the subtraction is only defined in 
also i added a max recursion depth like python3 to prevent users to write non terminating code … (the max rec depth for a while loop is 1500 iterations)
lets say you have a function 
lets calculate 
cat ./examples/multiplication-func.while// init var state
rv := 0;
a := 420;
b := 69;
// loop will be exec b-times
while b != 0 do
    // calculate rv += a (b-times)
    //  -> a * b = a + a + ... b-times
    temp := rv;
    loop a do temp := temp + 1 end;
    rv := temp;
    b := b - 1
end
since this is a bit tidies i allowed users to use expressions in the context
- conditions
- additions
- and subtractions
(refer to the grammar defined above)
shortened (not commpletely while-language correct …) version
x0 := 0; x1 := 420; x2 := 69; loop x2 do x0 := x0 + x1 end
stack run= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = [Error]: Usage: stack run <filename> Use 'stack run <filename>' to interpret a while source file. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
stack run ./examples/multiplication-func.while= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
[Interpreting file]    ./examples/multiplication-func.while
[READING .WHILE FILE] "./examples/multiplication-func.while"
[DONE TOKENIZE]
[DONE PARSING AST]
[RESULT OF EVALUATION]
[("temp",28980),("b",0),("a",420),("rv",28980)]
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
or use
stack ghci--      ast              tokens       lines of code     file name
ast <- runASTParser . tokenize <$> readFileContent "./filename.wile"
-- print $ eval ast []  -- eval v1
-- print $ evalT ast []  -- eval v2
let program = evalM ast  -- Monad eval
print $ getVarState program []
-- eg.
--
--  let program2 = evalM ast_1 >> evalM ast_2 >> ...
--  print $ getVarState program2 []
--
-- where `ast_1` could set global vars and `ast_2` could
--  contain a script using the global vars ...
-- or use:
--  print $ runEvalM ast []stack buildstack runstack teststack exec hlint src/*.hs app/*.hs test/*.hspre-commit run --all-filescurl -SL https://get.haskellstack.org/ | shapt install ghcapt install hlintnix-shellhlint src/*.hs app/*.hs test/*.hssame as before
cat ./LICENSECopyright Felix Drees (c) 2023
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of Felix Drees nor the names of other
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.