Scripting Language Genesis

Started by
116 comments, last by cmp 19 years, 5 months ago
How about the syntax:

Double Var1

Fucntion Oneach_Var1

end function

??

Well, maybe forevers arn't that usefull... but there are a few good uses for them:
For egsample, dofunction(y,z), to cause the function to be called continuously...

I would preferr tabs, to the +'s and -'s.

I don't use c++ often. when i do, its usually for something small, so oop isn't used.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Advertisement
Quote:How about the syntax:

Double Var1

Fucntion Oneach_Var1

end function


That is similar to what I was thinking, the name of the method has to have some relevance to the name of the variable.

Quote:I would preferr tabs, to the +'s and -'s.

There needs to be a way to differentiate between the two types of methods. Maybe the class declaration has different sections. Something like this as an example:
class base_class    // constant (guesses that it is a decimal - type is optional)    deltatime = 0.001        // methods here default to object methods    void start()        owner members        void get_number()                integer number_instanced        object members        integer do_calculation()                decimal delta_time        // get and set methods - only get called if they exist        // the compiler basically translates references to the        // property into method calls        decimal get_delta_time()        void set_delta_time()                // constant (although they can be anywhere, they are        // associated with the owner object only, but can be        used without dot notation in methods of this class)        use_timestep = true


Quote:I don't use c++ often. when i do, its usually for something small, so oop isn't used.

I must say that oop in C++ isn''t very nice. It's like they took C and tacked on oop, wait - that is what they did :P.
hi, i got a design problem.
i want my classes to have overloadable comparision operators, but then the following comparision is ambiguous obj == obj, since you don't know if you just compare the addresses or use the class' == operator.
but you need something like a address comparision operator, since you'll sometimes have to do sth. like this:
if( obj == 0 ) { }
so what would you do, just forget about the overloadable comparision operator, just introduce another operator or do sth. completly different.
Quote:Original post by cmp
hi, i got a design problem.


Other people have had the same problem.

One solution is to introduce a new operator, (eg "===") which does the actual memory comparison. Also using this way, just "=" and "==" could be used, but variable assignment can't be used in a conditional.

I'm not sure if I want variable assignment in conditionals in voodoo. On the other hand, I think I will keep the "==" operator because it is commonly used.

Another way is just to use object.equals(o) as the value comparison, and "==" for the actual object. But "==" will still act as the value comparison for native types (integer, double, boolean). This solution is a bit annoying because the definition of the operator "==" will be different depending on the type.

Basically you need two different operations, one that compares the actual object, and another that does the value comparison. Overloadable comparison is good, because the actual comparison is sometimes different for each class.

[Edited by - umbrae on November 11, 2004 2:03:14 AM]
Quote:Original post by Nice Coder
It doesn't get deleated... sorry (stack, its pointer gets popped out of existance). It doesn't get de-allocated by the garbage collector. So you end up with a memory leak.


I had a look at this and found that a class created by the code:
classname variablename

In C++ gets it's constructor and destructor called - it is not popped out of existance.

I ran the following code and got the output
constructordestructor

#include <iostream>using namespace std;class base{public:        base()    {        cout << "constructor\n";    }        ~base()    {        cout << "destructor\n";    }};int main (int argc, const char * argv[]){    base b;            return 0;}


This type of behaviour probably won't be available in voodoo, every variable will be an object pointer.
@the operator problem, i just came up with the idea of introducing a new address type and an operator wich returns the address of an object with this type.
Good solution.


I haven't done much work on voodoo over the last week, and Halo 2 came out a few days ago (and I have completed it three times since then). From Saturday I will get back into it.

Not sure whether to use flex and bison again to write the new parser, or to just use flex, or use none of those tools. If I don't use flex there is no real problem, I don't really need it's regex powers. But if I don't use bison then I have to build some sort of parse tree by hand.

What do you think about parsing straight to an xml tree? For me this sounds like a really good technique, transformations will be easy.
i think the idea is great :D
but the real problem is the first compilation pass, where you need to transform your sourcfile into a xml tree. and this is quite easy with yacc/bison
Quote:Original post by cmp
i think the idea is great :D

I might do just that then. All that the tree needs as values are strings (or char*'s) and xml does that fine. Also it is cool that xml has attributes - the properties of a class (parent, name etc) won't have to be child containers.

Quote:but the real problem is the first compilation pass, where you need to transform your sourcfile into a xml tree. and this is quite easy with yacc/bison

If I write my own lexer that has predictive tokening (the parser says now I am looking for one of these tokens) the lexer will be able to say "Error - looking for (list of tokens) found (token) at line ##" instead of the parser having to just say parse error. Also yacc/bison is not very good at relative tokens, ie you can say that this section of code has 3 tabs in front of it, but you can't say that I want 1 more tab than the last section of code.

While it would be possible to make yacc/bison and lex/flex parse a tab blocked language (that voodoo will be), it would require a bit of mucking around on the lexer level, and this seems too much work when I could just write my own lexer and parser. But on the other hand having a bnf that gets converted to a parser is really cool, and you know that it will only accept your language.

Maybe I should make the parser using a state machine, and run it off a bnf. But that sounds like too much work to me.
Quote:Original post by umbrae
the properties of a class (parent, name etc) won't have to be child containers.

i think if you would have multiple parents, you would have to use sub children, as ever attribute may only occur once, at least as far as i know.
Quote:
Maybe I should make the parser using a state machine, and run it off a bnf. But that sounds like too much work to me.

i also thought about this, at least it would sound very cool to be independtent from external tools.
but the first thing is, that i will write my own xml like langauge, since it is really a pain to write everthing in xml and i only use a small subset of xml (tags, attribute).
i thout something like this:
tag [tab] [child1] [attribute]:"[value]" [tab]  [tab] [child of child1] [attribute1]:"[value1]" [attribute2]:"[value2]" [tab] [tab] : [text, child of child1] [tab] ![comment, child of tag]

i tried to write a simple converter yesterday, but had some bug, but it should just be 100 lines of code and would save from a lot of writing.

This topic is closed to new replies.

Advertisement