smackem / rust-calc Goto Github PK
View Code? Open in Web Editor NEWA text-based calculator written in Rust
License: MIT License
A text-based calculator written in Rust
License: MIT License
#:
should enter parallel mode. All statements entered in parallel mode are stored but not executed. #.
leaves parallel mode, executes all stored statements in parallel and prints the results.
Command #w
should write out the current context into a JSON file (e.g. ~/rcalc.json
).
Instead of panic!
ing on errors, the parser methods should return std::Result
.
Augment grammar with function declarations:
stmt:
'let' IDENTIFIER '=' expr
'let' IDENTIFIER '(' identifier-list ')' '=' expr
expr
... and function calls:
atom:
...
IDENTIFIER '(' expr-list ')'
...
Instead of i32
, values should be held in enum Value
which supports long integers, floating point numbers and conversion between the two.
Use Rocket to support http calls: REST interface and tiny HTML page that uses javascript to consume REST service.
[10, 20, 30]
as well as [0..10]
( = [0,1,2,3,4,5,6,7,8,9]
) and [0..10:2] ( = [0,2,4,6,8]
) should denote a vector v
.
v + 1 = [v0 + 1, v1 + 1, v2 + 1]
etc.
Create a struct Calculator
that holds state about bindings and lexer tokens.
Leave mod tests
wherever appropriate (unit test f. internals)
Don't just display the debug representation of the interpreter result, but display numbers in appropriate format, e.g. for Integer:
10
Ah
1010b
-
can be lexed as the start of a literal (-5 for example) and may also denote the subtraction operator. Which meaning is parsed depends on whitespace usage:
5-5
is a parser error (atom atom
where atom OP atom
is expected)5 - 5
parses correctly as atom MINUS atom
-
and removing the lexer ability to lex negative numbers.Describe project in README.md
#precision NUMBER
should control the number of decimal digits.
All operators are now parsed as right-assoc with recursion. Migrate to loops for left-assoc operators. Test against 5 - 5 - 5
, which should yield -5
but yields 5
as is.
Support number literals like 0xA8F3
or 0b1100_0101_0001
Add the following operators:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.