Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Signal Rebirthed
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Signal Rebirthed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Signal Rebirthed

    I was bored recently and decided to pick up the Signal project that was started by @jeremic.

    What the language had when he dropped the project:
    • Fully working expressions.
    • Conditional if/else blocks.
    • Functions.
    • All binary operators except modulo, exponent, +=, and -=.
    • All unary operators except ++ and --.
    • Class parsing but no actual functionality.
    • Loop (while and for) parsing but no actual functionality.
    • Parsing of break and continue statements but no actual functionality.
    • Print() native function but no c-function exports.
    • Basic string, number, boolean, and nil types.


    What I've added in the past 2 days:
    • Loop functionality (compilation and interpretation) for both while and for loops.
    • Functionality (compilation and interpretation) for both break and continue statements.
    • Class instance creation (via new operator).
    • Instance-level scoping for classes.
    • Member function calls for classes (parameters are acting up, though).
    • Unary operators ++ and -- (postfix).
    • String unescaping to support characters such as "\n" and "\t".
    • Many bug fixes with error reporting (strings were being passed into printf() as opposed to their .c_str() member calls).
    • Some changes to the overall structure of the architecture and virtual processor.
    • C-function exporting
    • Switch statements (lexing, parsing, compilation, and interpretation).
    • Function keyword.
    • Improvements many binary operators (will finish all of them soon).
    • Numeric values which allow decimal places.
    • Optimizations / cleanups to the VM code.
    • Parsing an AST creation for tables (Currently no compilation or interpretation, though).


    What I want to add before I inevitably get bored and ditch the language:
    • Class members abstract the table interface.
    • Fix parameter bugs for class member functions.
    • Global variables.
    • Remaining binary operators (modulo, exponent, +=, and -=).
    • More stuff that I can't think of right now.


    Here's what the syntax/usage currently looks like (no class stuff here because I'm currently improving it):
    Code:
    function testWhile(){
        print("Expect 'haahaahaa'\n ");
        n = 0;
        while (true)
        {
            n = n + 1;
            print("h");
    
    
            i = 0;
            while (i < 2)
            {
                i = i + 1;
                print("a");
            }
    
    
            if (n == 3)
                break;
            else
                continue;
        }
        print("\n");
    }
    
    
    function testFor()
    {
        print("Expect '012345 -- 54321 -- 13579'\n ");
        for (i = 0; i <= 5; i = i + 1)
        {
            print(i);
        }
        print(" -- ");
        for (i = 5; true; i = i - 1)
        {
            print(i);
            if (i == 1)
                break;
        }
        print(" -- ");
        for (i = 1; i < 10; i = i + 1)
        {
            if (i == 2 || i == 4 || i == 6 || i == 8)
                continue;
            print(i);
        }
        print("\n");
    }
    
    
    function testIncDec()
    {
        print("Expect '01021 | -1 | 4'\n ");
        var = 0;
        print(var);
    
    
        var++;
        print(var);
    
    
        var--;
        print(var);
    
    
        var++;var++;
        print(var);
    
    
        var--;
        print(var);
    
    
        print(" | ");
    
    
        var--;var--;
        print(var);
    
    
        print(" | ");
    
    
        val = 1;
        val = val + val++;
        print(val);
    
    
        print("\n");
    }
    
    
    function testSwitch(value)
    {
        switch (value)
        {
            case 3:
                print("three, ");
            case 2:
                {
                    print("two, ");
                }
            case 1:
                {
                    print("one\n");
                    break;
                }
            default:
            {
                print("other\n");
            }
        }
    }
    
    
    function main()
    {
        testWhile();
        testFor();
        testIncDec();
    
    
        print("Expect 'one'\n ");
        testSwitch(1);
        print("Expect 'two, one'\n ");
        testSwitch(2);
        print("Expect 'three, two, one'\n ");
        testSwitch(3);
        print("Expect 'other'\n ");
        testSwitch(4);
    }
    Here's the usage from c++ including a function export example:
    Code:
    //exported function prototype
    std::shared_ptr<Object> printFunc(Environment env, std::vector<std::shared_ptr<Object>> args);
    //execution of a script
    FileInput file (name);Lexer lexer (file);
    Parser parser (lexer);
    std::shared_ptr<AST> ast = parser.parse_program ();
    Environment env = Environment ();
    
    
    env.exportFunction("print", printFunc);
    
    
    Compiler::Compile(env, ast);
    Interpreter interpreter(env);
    interpreter.execute ();
    https://code.google.com/p/signalscript/

    //DarkstaR

  2. #2
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    cool subject to dig into. I'll like to watch this evolution.

    Do you have a written grammar (preferably EBNF) for this language? This would be handy to diagnose errors in the lexer / parser / ast etc as well write them.

  3. #3
    Quote Originally Posted by Blequi View Post
    cool subject to dig into. I'll like to watch this evolution.

    Do you have a written grammar (preferably EBNF) for this language? This would be handy to diagnose errors in the lexer / parser / ast etc as well write them.
    I'm not sure how to create one of these o.o. I kind of had to do a lot of RE to figure out the initial grammar since he had no documentation, and the remaining grammars I've implemented myself, so it's all in memory.

  4. #4
    Switch statements are done. That was pretty tricky.

  5. #5

  6. #6
    Wow it's interesting

  7. #7
    I've added in table parsing and creation for AST for tables. Need to work on compilation, assignment, and indexing now.

    Quote Originally Posted by astra View Post
    Wow it's interesting
    Thanks!

  8. #8
    Senior Member
    Join Date
    Nov 2009
    Posts
    320
    Xenobot will support this language ?
    oi amiguinhos

  9. #9
    Quote Originally Posted by Devil View Post
    Xenobot will support this language ?
    Maybe maybe not. This is a project I'm doing for learning purposes, I'm not sure if it will have the quality to be implemented into XenoBot. Plus, supporting two scripting languages is tricky.

  10. #10
    Senior Member
    Join Date
    Mar 2007
    Posts
    766
    Cool, nice to see some source is being put to good use, albeit the quality of my 4 year old code is quite embarrassing.

    How far have you gotten in this project DarkstaR? I think you will have trouble implementing object orientation, as the language needs to be built ground up with that mind. I hope I can showcase my new language that I've completed soon. It will be the basis for my new scriptable bot.
    Last edited by jeremic; 04-20-2014 at 05:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •