purplemyst / epython Goto Github PK
View Code? Open in Web Editor NEWEPython is be a toy CPython bytecode interpreter written in Elixir.
License: GNU General Public License v3.0
EPython is be a toy CPython bytecode interpreter written in Elixir.
License: GNU General Public License v3.0
def add(a, b):
print(a + b)
add(1, 2, 3)
This prints 3, when it should error.
Additionally:
def a(x, y):
print(x * 1)
a(3)
This also prints 3.
Adding an import system is important, due to it being one of python's biggest strengths.
__name__
, ...)math
, ...)os
, sys
, ...)Exception handling is a pretty key concept. This is a tracking issue for everything related to it.
try
/except
statements** (KeyError) key :pc not found in: %EPython.InterpreterState{next_id: 0, objects: %{}, refcounts: %{}, topframe: %EPython.PyFrame{blocks: [], code: [argcount: 2, kwonlyargcount: 0, nlocals: 2, stacksize: 3, flags: 67, code: <<116, 0, 124, 0, 124, 1, 26, 0, 131, 1, 1, 0, 100, 0, 83, 0>>, consts: {:none}, names: {"print"}, varnames: {"x", "y"}, freevars: {}, cellvars: {}, filename: "test.py", name: "a", firstlineno: 1, lnotab: <<0, 1>>], pc: 8, previous_frame: %EPython.PyFrame{blocks: [], code: [argcount: 0, kwonlyargcount: 0, nlocals: 0, stacksize: 3, flags: 64, code: <<100, 0, 100, 1, 132, 0, 90, 0, 101, 0, 100, 2, 100, 3, 131, 2, 1, 0, 100, 4, 83, 0>>, consts: {[argcount: 2, kwonlyargcount: 0, nlocals: 2, stacksize: 3, flags: 67, code: <<116, 0, 124, 0, 124, 1, 26, 0, 131, 1, 1, 0, 100, 0, 83, 0>>, consts: {:none}, names: {"print"}, varnames: {"x", "y"}, freevars: {}, cellvars: {}, filename: "test.py", name: "a", firstlineno: 1, lnotab: <<0, 1>>], "a", 1, 2, :none}, names: {"a"}, varnames: {}, freevars: {}, cellvars: {}, filename: "test.py", name: "<module>", firstlineno: 1, lnotab: <<8, 3>>], pc: 16, previous_frame: nil, stack: [], variables: %{"a" => %EPython.PyUserFunction{code: [argcount: 2, kwonlyargcount: 0, nlocals: 2, stacksize: 3, flags: 67, code: <<116, 0, 124, 0, 124, 1, 26, 0, 131, 1, 1, 0, 100, 0, 83, 0>>, consts: {:none}, names: {"print"}, varnames: {"x", "y"}, freevars: {}, cellvars: {}, filename: "test.py", name: "a", firstlineno: 1, lnotab: <<0, 1>>], name: "a"}}}, stack: [0.0, %EPython.PyBuiltinFunction{function: #Function<0.22053186/2 in EPython.Interpreter.builtins/0>, name: "print"}], variables: %{"x" => 1, "y" => 2}}}
(epython) lib/epython/interpreter.ex:163: EPython.Interpreter.execute_instructions/1
(elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2
Code:
print(3 // 2)
Currently function calls are limited to positionary arguments with no default values. Here are some features that need to be implemented:
(Note: A hard crash is when the interpreter crashes, rather than the Python code crashing.)
It might be useful to print the line of CPython bytecode, the line of Python code, and stack/frames in the case of an unhandled interpreter crash.
OO support is a critical part of Python.
__init__
etc)And so on.
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.