esseks / monicelli

An esoteric programming language, come se fosse antani.
GNU General Public License v3.0
1.32k stars 55 forks source link

Online compiler #30

Open fcalderan opened 8 years ago

fcalderan commented 8 years ago

Would it be feasible to have an online Monicelli compiler like many other eso-langs (Cjam, Pyth, ...)? I'd like to send my codegolf entries in this language

esseks commented 8 years ago

What an honour :) Monicelli is written in C++, which makes a web port quite difficult.

A rewrite in JS would be needed to build a web interpreter, which is not impossible (the grammar can be mostly reused and a transpiler derived from the C++ one), but quite a big task.

Executing the code server side and sending back the results is an easier alternative, although at the moment I am not willing to manage a properly sandboxed compilation and execution environment.

This stands as a valid, open issue.

lplume commented 8 years ago

Can you give me a starting point for the grammar, id like to check if I am able to do something, starting from pegjs

esseks commented 8 years ago

@lplume the grammar is contained in Monicelli.ypp (parser and semantic actions) and Monicelli.lpp (lexer). First an internal AST is built (see Nodes.hpp for AST nodes), then a visitor performs the transpilation (in the case of C++) or the lowering to LLVM IR. CppEmitter.cpp contains the C++-transpiling visitor.

As the name says, PEG.js builds from a parsing expression grammar, while the current Monicelli grammar is LALR(1) (purely because that's what Bison does). AFAIK you'll have to eliminate all left recursions, likely you will have to hammer the grammar hard or rewrite it from scratch. Feel free to correct me, though.

Please let me know if you intend to do anything serious, so that we can discuss, coordinate and avoid unnecessary duplications of efforts.