yiransheng / basic_rs Goto Github PK
View Code? Open in Web Editor NEWOriginal Dartmouth BASIC Interpreter/Compiler
Original Dartmouth BASIC Interpreter/Compiler
Also throwing away pretty much all source info
Example:
10 READ X
20 GOTO 200
Currently producing:
Compile error at Line: 0
Compile failed
Cause is in CFG traversal, the first NEXT takes away for state. Needs to check for index variable.
not proper DFS, visited node might get emitted more than once
Currently, scanner is somewhat spaces insensitive, it can recognize tokens like "L E T".
However, certain cases are not covered, such as "< =".
Do a full audit, and make sure spaces are skipped when needed, and add unit tests for all token types.
Currently LineNo
is a type alias to usize
.
Should convert it to a new type, as in a couple of places line numbers might get confused with line index.
Perhaps should use petgraph
crate to represent the graph, adds a bit overhead, but makes underlying algorithm and analysis clearer.
Find a lib for io, extend VM to accept chunks after init
This will allow interactive programs.
Supporting it in wasm
will be tricky, as INPUT
is blocking.. maybe use window.confirm
for this?
Changes required:
keyword.js
to generate new type and compile time DFA for keywordsToken
enumast
data types with new statement typeparser
Statement::Input
variant in ir
Input
OpCode
variantVM
to take in stdin.lock()
in run
and exec
methodstdin
input, fail on number parsing (add new variant to RuntimeError)unimplemented!()
on wasm sideLater,
Investigate window.confirm
approach
EDIT: window.prompt
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.