Here's a link to the code on GitHub: https://github.com/reedoolang/reedoo
Hi,
I've been working on my own programming language, as a hobby for the past couple of months now. It's called Reedoo, it is implemented pure C++ 11, it uses only the libraries that come with C++, no external ones. I've never studied Computer Science, I've done about 2 weeks of software development so far in school, but that's it.
Since I've never studied Computer Science, I've never taken a compiler class, so I'd like some feedback to know whether I'm using techniques that will result in a "useable" language.
Currently the language is really, really small. It has a "print" statement, variables, expression evaluation, comments and "if" statements.
Here's a simple program demonstrating all of the features so far.
if "Hello World" == "Hello World" and "Reedoo" == "reedoo" {
print "This part of the block shouldn't run"
} else {
print "This should be displayed in the console."
print 10 + 2 * (5 + 4) # Example of expression evaluation and a comment
}
How it works, currently:
Reedoo has a hand-written lexical scanner that scans and input .rdo file and identifies the tokens. Here's the tokens from that program above:
if
cond:string:"Hello World" eqeq string:"Hello World" and string:"Reedoo" eqeq string:"reedoo"
opencb
print
string:"This part of the block shouldn't run"
sc
closecb
else
cond:string:"Hello World" eqeq string:"Hello World" and string:"Reedoo" eqeq string:"reedoo"
opencb
print
string:"This should be displayed in the console."
sc
print
expr:(10+2*(5+4))
sc
closecb
sc
Each token is on it's own line. The "sc" token stands for semi-colon, the lexer injects semi-colons in place of new lines. When the lexer finds a condition, like in an if statement, it adds the parts of the condition together until it finds the open curly bracket token.
The parser The parser then takes the tokens and one-by-one adds them together until it matches one of the patterns in the parser. The parser is also hand written.
The parser makes calls to other functions I wrote also, for example, when evaluating an expression, the parser calls a function I wrote that returns the result of the expression.
When evaluating conditions the parser executes another function that returns either true or false.
Variables Variables are stored in a C++ map.
I also make extensive use of vectors in all aspects of the lexer / parser and related functions, is this bad for performance?
Finally, the parser just executes code as it see's it, I don't know enough about to tree's to implement one.
So I'd just like some feedback on my project, I'd like to know am I going about things the right way? And also if possible a rating out of 10 would be nice. I don't mind low ratings, but ratings are an easy way to tell whether I'm close to a good implementation or miles away from one.