Hi. ๐
danii / hematita Goto Github PK
View Code? Open in Web Editor NEWA memory safe Lua interpreter
License: GNU General Public License v3.0
A memory safe Lua interpreter
License: GNU General Public License v3.0
Hi. ๐
Running the same benchmarks as in LuaJIT against both the canonical and LuaJIT interpreters would be interesting to have a ballpark estimation about whether this is also a proper replacement where speed matters.
It may also help guide optimizations if needed.
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/hematita_cli`
> if 1==1 then
>> return
>> end
syntax error: unexpected 'end'
>
Token's locations within the source are not currently tracked, meaning error information is scarce, and diagnosing syntax problems becomes tedious.
my code:
fn run(&self, code : &mut Peekable<impl Iterator<Item = char>>) -> Result<Arc<vm::value::Table>> {
let lexer = ast::lexer::Lexer{ source : code.peekable()};
let parsed = ast::parser::parse_block(
&mut ast::parser::TokenIterator(lexer.peekable())
)?;
let compiled = compiler::compile_block(&parsed);
let result = self.vm.execute(&compiled.into(), lua_tuple![].arc()).map_err(into_err)?;
Ok(result)
}
error occurs on lua_tuple![]
error message:
unresolved import
hashbrown
use of undeclared crate or modulehashbrown
rustcClick for full compiler diagnostic
value.rs(124, 8): Actual error occurred here
if i do cargo add hashbrown the error changes to this:
mismatched types
structhashbrown::HashMap
and structhashbrown::map::HashMap
have similar names, but are actually distinct types
perhaps two different versions of cratehashbrown
are being used?rustcClick for full compiler diagnostic
value.rs(133, 28): Actual error occurred here
value.rs(133, 17): arguments to this function are incorrect
map.rs(188, 1): structhashbrown::HashMap
is defined in cratehashbrown
map.rs(192, 1): structhashbrown::map::HashMap
is defined in cratehashbrown
mutex.rs(219, 18): associated function defined here
my dependecies are:
[dependencies]
hematita = "0.1.0"
string-error = "0.1.0"
Modulo operator as simple as that:
print(5 % 2)
Gives out this error:
$ hematita_cli a.lua
runtime error: unknown binary operation error
Probably modulo operator is not properly implemented?
Hi,
First of all thanks for this project. I would like to have more time and knowledge to help on hematita. :)
So, let's talk about bugs...the code below does not run on hematita_cli
, but on luajit works fine.
$ hematita_cli print_html.lua
syntax error: unexpected ','
-- print_html.lua
local html = [[
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
]]
local html_footer = [[
</body>
</html>
]]
print(html)
From what I've seen, the project currently handles memory with Arcs, which will leak on cyclic references. Are there plans to use a real garbage collector?
In Lua, all numbers are assumed to be doubles, not integers.
Using double numeric values causes the parser to crash.
local PI = 3.14
panics on let parsed = parser::parse_block(&mut parser::TokenIterator(lexer)).unwrap();
while
local meaning_of_life=42
works perfectly fine.
The pairs
Lua function cannot be implemented because it is deterministic without state. It seems as if the reference implementation PUC Lua actually uses b-trees rather than hash maps to store tables.
Hmm. Tried installing the CLI based on the README and it failed:
$ cargo install hematita_cli
Updating crates.io index
error: could not find `hematita_cli` in registry `crates-io` with version `*`
I've tried on Ubuntu 21.10 and Windows 7 (yes, it's old on purpose :D)
The example in the README will fail due to the lua_tuple!
macro needing the hasbrown crate. What's a bit unfortunate is that hasbrown 0.12 has restructured things a bit.
Without hasbrown at all, you'll receive
use of undeclared crate or module `hashbrown`
And with 0.12 you'll receive
expected struct `hashbrown::map::HashMap`, found struct `hashbrown::HashMap`
After setting the version in my projects Cargo.toml to 0.11.2 things started working.
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.