• Advertisement

Archived

This topic is now archived and is closed to further replies.

Visual Studio Style App

This topic is 6449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m attempting to write my own "IDE" for a script converter I''m writing. Currently, I have a program that reads in text files and converts them correctly. However, I sometimes have problems with syntax because (even though I came up with the syntax) I sometimes forget how exactly the syntax works :-) So, I want to make a program that will analyse my code line by line and change it to different colors and styles depending on the contents of the line and the validity. Is there a way to do this in VB. Simply changing the style and color of the text area changes the color and style for the entire set of text. Please let me know. Thanks! :-) -=xelius=-

Share this post


Link to post
Share on other sites
Advertisement
It depends on the complexity of the grammar or your scripting language.

If the grammar is simple, you can do it by brute force and just look for the keywords in the file, then highlight them.

If you came up with the syntax yourself, then you are probably writing the script interpreter as well. Use the parser code from your script interpreter to parse the script when it is in your IDE''s script editor. Then color the text according to the parse tree. (Of couse this is easier said than done. ...and you want to do this in VB?)

I assume, since you are using VB, you are not using UNIX or Linux and you have never heard of YACC and LEX.
If you are designing your own language and an interpreter for it in VB, look for a product called Visual Parse++ and download the 30 day demo. I think it''s from a company called Sandstone software at www.sandstone.com

I used VP++ for a semester project in compiler design class.
VP++ can generate all the parser code you need in VB, C++, Delphi, Java, ... (though if you don''t know what a Context Free Grammar is, you may have trouble using it).

CFGs are nice because you can make really fast parsers for them. Note that VC++ and VB IDEs color the code really fast. If you open a really big C++ source file and immediatly scroll to the bottom you will notice that the code is not colored yet. Similarly, Microsoft Word takes time to red-underline your spelling mistakes and green-underline your poor grammer. An example of a slow parser comes with a product called MATLAB. Using the MATLAB script editor, you can watch the code get colored even in the smallest files.

Share this post


Link to post
Share on other sites
Thanks for the info, I''d been looking for a parser to use w/ VB as well. BTW, I found a website about the product, it''s at:
http://www.sand-stone.com/prod02.htm

(after ending up at famology.com or something, I dug around)

-Ascent

Share this post


Link to post
Share on other sites
So you are making an IDE in VB. Hmmmm. How are you displaying the text? Are you using an Edit Box or a Rich-Text Edit Box? or are you making your own edit window from scratch?

Now that you can parse your script, how are you going to tell it to color?

What other games come with a custom IDE for script editing? ...or don''t they just count on Notepad.exe to do the job?

But wait, there''s more! If you do have a very simple grammar that does nothing more but make calls into your object model, and if you don''t want do the work to make a parser, you don''t need a parser. Try using a hash table. That is Hash your function calls (even arithmetic and logic operations can be scripted and mapped to function calls).

Then your grammar will become all post fix expressions, kind of like assembly language, and your script interpreter will work like an assembler (using a hash table). This is a simpler design, easier to code and may execute faster too.

If your grammar is like dirty java script, then you definitly need a parser, but if your grammar is like the original BASIC, a subset of BASIC or simplified BASIC, such that it uses a reduced grammar set, you may not need a parser, you just need to determine postfix expressions from infix expressions before you look them up in the hash table and symbol table. (Kind of an improved assembler.)

Share this post


Link to post
Share on other sites
Well, I discovered the magic or Rich Text Boxes. So, I was able to figure it out. I will take a look at the other stuff though, and see how it is. Setting the color and such is fairly easy because of the RichTextBox.SelColor, SelBold, SelItalic, SelFont, etc. variables. It''s fairly easy actually, it''s just that I didn''t know about Rich Text Boxes because they don''t show up on my component list automatically.... :-)

As for the complexity of the statements, they''re usually pretty simple. It''s just that I forget the syntax sometimes when I''m writing it and I either usually refer back to my own documentation, or if it''s a new feature I end up running the script and having the program report an error if the script is wrong. The script is eventually "compiled" into a set of codes that the program understands. It''s just that sometimes the compiler doesn''t pick up errors because the code given is similar to correct code and because of the way the compiler works, it still goes through. (Don''t worry, this isn''t a professional compiler I''m writing ;-)) Then when I try to reverse the contents of the compile, I get strange code back. So, in order to reduce the time it takes me to debug my scripts, I wanted something that verifies my syntax while I''m typing the script. That''s it, and hopefully I''ll be able to figure out the rest. I will check out that other stuff though, it sounds cool. Thanks! :-)




-=xelius=-

Share this post


Link to post
Share on other sites
On a certain project, a class mate and I were always complaining to each other about the C++ compiler errors we would get. Instead of just spitting out errors, we wanted a compiler that would compliment us on good programming style, and great algorithm design!

A few times I wrote some programs so that function calls would return a status code.
    
enum ERRCODE
{
E_OK = 1,
E_ERROR = 0,
E_NULLPOINTER = -1
E_BADLOGIC = -2,
E_YOUSUCK = -3,
E_NICECODE = 2,
E_GREATJOB = 3
};


Then I thought, maybe Microsoft could take the red and green wavy underlines from MS Word, and put them in the VB and VC++ code editors so that the auto-parsing-code-colorizing-workspace-auto-intelli-typing-blowjob9000 could also point out good and bad programming before I even compiled and profiled it.

Nah, maybe not.

Share this post


Link to post
Share on other sites
That''s expecting a little much from Microsoft isn''t it?

-=xelius=-

Share this post


Link to post
Share on other sites
You''re working alone to make a script interpreter in Visual Basic and you''re asking if it''s a little much for a gagle of programmers at Microsoft to take features from one product and put them in another? For 5 bucks I''ll sell you some K-mart brand crack rocks

Share this post


Link to post
Share on other sites
Maybe I should have noted that I was being sarcastic :-)
Of course it would be nice for Microsoft to do anything extra nice for us consumers...but I don''t see it happening.

-=xelius=-

Share this post


Link to post
Share on other sites
Alot of little "easter Egg" style stuff does get coded into microsoft apps. It''s just that alot of little things get shot down by "higher ups" beacuse they want the product to be "professional", even though the people using the programs are programmers as well who would get a kick out of such stuff..

now, about those crack rocks....

-Zims

Share this post


Link to post
Share on other sites
yeah, forget Vis. Studio style apps :-D
what up ''bout those rocks hehe

-=xelius=-

Share this post


Link to post
Share on other sites

  • Advertisement