-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Language design #1
Comments
What ideas do you have comrades, for parser\tokens\etc ? Are we gonna to use some existing tools for writing our alphabet, lexical\semantic rules and so on ? i.e. we can use Jison for parser. |
looks interesting, @ghaiklor, haven't seen it before, will definitely play with it tonight. |
I like this particularly because we can have some sort of a higher order shit |
ok, sorry for not doing anything for quite a while, I'll get back to it very soon, I hope! |
@vyorkin played a little bit with LLVM... What if we will take LLVM as a compiler and write LLVM frontend for our ShitScript ? |
@ghaiklor good idea (I've just watched this talk https://www.youtube.com/watch?v=PauCAyVg348), I need to build smth very simple first (sorry still don't have enough time) |
we definitely should target LLVM so we'll be able to use emascripten to target wasm |
oops |
@vyorkin here is my playground for llvm, but nothing special - https://github.com/ghaiklor/llvm-kaleidoscope |
how about using Rust + llvm-rs + lalrpop to build this? I'm going to start working on it these weekends, the time has come :)
we could use docopt or clap crates for CLI args parsing I'm still learning & playing with llvm-rs crate (the |
@vyorkin I've started R&D in parsers written in JavaScript. Found Lexical analysis - Jalex. You can describe rules via regular expressions and it will call a callback when match is found. So, we will be able to describe lexical rules via regular expressions and implement all needed actions for returning a stream of tokens. Semantic analysis - Jison. It has its own simple built-in lexical analyzer, though, I'm thinking to use Jalex, since we will definitely write our own scanner in future. Why I chose them? They are compatible with lex\yacc format. So you can describe definitions, translation rules in plain old-way as it was done in yacc. For a grammar, we can try to found already implemented grammar for JavaScript and just modify it to fit our needs. Though, still thinking about other lexical analyzers, but for semantic analysis I didn't found too much, so seems like Jison is our only options for semantic. |
@ghaiklor do you know any good LLVM bindings for nodejs? I've found only these 2:
|
@vyorkin I'm wondering why you stick to LLVM 😸
So steps are with LLVM will be close to defining a scanner with rules which returns tokens with inherited and synthetic attributes. Passing these tokens into a parser which has our grammar with semantic actions. During parsing of our tokens, parser will be able to call our semantic action where we are calling LLVM IR Builder. And, do not forgot about code-generation phase which we also need to implement with LLVM. Anyway, we'll not get magical solution for ShitScript if we are stick to LLVM. My initial idea is to examine existing generators for lexical and semantic parsers, so we can build our own grammars right from scratch and use generators to create parsers. Afterwards, I'm looking for a way to create our own code generator. Still thinking about it, but if we will have a grammar and a parse tree, that's not a big issue to generate code in SSA form. Aaaand, when we have SSA form, that's not a big issue to generate an Assembly code from it. To be honest, I even think about generating machine code from JavaScript, but that's just thoughts. What you all think? @vyorkin @chicoxyzzy maybe and @bniwredyc |
Wow, thanks! I'll give a detailed answer today later, here is my latest unfinished playground in rust which I've started to work on after working through LLVM kaleidoscope tutorial series (same thing as you did, but I'm still not finished it yet:)). I've stopped here (LLVM IR Builder / Emitter visitor). UPD: |
Agreed, though, you still need to implement the correct way of applying these optimizations. We are creating a ShitScript here, do not forgot about it. And the question here is does it worth it to investigate so much time in LLVM for building a ShitScript ? 😸 |
@vyorkin also, I've just found LLVM compiled to JavaScript itself - https://github.com/kripken/llvm.js I.e. // Here input is an LLVM IR
function process(input) {
try {
return llvmDis(llvmAs(input));
} catch (e) {
if (typeof e == 'string') {
return 'Error in compilation: ' + e;
} else {
throw e;
}
}
} Worth note that it's just a playground and as author mentioned:
|
Sorry I'm too drunk for this kind of shit RN |
moved from shitjs/meta/issues/2
Initial thoughts
informal description
var
(variables are always declared in a global scope by default)return
– ShitScript returns the last evaluated expressionarray
's, noobject
's (except forconsole
andwindow
)shitty ideas
-
,?
,!
in function names (no-camel-case
)'shit'
);
->)))
===
->====
,!==
->!===
(...)
->[...]
function
->shit
/fuck
try
->why-the-fuck-not
catch
->fucked-up
finally
->dont-fucking-care
please
to enable lexical scoping4
and2
) for no reasonx / 0
=Math.random()
if
->o-rly?
then
->ya-rly
else
->no-way
o-rly?
-ya-rly
-no-way
for one-liners (without brackets).
->->
(works only forconsole
andwindow
)an example program:
P.S.: Not sure about using words
fuck
andshit
everywhere (may be considered offensive)The text was updated successfully, but these errors were encountered: