Shop OBEX P1 Docs P2 Docs Learn Events
AdvSys2 Development - RIP - Page 3 — Parallax Forums

AdvSys2 Development - RIP

13»

Comments

  • I think he's referring to the _STACK constant which you can set (along with a related constant _FREE). _STACK just tells the compiler how much space will be needed for the stack, so that if the sum of the code size, data size, _STACK, and _FREE value is more than 32KB it can report an error. It doesn't actually reserve any space, just makes sure that the program will fit in a certain amount of memory. It might be kind of useful if you link your bytecode program to a certain fixed address, say $1000 (4K); then you can set _FREE to $7000 (28 K) and _STACK to what you think the interpreter needs for stack, and then openspin will let you know if the interpreter is too big to fit in its 4K space.
  • OK, thanks. I never knew about _STACK or _FREE. This is the first time I've ever heard it mentioned.
  • David BetzDavid Betz Posts: 14,516
    edited 2018-09-29 02:14
    I've updated the compiler to produce Propeller .binary files directly and have also made it possible to build it for Windows. I guess I should write a document describing the language and post a package so those not comfortable checking code out of GitHub and building it could try it. I suppose I could build a Propeller loader in as well so you could do everything with a single executable.
  • David BetzDavid Betz Posts: 14,516
    edited 2018-10-01 00:50
    I changed the method invocation syntax to look more like C++. The old syntax was pretty ugly. The object "proto" is the prototype object. The object "obj" inherits from it but adds its own properties and a method. Obviously, this is just a test program but it shows how methods are invoked.
    object proto {
    p1: 1;
    p2: 2;
    m1: method(a) {
            return self.p1;
        };
    m2: method(b) {
            var res = self.p1 + b;
            println "proto.m2 ", b, " -> ", res;
            return res;
        };
    }
    
    proto obj {
    p1: 3;
    p3: 4;
    m2: method(x) {
            var res = super.m2(x) + self.p1;
            println "obj.m2 ", x, " -> ", res;
            return res;
        };
    }
    
    def main()
    {
        println proto.m1(100);
        println obj.m1(200);
        println obj.m2(10);
    }
    
  • Finally finished adding the vocabulary statements that will allow me to parse English commands instead of single-letter ones. These are the first statements that are mostly useful to people writing text adventure games although I suppose other programs that require language parsing could use them as well. Infocom used its language to write a database program! Anyway, my next task is to actually use my language to write a parser. For the moment, I'm done with language implementation and can now become a language user.
  • Here is some rather ugly test code that shows the vocabulary feature. Note that the compiler automatically creates the arrays "_words" and "_wordTypes" if you use any of these vocabulary features. If you don't use them the arrays are not created.
    var myString[16]; // 64 byte string
    
    noun "fred", "george", "troll";
    verb "take", "drop";
    
    object obj1 {
    p1: 2;
    p2: 1;
    noun: "herbert";
    verb: { "swing", "throw", "shout", "gurgle" };
    }
    
    def main()
    {
        var i, j;
        
        println _words[-1], " words";
        for (i = 0; i < _words[-1]; ++i)
            println #_words[i], " ", _wordTypes[i];
            
        for (i = 0; i < obj1.verb[-1]; ++i)
            println #obj1.verb[I];
    
        for (i = 0; i < obj1.verb[-1]; ++i) {
            for (j = 0; j < obj1.verb[i].byte[j] != 0; ++j) {
                myString.byte[0] = obj1.verb[i].byte[j];
                myString.byte[1] = 0;
                println "'", #myString, "'";
            }
            println;
        }
    }
    
  • David BetzDavid Betz Posts: 14,516
    edited 2018-10-14 21:20
    I've disabled WordFire/Quby support in the advsys2 GitHub repository for the time being because it depends on a keyboard driver that is not open source. That means that anyone who didn't have the driver got an error when they tried to build the advsys2 tools. This change makes the repository build for everyone. I will enable it again once I have a chance to write an open source keyboard driver. This should not slow down my parser development because I can always test using an ActivityBoard with serial I/O.
  • The first step in writing a parser is accepting a full line of text. Here is the beginning of that. As you can see, this C-like language is pretty standard and you write code pretty much the way you would in any high-level language. At some point I'd like to replace the inline TRAP instructions with code that invokes the full duplex serial PASM code directly instead of going through a Spin helper program. That shouldn't really be that hard once I have a way to load code into another COG.
    def BS = 0x08;
    def DEL = 0x7f;
    def CR = 0x0d;
    
    def getc()
    {
        asm {
            TRAP 0
            RETURN
        }
    }
    
    def putc(ch)
    {
        asm {
          LADDR 0
          LOAD
          TRAP 1
        }
    }
    
    var lineBuffer[16]; // 64 byte buffer
    
    def getLine()
    {
        var i, ch;
        i = 0;
        while ((ch = getc()) != CR) {
            if (ch == BS || ch == DEL) {
                if (i > 0) {
                    --i;
                    putc(BS);
                    putc(' ');
                    putc(BS);
                }
            }
            else {
                lineBuffer.byte[i++] = ch;
                putc(ch);
            }
        }
        lineBuffer.byte[i] = 0;
    }
    
    def main()
    {
        while (1) {
            putc(':');
            getLine();
            println;
            println "Got: ", #lineBuffer;
        }
    }
    
  • I spent some time this past weekend converting some of my old C parser code to the advsys2 language and in the process I decided that there really isn't enough difference between my new language and C itself. I've decided that it would be better to just use PropGCC with the CMM memory model rather than creating a new language. The main advantage of the advsys2 is its data definition features and it is likely that I will extract those and build a data structure compiler that can be combined with game logic written in C. No need to create a completely new language for this. It was fun getting it working but I'm not sure it's worth much continuing effort.
  • jmgjmg Posts: 15,172
    David Betz wrote: »
    I spent some time this past weekend converting some of my old C parser code to the advsys2 language and in the process I decided that there really isn't enough difference between my new language and C itself. I've decided that it would be better to just use PropGCC with the CMM memory model rather than creating a new language. The main advantage of the advsys2 is its data definition features and it is likely that I will extract those and build a data structure compiler that can be combined with game logic written in C. No need to create a completely new language for this. It was fun getting it working but I'm not sure it's worth much continuing effort.

    If you have some features within advsys2 worth keeping, maybe it can emit C, so you can have the benefits of both ?
  • That’s what I will do eventually. I’ll make the data structure compiler emit C data structures that can be used with a C library. I probably should have done that in the first place but designing programming languages is fun. :smile:
Sign In or Register to comment.