Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scripting Language project...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
15 replies to this topic

#1 Mike   Members   -  Reputation: 140

Posted 26 February 2000 - 04:26 PM

For an independant study in high school I am developing a scripting language. I don''t really know what I''m doing; just kinda figuring it out as I go. The goal of the language is for it to be easily implemented it various projects. I''m not very far along, but eh... If you want to look at the code yourself to get ideas or to tell me what I''m doing wrong go here: mike010.hypermart.net Let me know what you think about the web page to. Once you see the page you will see the humor in the previous sentence.

Sponsor:

#2 joew   Crossbones+   -  Reputation: 3679

Posted 27 February 2000 - 05:36 AM

Mike, check out http://root.cern.ch/root/Cint.html because you''ll need something like this.

#3 Mike   Members   -  Reputation: 140

Posted 27 February 2000 - 03:00 PM

I''m not sure what you mean by "you''ll need something like this."

I''m guessing that you mean it would be a good example to look at. Thanks for the link, and if you have some spare time do me a favor and take a look at my code (actually you would need alot of spare time concidering my project has surpased the 1500 lines of code mark) and let me know what you think.

#4 SiCrane   Moderators   -  Reputation: 9670

Posted 27 February 2000 - 03:17 PM

Haven''t read too much of the source, but my first question has got to be, why is the opcode function called "Exicute"? Otherwise I can''t say much, as it seems like the project is still in its infancy.

#5 Brad8383   Members   -  Reputation: 122

Posted 27 February 2000 - 03:24 PM

Theres a whole series of articles on scripting languages at flipcode

#6 Mike   Members   -  Reputation: 140

Posted 27 February 2000 - 03:44 PM

SiCrane-

The Exictute function actually does something. Each OpCode class holds the actually C++ code that the virtual machine actually runs in its exicute funtion. As the virtual machine goes through the script''s op codes it calls the op code''s exicute function to actually do something. If you know of a better way to do it please share it with me. I''m new to the this game and open to suggestions.

Brad-

I read the articles at flipcode quite a while ago (before I actully had any desire to write a scirpting language). The problem I have with that series is that the author uses lex and yakk (or was it flex and bison... or flex and yakk...) to generate the lexer and parser. I plan to write my own. However, i think that i am using some of the ideas that the author presented. To be honest I''ve read alot about scripting languages, but what i read is always implemented useing a lexer and parser generator or its implemented in a C style (not C++). I''ve pretty much decided to go my own way (don''t get me wrong, I will still listen to advice). I''m just trying to make sure I don''t completely screw things up.

#7 SiCrane   Moderators   -  Reputation: 9670

Posted 27 February 2000 - 03:51 PM

You misunderstand me, I understand what the function does, I''m wonder why it''s called "Exicute". Rather than, for example, "Execute."

Traditionally, though, the execution of opcodes has been a property of the VM rather than the opcodes. This is, more or less, a necessity when the code is compiled to true byte-codes. However, again, I stress I''ve only given your project a cursory look, and can''t make any judgements yet.

#8 Mike   Members   -  Reputation: 140

Posted 28 February 2000 - 08:08 AM

Oh... that''s any easy one; I can''t spell. It''s kinda funny that I would messup that one considering that you run a ".exe".

#9 Lance   Members   -  Reputation: 122

Posted 29 February 2000 - 09:40 AM

No offense bud but I seriously doubt you can write a non-ambiguous parser without the help (and ease of use) of Flex and Bison. Don't get cocky. Until you have read and understood the Dragon Book (Aho) and you understand LR(1) and LALR(1) parsers writing your own C-syle recursive descent parser is ludicrous. Flex and Bison are extremely easy and powerful tools. Hell, even GNU g++ uses them for its C++ grammar parser.

There is no one on this planet that can write a scripting parser in C or C++ faster than I can write the parser/lexer in Flex/Bison, eat a Pizza, shoot some pool, and take a nap. It just isn't possible; the larger the grammar gets the more you will thank yourself you spent the time reading Levine's book on Flex and Bison.


Edited by - Lance on 2/29/00 3:41:49 PM

#10 SiCrane   Moderators   -  Reputation: 9670

Posted 29 February 2000 - 10:03 AM

Um, Lance, did you see his instruction set? For a project on this scale it''s pretty easy to handcode an RDP for the grammar. Even without lex and yacc (or flex and bison) you can use other similar tools, such as Johnston''s RDP generator or JavaCC. So you don''t need to preach flex/bison like it was gospel.

#11 Mike   Members   -  Reputation: 140

Posted 29 February 2000 - 01:42 PM

Lance:

I''m not ignorant (I just can''t spell) nor am I cocky. I know my place at the bottom of the programming chain. You don''t seem to realize that this is a simple language that I am creating for an aditional credit in HIGH SCHOOL. I''ve completed the code to handle input, output, and ifs from the syntax tree to compilation. This means that I have roughly 10 weeks to write a simple parser.

I know that parsers and lexers are insane tasks to take on and if I were to write a very complex (or even somewhat complex) language I would use flexx and bison (or flexx++ and bison++... but I''ve heard that those aren''t to good); however, as SiCrane pointed out, I''m not about to write the language to replace Python.

Please realize that I am doing this to further my programming abilities. Generating code with lexx and yak is not exactly going to enrich my programming abilities (in perticualar: problem solveing). Even if I fail at writing the parser I will still get the additional credit and I will still learn something.

#12 joew   Crossbones+   -  Reputation: 3679

Posted 29 February 2000 - 09:04 PM

I totally agree with Mike on this one.

#13 Squidi   Members   -  Reputation: 122

Posted 01 March 2000 - 03:59 PM

Check into Forth. It is an extremely simple language which runs on a word-based system. Even things like math are in reverse notation, so instead of having to parse x = 3 + 4, you get 3 4 + x ! (the ! sets the variable x to the top integer on the stack). It has polymorphic variables of global scope only. It requires that you become very familiar with the whole "stack" thing, but you can only become better because of it. I believe MUCKs are programmed with a Forth derivative.

I wrote a Forth interpreter as a Freshmen in College, and I don''t think the thing was more than 700 lines. Geez, that wasn''t that long ago, yet I am so much better at programming. Maybe for kicks, I''ll rewrite it or something...maybe make it OOP. That''d be worth a giggle or two...

#14 Cygon   Crossbones+   -  Reputation: 1156

Posted 15 March 2000 - 03:44 PM

I've also tried to write a scripting language parsing C++ scripts and compiling them into bytecode in singlepass (don't laugh!). The bytecode was risc-like and it mainly used registers (rather than being a stack machine).

Well, a huge bunch of unexpected problems arised, so I stopped and decided to use something like GENTLE or PCCTS, because bison/flexx doesn't seem like it's learnable in a week or so

Anyway, what I've completed yet could easily transformed into a good, solid tokenizer (preprocessor), so if someone likes to take a look at:
http://www.lunaticsystems.de/scrix.zip

-Markus-

Edited by - Cygon on 3/15/00 9:46:09 PM

#15 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Posted 19 March 2000 - 02:56 PM

I don''t really know why I''m writing this here, just thought I''d share my experience.

I tried to construct my own scripting language for a game project I''m working on (using flex and bison). I had attained the level of functionality that C provides and I wanted to give it the ability to define and use user-defined objects. That''s where the brick wall approached. As a 2nd-year programmer, I hardly knew enough to handle objects, and I certainly didn''t understand the recursive nature of the parser. So I gave up. But now that I look back, I think it''s actually quite good. I even figured out how to export C functions on my own (Mike - I posted the solution I used in another post somewhere) and get the byte code to execute quite nicely on the virtual machine. It even did a two-level compile, making virtual assembly first and then converting to bytecode.
Anyway, I wish you the best of luck Mike and hope you get the language working.

#16 Mike   Members   -  Reputation: 140

Posted 19 March 2000 - 03:04 PM

I''ve figured out how to export native functions to the scripting language on my own (I asked how to do it, but I didn''t really like the way that other people did it so I went my own way). I have no plans to implement objects or user defined data types. I only need to add functions to the scripting language (it will not take long to acomplish based on the fact that I''ve already implemented a label and a jump virtual machine op code) and I will be almost done. I only need to write a lexer and a parset (unlike the functions, this will take for ever to get done).

Just incase you wondered.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS