ArnoldC icon indicating copy to clipboard operation
ArnoldC copied to clipboard

Web page for evaluating ArnoldC programs

Open lhartikk opened this issue 10 years ago • 7 comments

lhartikk avatar Feb 25 '14 15:02 lhartikk

Several months ago, I put together a compiler for another language using CodeMirror and other JavaScript tricks: http://mapplz.com/howandwhy.html

I'll take a look at ArnoldC tonight and see what I can do. It'd be cool to host it on the gh-pages branch of this repo.

mapmeld avatar Feb 25 '14 19:02 mapmeld

Check it out! Not 100% but it has printing, variable initialization, variable assignment, and operands: http://mapmeld.github.io/ArnoldC/

Sample programs:

IT'S SHOWTIME
  HEY CHRISTMAS TREE varFalse
  YOU SET US UP @I LIED
  TALK TO THE HAND varFalse

YOU HAVE BEEN TERMINATED
IT'S SHOWTIME
  TALK TO THE HAND "How old will Arnold be this year?"
  GET TO THE CHOPPER age
    HERE IS MY INVITATION 2014
    GET DOWN 1947
  ENOUGH TALK
  TALK TO THE HAND age
YOU HAVE BEEN TERMINATED

If you screw up, it should have syntax errors (not Arnold-ified, unfortunately).

mapmeld avatar Feb 26 '14 07:02 mapmeld

Can you guide me how to compile it without using your compiler ?

Sourcex4447 avatar Feb 26 '14 10:02 Sourcex4447

@Sourcex4447 do you mean running it on another website? Requires jQuery, CodeMirror.js, plus arnoldc.js and arnoldc-compiler.js from that page.

Then you'd need to write a file like homepage.js to pass a

var your_text = $("<textarea>");
var myCodeMirror = CodeMirror( your_text[0], {
  mode: "text/x-ruby",
  lineNumbers: true
});

myCodeMirror.setValue("TALK TO THE HAND 3000");

execute_code($(your_text));

Result: console.log says "missing IT'S SHOWTIME on first line" -- you can overwrite console.log in your application to print onto the page.

mapmeld avatar Feb 26 '14 14:02 mapmeld

Can't I just Run in my windows PC ?

Sourcex4447 avatar Feb 26 '14 16:02 Sourcex4447

Oh, I misunderstood. Can you type some ArnoldC code in that text area and run it? If you're trying to run it outside of the web browser that is a separate issue.

mapmeld avatar Feb 26 '14 16:02 mapmeld

Now supports conditionals and loops! It runs the printing 1 to 10 example!

http://mapmeld.github.io/ArnoldC/?v=2

mapmeld avatar Feb 27 '14 05:02 mapmeld