making a compiler

Started by
27 comments, last by jumpjumpjump 20 years, 1 month ago
I am working on making my own scripting language thing and I want to know if there is any way to write a compiler for it in VB.NET, is there and what are some good resources on making compilers? I have a few bookmarks on flipcode. i also have some C++ knowledge, if that helps. Boo!! I know all.
Advertisement
I want to do as much as i can in basic instead of an assembly language.
Depending on how complex your scripting language is you may want to start out by mapping it out in EBNF. Then simply work out the EBNF in VB.

For example (not sure about the syntax):
digit := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';// A Digit is either a 0, 1, 2, ... 8, or 9 number := digit[digit];// A Number is one or more digitsexpression := number '+' expression | number '-' expression;


This maps out a syntax for adding or subtracting 2 or more numbers

"2+34-2" or "5-2+44-342+1" are both valid strings

this would be implemented by doing creating a couple of functions :
IsDigit(), IsNumber(), and IsExpression()
Which would determine if the input string follows the EBNF guidelines.

Hope this helps.


[edited by - enfekted on January 23, 2004 8:20:34 PM]
Writing compilers may not be a very suitable task for a beginner (as I will assume you are, posting in the For Beginners forum ...); it''s a large and complicated topic. In any case, the Dragon Book is the canonical book on the subject. Some people have also spoken favourably about Programming Language Processors in Java, which my university''s compiler course uses as a textbook (though as it turned out, the professor got most of his examples from the Dragon Book).
Game Scripting Mastery teaches you how to make your own scripting
language from start to finish.

It comes with a complete system called XtremeScript.



Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
What is the best assembly language to use if i decided to try that?
Why would you need assembly?

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:Original post by jumpjumpjump
What is the best assembly language to use if i decided to try that?


The assembly language that your processor uses is not only best, but the only one that would work. Chances are thats x86, which would be Intel-like processors (Intel, AMD, etc.). For the sake of correctness, not all Intel processors are x86 but chances are you don't have one that isn't.

Edit: If you are a beginner, which as mentioned seems to be the case because of your posting in the For Beginners forum, a scripting language may not be a good project for you and assembly language may be a problem for you, too.

[edited by - Aerolithe on January 25, 2004 2:23:35 AM]
By assembly language, do you mean a virtual machine which processes a list of opcodes and data?

Yo ucan write your own, incidentally i found this part relatively simple. The harder bit will be writing the lexical/syntax analyser

If your app cranks out assembly language, it''s not a scripting language.

.bas

[sPiKie] mmorpg isnt hard in vb
.basprintf ( "And for the %dth time, I'm not American!", ++lIdiots );My homepage

This topic is closed to new replies.

Advertisement