Various issues discovered while compiling Rawrcat
I saw this project, and decided to give it a shot on compiling my JavaScript implementation of RawrCat.
https://github.com/ephsec/rawrcat
Tested versions:
- NectarJS
v0.7.99 - NectarJS
masteroff github.
Invoking nectarjs on rawrcat.js uncovered several issues:
-
delete item[k]throws a parse error inbabel -
for()loops require explicitvardeclaration inside thefor()if the variable isn't defined beforehand. (This is something I will fix in my source code, for linting purposes) -
My use of
nullcomparison isn't yet supported:
Visitor VISITOR.objectExpression not implemented yet for NullLiteral
- My use of conditional expressions doesn't seem to be much liked either:
Visitor VISITOR.objectExpression not implemented yet for ConditionalExpression
Is there a debug mode that will tell me exactly where in the source it's having issues? --verbose does not appear to do much.
This project interests me, and I'd like to help get it to where it can compile RawrCat. I'm a language, parser, and compiler nerd myself.
Hi @wbrown ,
thank you for your interest in NectarJS,
I will try to compile Rawrcat to check the bugs and correct them
Right now there is no debug mode, but it's on the roadmap
-
for()loops require explicitvardeclaration inside thefor()if the variable isn't defined beforehand. (This is something I will fix in my source code, for linting purposes)
I've just corrected the above in my source code, as it's actually more correct code to use var to avoid bringing in scope from outside the loop.
the file you want to compile is rawrcat.js ?
@adrien-thierry Yes, sir. Though now that I think about it -- how does it handle require() calls?
Ok, i will check it
For require, code is encapsuled into a function call then integrated in the code
@adrien-thierry Any updates? Any way I can help? :)
Hi, yes sorry, a lot of things ti do haha
NectarJS doesn't support dynamic require yet, can you modify this ?
I will add the missing visitors and missing method
I corrected the delete item[k] problem,
I will continue to correct things until we can compile Rawrcat
NectarJS doesn't support dynamic require yet, can you modify this ?
So what do you mean by this? Just static require statements for the modules in question?
Rather than wrapping require in a handler with a variable passed, do static requires for the modules?
i.e. rather than: https://github.com/ephsec/RawrCat/blob/master/rawrcat.js#L17-L36
... and dynamically loading the modules in at runtime, like so: https://github.com/ephsec/RawrCat/blob/master/index.html#L43
... we do:
require("js/rawrterm.js")
... ?
Yes, exactly, atm, require in NectarJS is a macro that manage code including wrapped in a module. When NectarJS will be self compiled, we will be able to self embed the compiler and generate code from module on the fly, but for now, the only solution is to use static require
@adrien-thierry Is there a test or variable I can check to detect that that the code is being compiled by NectarJS, or running as a NectarJS-produced executable?
I've managed to avoid a build system thus far by checking the runtime environment, and I'd like to continue to do this if possible. :)
Yes, you can check the __NJS_ENV global var like :
if(__NJS_ENV)
{
// NectarJS
}
else
{
// not NectarJS
}
The __NJS_ENV var store the name of the env you compile the code with (std, android, arduino, node ...)
@adrien-thierry I've added the check for the existence of __NJS_ENV, hopefully this works:
https://github.com/ephsec/RawrCat/commit/7b38fd99ec5d7f699a2a9157f4ec8a7c6461e03b
Hi @wbrown , I corrected some problems, i will continue
Hi @wbrown , I corrected some problems, i will continue
Awesome. Which problems, out of curiosity?
Hi @wbrown , we implemented our own parser, we will release a big update soon