0 Members and 1 Guest are viewing this topic.
I think the best thing to at least build the parse tree part of the compiler (without releasing it) and add the features you have designed so far. If you're programming it correctly in a massively inheritable object oriented way, this should be extremely easy to add and remove features at around the same speed you can come up with them on paper.
Quigibo: I've had a few premature run-throughs with compilers before. Last time, I went through and changed some key rules which really affected parsing and verification rules for classes & interfaces. I do have a couple aspects already in place; However, the new design is free of MUCH of that red tape (since it lacks a type-hierarchy), so I might be able to put more up sooner (school etc. permitting)
input: expr TOKEN_SEMICOLONexpr: expr TOKEN_PLUS expr | expr TOKEN_MULTIPLY expr | var TOKEN_ASSIGN expr | varvar: char | char varchar: TOKEN_A | TOKEN_B etc.
struct S { byte x; cofunc f(...) { ... } // f and g may contain yields cofunc g(...) { ... } // f and g have access to each other and x}s := S{1};s.f(...);s.g(...);
struct T { cofunc(...) { ... } } // the cofunc is an anonymous field of Tcofunc T(...) { ... } // This is a shorthand for the same thing abovet := T{};t();
cofunc T(byte x : byte) { // THIS SHORT-HAND FORM... for(byte last = 0; true; last += x) { yield last; }}struct T { // ...REALLY MEANS THIS cofunc(byte x : byte) { for(byte last = 0; true; last += x) { yield last; } }}t := T{}; // make a T variablet(1); // 0+1 = 1t(2); // 1+2 = 3
struct Foo { byte x; cofunc f(byte y) { ... } cofunc g(char c) { ... } } f := Foo{1}; // x f.f(2); // y f.g('H'); // c
struct S { func fp(byte); // function-pointer func mp(this, byte); // method-pointer (caller is passed to "this" automatically) cofunc cf(byte x) { ... } // member cofunc ("this" is implied) // NOTE: cf is NOT directly modifiable (it changes after each 'yield')}func f(*S, byte x) { ... } // non-member functionfunc S.m(byte x) { ... } // non-member method s := S{f,m}; // cf is not in the list (not a pointer)// To show that they are all of type func(*S,byte):s.fp = s.mp = f; // all point to fs.fp = s.mp = S.m; // all point to S.ms.fp = s.mp = s.cf; // ... (Yes, even the cofunc!)// To show how call syntax differs:s.fp(s,5); // pass an *S directly (does not have to be s!)s.mp(5); // s is automatically as "this"s.cf(5); // s is automatically passed as "this"
cofunc CF(byte x) { ... } // cannot access y in therestruct S { byte y; CF cf; }s := S{5,CF{}};s.cf(5);ptr := s.cf; // ptr is a func(*CF, byte), rather than a func(*S,byte)