Sinisterly
Xitram language interpreter - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: PHP (https://sinister.ly/Forum-PHP)
+--- Thread: Xitram language interpreter (/Thread-Xitram-language-interpreter)

Pages: 1 2


RE: Xitram language interpreter - 1llusion - 06-10-2013

(06-10-2013, 12:35 PM)noize Wrote: But this is fucking Cool.

Check out say.php, in the comment you're saying you don't want any additional comment, but that's wrong for sure.

Oops that is what happens when you use one keyword as template for others Smile
fixed, thanks for reporting Smile


RE: Xitram language interpreter - noize - 06-10-2013

Don't have a Github account yet, so I'll just push a few PHP commands I translated in Xitram keyword file basing on that template:

file_put_contents(file,data) => writef(file,data)
Code:
<?php class writef implements keywords{ private $error = NULL; //We will store errors here public function error(){ //This will be called when some error is found return $this->error; } public function syntax($string){ if(empty($string)){ $this->error .= "Syntax error. \"writef\" requires additional arguments."; return false; } return true; } public function run($string){ file_put_contents $string; } } ?>

mkdir(dirname, mode, 2 args I can't remember what they do) => newd(dirname,mode,arg3,arg4)
Code:
<?php class newd implements keywords{ private $error = NULL; //We will store errors here public function error(){ //This will be called when some error is found return $this->error; } public function syntax($string){ if(empty($string)){ $this->error .= "Too few arguments for 'newd'."; return false; } return true; } public function run($string){ mkdir $string; } } ?>

I've used two different error messages, I think the latter is the better one (the one for newd).

You shall probably use the same error style for all commands, of course, so choose well.

P.S: I know it's not much, I'll try for something more tomorrow.


RE: Xitram language interpreter - 1llusion - 06-10-2013

(06-10-2013, 11:19 PM)noize Wrote:
Spoiler:
Don't have a Github account yet, so I'll just push a few PHP commands I translated in Xitram keyword file basing on that template:

file_put_contents(file,data) => writef(file,data)
Code:
<?php class writef implements keywords{ private $error = NULL; //We will store errors here public function error(){ //This will be called when some error is found return $this->error; } public function syntax($string){ if(empty($string)){ $this->error .= "Syntax error. \"writef\" requires additional arguments."; return false; } return true; } public function run($string){ file_put_contents $string; } } ?>

mkdir(dirname, mode, 2 args I can't remember what they do) => newd(dirname,mode,arg3,arg4)
Code:
<?php class newd implements keywords{ private $error = NULL; //We will store errors here public function error(){ //This will be called when some error is found return $this->error; } public function syntax($string){ if(empty($string)){ $this->error .= "Too few arguments for 'newd'."; return false; } return true; } public function run($string){ mkdir $string; } } ?>

I've used two different error messages, I think the latter is the better one (the one for newd).

You shall probably use the same error style for all commands, of course, so choose well.

P.S: I know it's not much, I'll try for something more tomorrow.

Perfect! I'll add them tomorrow as I'm off to bed now Smile
Thanks for the contribution Smile

Note: feel free to add your username, credits or w/e as a comment. I'll later on create a "help" command, that will display descriptions etc. of commands Smile