Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
Post by Nick on Apr 17, 2011 4:58:33 GMT
That would be cool! How big is your library? The command library? At the moment its pretty damn small, just the bare basics for a simple console app. Have you barrowed any parts from other codes or is it custom?
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 17, 2011 9:38:30 GMT
Post by xcessive on Apr 17, 2011 9:38:30 GMT
The command library? At the moment its pretty damn small, just the bare basics for a simple console app. Have you barrowed any parts from other codes or is it custom? *faceplam*
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 17, 2011 18:58:29 GMT
Post by Jordan on Apr 17, 2011 18:58:29 GMT
I just discovered a really odd bug. IF statements don't work in WHILE loops. :S I might have to release a version of the interpreter for people to play with and find more of these bugs. I'd take a look at it if you did. I'm actually curious about how to go about implementing an interpreter, so I wrote one which parses variables. I was going to do more, but it takes too much time. I'm now curious about how you are parsing all the code since it can get tough. Are you using a stack to store content in so you know what must come next and when you are finished you pop it off? For example, if you hit an if statement, do you push an "if statement" onto the stack, and then if you hit another one, you push that one on as well so the program then knows to only deal with whats on top of the stack? Also, when are you parsing and when are you executing code? Do you execute as you parse, or do you parse everything and then execute the code that you interpreted? This is my really crappy 30 minute interpreter which only parses variables at the moment - I might add a basic if statement later. It also depends on the fact that everything is spaced out with whitespace, I didn't feel like writing code that parsed it character by character. (Also note that the program is set up to support more than just variables otherwise the program would be a few lines long). It parses the text below in a file called source.txt int variableName = 3 int asdf = 34343 double aDouble = 23.5 ... double oneThousand = 1000 #include <iostream> #include <fstream> #include <string> #include <map> #include <stack> #include <vector> #include <stdlib.h>
using namespace std;
// What the text reprecents enum KEYS { /* Anything to do with variables */ DATA_TYPE = 0, VARIABLE_NAME, VARIABLE_VALUE, VARIABLE_ASSIGNMENT,
/* If statements, for loop, while loop */ STATEMENT,
/* Syntactical snuff */ OPEN_PARENTHESIS, CLOSE_PARENTHESIS, OPEN_BRACKET, CLOSE_BRACKET,
/* If we can't yet determine what the text reprecents */ UNKNOWN };
// The supported statments enum STATEMENTS { IF = 0, FOR, WHILE };
// The supported data types enum DATATYPES { INTEGER = 0, DOUBLE };
class BaseVariable { public: string name; // int, double BaseVariable(string name) { this->name = name; } virtual void print() = 0; };
class IntegerVariable : public BaseVariable { public: int value; IntegerVariable(string name, int value) : BaseVariable(name) { this->value = value; } virtual void print() { cout << name << ": " << value << endl; } };
class DoubleVariable : public BaseVariable { public: double value; DoubleVariable(string name, double value) : BaseVariable(name) { this->value = value; } virtual void print() { cout << name << ": " << value << endl; } };
int main() { map<string,int> key; map<string,int>::iterator keyIter; key["int"] = DATA_TYPE; key["double"] = DATA_TYPE; key["="] = VARIABLE_ASSIGNMENT;
key["if"] = STATEMENT; key["for"] = STATEMENT; key["while"] = STATEMENT;
key["("] = OPEN_PARENTHESIS; key[")"] = CLOSE_PARENTHESIS; key["{"] = OPEN_BRACKET; key["}"] = CLOSE_BRACKET;
map<string,int> dataType; map<string,int>::iterator dataTypeIter; dataType["int"] = INTEGER; dataType["double"] = DOUBLE;
map<string,int> statement; map<string,int>::iterator statementIter; statement["if"] = IF; statement["for"] = FOR; statement["while"] = WHILE;
map<string,BaseVariable*> variable; map<string,BaseVariable*>::iterator variableIter;
stack<int,vector<int> > runTimeStack;
fstream inFile("source.txt", ios::in); string command = "";
if(!inFile) return 1;
while(inFile >> command) { int whatWeMustReadNext = -1;
// Get what the text should be so we can give an error if its not if(runTimeStack.size() > 0) whatWeMustReadNext = runTimeStack.top();
// See if can determine what the text reprecents keyIter = key.find(command.c_str());
if(keyIter != key.end()) { int type = keyIter->second;
if(whatWeMustReadNext != -1 && whatWeMustReadNext != type) { cout << "error, was expecting whatWeMustReadNext key" << endl; return 2; }
switch(type) { case DATA_TYPE: { dataTypeIter = dataType.find(keyIter->first);
if(dataTypeIter != dataType.end()) { runTimeStack.push(VARIABLE_NAME); // variable name must come next } else { cout << "Error: Unrecognized data type" << endl; return 3; }
break; } case VARIABLE_ASSIGNMENT: { runTimeStack.pop(); runTimeStack.push(VARIABLE_VALUE); break; } default: { cout << "Error..." << endl; } } } // This is a programmer defined text, like a variable name or value else { if(whatWeMustReadNext != -1) { switch(whatWeMustReadNext) { case VARIABLE_NAME: { pair<map<string,BaseVariable*>::iterator,bool> returnValue;
if(dataTypeIter->second == INTEGER) returnValue = variable.insert(pair<string,BaseVariable*>(command, new IntegerVariable(command, 0))); else if(dataTypeIter->second == DOUBLE) returnValue = variable.insert(pair<string,BaseVariable*>(command, new DoubleVariable(command, 0)));
if(returnValue.first == variable.end()) { cout << "Did not insert variable."; return 53; } else { //cout << returnValue.first->first << endl; variableIter = returnValue.first; } runTimeStack.pop(); runTimeStack.push(VARIABLE_ASSIGNMENT); break; } case VARIABLE_ASSIGNMENT: { runTimeStack.pop(); runTimeStack.push(VARIABLE_VALUE); break; } case VARIABLE_VALUE: { if(dataTypeIter->second == INTEGER) static_cast<IntegerVariable*>(variableIter->second)->value = atoi(command.c_str()); else if(dataTypeIter->second == DOUBLE) static_cast<DoubleVariable*>(variableIter->second)->value = atof(command.c_str());
runTimeStack.pop(); break; } default: { cout << "Error: Wasn't expecting this..." << endl; return 4; } } } else { cout << "Error: whatWeMustReadNext was invalid" << endl; return 5; } } }
for(map<string,BaseVariable*>::iterator i = variable.begin(); i != variable.end(); i++) { i->second->print(); }
inFile.close();
return 0; }
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 18, 2011 0:12:14 GMT
Post by xcessive on Apr 18, 2011 0:12:14 GMT
I just discovered a really odd bug. IF statements don't work in WHILE loops. :S I might have to release a version of the interpreter for people to play with and find more of these bugs. I'd take a look at it if you did. I'm actually curious about how to go about implementing an interpreter, so I wrote one which parses variables. I was going to do more, but it takes too much time. I'm now curious about how you are parsing all the code since it can get tough. Are you using a stack to store content in so you know what must come next and when you are finished you pop it off? For example, if you hit an if statement, do you push an "if statement" onto the stack, and then if you hit another one, you push that one on as well so the program then knows to only deal with whats on top of the stack? Also, when are you parsing and when are you executing code? Do you execute as you parse, or do you parse everything and then execute the code that you interpreted? This is my really crappy 30 minute interpreter which only parses variables at the moment - I might add a basic if statement later. It also depends on the fact that everything is spaced out with whitespace, I didn't feel like writing code that parsed it character by character. (Also note that the program is set up to support more than just variables otherwise the program would be a few lines long). It parses the text below in a file called source.txt int variableName = 3 int asdf = 34343 double aDouble = 23.5 ... double oneThousand = 1000 #include <iostream> #include <fstream> #include <string> #include <map> #include <stack> #include <vector> #include <stdlib.h>
using namespace std;
// What the text reprecents enum KEYS { /* Anything to do with variables */ DATA_TYPE = 0, VARIABLE_NAME, VARIABLE_VALUE, VARIABLE_ASSIGNMENT,
/* If statements, for loop, while loop */ STATEMENT,
/* Syntactical snuff */ OPEN_PARENTHESIS, CLOSE_PARENTHESIS, OPEN_BRACKET, CLOSE_BRACKET,
/* If we can't yet determine what the text reprecents */ UNKNOWN };
// The supported statments enum STATEMENTS { IF = 0, FOR, WHILE };
// The supported data types enum DATATYPES { INTEGER = 0, DOUBLE };
class BaseVariable { public: string name; // int, double BaseVariable(string name) { this->name = name; } virtual void print() = 0; };
class IntegerVariable : public BaseVariable { public: int value; IntegerVariable(string name, int value) : BaseVariable(name) { this->value = value; } virtual void print() { cout << name << ": " << value << endl; } };
class DoubleVariable : public BaseVariable { public: double value; DoubleVariable(string name, double value) : BaseVariable(name) { this->value = value; } virtual void print() { cout << name << ": " << value << endl; } };
int main() { map<string,int> key; map<string,int>::iterator keyIter; key["int"] = DATA_TYPE; key["double"] = DATA_TYPE; key["="] = VARIABLE_ASSIGNMENT;
key["if"] = STATEMENT; key["for"] = STATEMENT; key["while"] = STATEMENT;
key["("] = OPEN_PARENTHESIS; key[")"] = CLOSE_PARENTHESIS; key["{"] = OPEN_BRACKET; key["}"] = CLOSE_BRACKET;
map<string,int> dataType; map<string,int>::iterator dataTypeIter; dataType["int"] = INTEGER; dataType["double"] = DOUBLE;
map<string,int> statement; map<string,int>::iterator statementIter; statement["if"] = IF; statement["for"] = FOR; statement["while"] = WHILE;
map<string,BaseVariable*> variable; map<string,BaseVariable*>::iterator variableIter;
stack<int,vector<int> > runTimeStack;
fstream inFile("source.txt", ios::in); string command = "";
if(!inFile) return 1;
while(inFile >> command) { int whatWeMustReadNext = -1;
// Get what the text should be so we can give an error if its not if(runTimeStack.size() > 0) whatWeMustReadNext = runTimeStack.top();
// See if can determine what the text reprecents keyIter = key.find(command.c_str());
if(keyIter != key.end()) { int type = keyIter->second;
if(whatWeMustReadNext != -1 && whatWeMustReadNext != type) { cout << "error, was expecting whatWeMustReadNext key" << endl; return 2; }
switch(type) { case DATA_TYPE: { dataTypeIter = dataType.find(keyIter->first);
if(dataTypeIter != dataType.end()) { runTimeStack.push(VARIABLE_NAME); // variable name must come next } else { cout << "Error: Unrecognized data type" << endl; return 3; }
break; } case VARIABLE_ASSIGNMENT: { runTimeStack.pop(); runTimeStack.push(VARIABLE_VALUE); break; } default: { cout << "Error..." << endl; } } } // This is a programmer defined text, like a variable name or value else { if(whatWeMustReadNext != -1) { switch(whatWeMustReadNext) { case VARIABLE_NAME: { pair<map<string,BaseVariable*>::iterator,bool> returnValue;
if(dataTypeIter->second == INTEGER) returnValue = variable.insert(pair<string,BaseVariable*>(command, new IntegerVariable(command, 0))); else if(dataTypeIter->second == DOUBLE) returnValue = variable.insert(pair<string,BaseVariable*>(command, new DoubleVariable(command, 0)));
if(returnValue.first == variable.end()) { cout << "Did not insert variable."; return 53; } else { //cout << returnValue.first->first << endl; variableIter = returnValue.first; } runTimeStack.pop(); runTimeStack.push(VARIABLE_ASSIGNMENT); break; } case VARIABLE_ASSIGNMENT: { runTimeStack.pop(); runTimeStack.push(VARIABLE_VALUE); break; } case VARIABLE_VALUE: { if(dataTypeIter->second == INTEGER) static_cast<IntegerVariable*>(variableIter->second)->value = atoi(command.c_str()); else if(dataTypeIter->second == DOUBLE) static_cast<DoubleVariable*>(variableIter->second)->value = atof(command.c_str());
runTimeStack.pop(); break; } default: { cout << "Error: Wasn't expecting this..." << endl; return 4; } } } else { cout << "Error: whatWeMustReadNext was invalid" << endl; return 5; } } }
for(map<string,BaseVariable*>::iterator i = variable.begin(); i != variable.end(); i++) { i->second->print(); }
inFile.close();
return 0; }Mine parses and interprets on the fly, I was originally going to use a double linked list, but now I basically just store an index to the line number in the source file and treat the source file like an array of commands. Variables were the easy part for me, I actually did them very similar to the way you did. Here have a look at the Blitzmax code: Function setInteger(tokens:String[]) If Not(tokens.length = 3) 'if there arent exactly 3 parameters its not a valid call error("Wrong number of parameters") EndIf Local id:String = tokens[1] id = id.Replace("v","") 'get rid of the v in vVARIABLEID Local expr:String = tokens[2].Replace("[","") expr = expr.Replace("]","") expr =expr.Trim() ' need to find the reference to the right integer. so we search through the var list and find the right indentifier Local i:Variable = variables[id.toInt()] If i.varType = 1 'check id the identifier is right, and its an int Integer(i).value = Int(parseExpression(expr)) Return 'function is finished EndIf 'if were here the function didnt find the variable error("Identifier not found") Return EndFunction
Function declareInteger(tokens:String[]) If Not(tokens.length = 3) 'if there arent exactly 3 parameters its not a valid call error("Wrong number of parameters") EndIf Local id:String = tokens[1] id = id.Replace("v","") 'get rid of the v in vVARIABLEID Local expr:String = tokens[2].Replace("[","") expr = expr.Replace("]","") expr = expr.Trim() If expr = "" 'cant have an empty expression expr = "0" EndIf ' need to check if it already exists If Not variables[id.toInt()] = Null error("Variable already delcared") EndIf Local temp:Integer = New Integer 'create a new int object, it automatically gets added to the var list 'set up its parameters temp.identifier = tokens[1] temp.value = Int(parseExpression(expr)) variables[id.toInt()] = temp 'put in var list EndFunction
'This file contains the variable types
'The base class from which all variables are extended, includes generic functionality Type Variable Field varType:Int 'stores the var type, 1=int, 2=float, 3 =string, 4 = bool Field identifier:String 'the name of the variable Global varList:TList = New TList Method getType:Int() Return Self.varType EndMethod EndType
Type Integer Extends Variable
'The value of this variable object Field value:Int 'constructor Method New() varType = 1 varList.addLast(Self) EndMethod 'Converts this object to a StringVar, and retruns the StringVar Method convertToString:StringVar() Local temp:StringVar= New StringVar temp.value = String.FromInt(Self.value) Return temp EndMethod EndType
Type FloatingPoint Extends Variable 'The value of this variable object Field value:Float 'constructor Method New() varType = 2 varList.addLast(Self) EndMethod 'Converts this object to a StringVar, and retruns the StringVar Method convertToString:StringVar() Local temp:StringVar= New StringVar temp.value = String.FromFloat(Self.value) Return temp EndMethod EndType
Type StringVar Extends Variable 'The value of this variable object Field value:String 'constructor Method New() varType = 3 varList.addLast(Self) EndMethod 'converts the object into an Integer and returns that int Method convertToInt:Integer() Local temp:Integer = New Integer temp.value = Int(Self.value) Return temp EndMethod 'converts the object into a Float and returns that Float Method convertToFloat:FloatingPoint() Local temp:FloatingPoint = New FloatingPoint temp.value = Float(Self.value) Return temp EndMethod EndType
Type Boolean Extends Variable 'The value of this variable object Field value:Short 'constructor Method New() varType = 4 varList.addLast(Self) EndMethod EndType
The worst part by far was the While loop. That took a long time to get right, and to be honest it still isnt right. Also I am thinking of building a parsed "command tree", apparently thats the normal way of doing things.
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 18, 2011 7:14:28 GMT
Post by Jordan on Apr 18, 2011 7:14:28 GMT
Mine parses and interprets on the fly, I was originally going to use a double linked list, but now I basically just store an index to the line number in the source file and treat the source file like an array of commands. Ah, that makes sense. That should work well although I would think it would be slow since you have to parse the line every time. Of course, the other alternative would be translating it into machine code your own type of code which would most likely take a lot more time to implement. Variables were the easy part for me, I actually did them very similar to the way you did. Here have a look at the Blitzmax code: Function setInteger(tokens:String[]) If Not(tokens.length = 3) 'if there arent exactly 3 parameters its not a valid call error("Wrong number of parameters") EndIf Local id:String = tokens[1] id = id.Replace("v","") 'get rid of the v in vVARIABLEID Local expr:String = tokens[2].Replace("[","") expr = expr.Replace("]","") expr =expr.Trim() ' need to find the reference to the right integer. so we search through the var list and find the right indentifier Local i:Variable = variables[id.toInt()] If i.varType = 1 'check id the identifier is right, and its an int Integer(i).value = Int(parseExpression(expr)) Return 'function is finished EndIf 'if were here the function didnt find the variable error("Identifier not found") Return EndFunction
Function declareInteger(tokens:String[]) If Not(tokens.length = 3) 'if there arent exactly 3 parameters its not a valid call error("Wrong number of parameters") EndIf Local id:String = tokens[1] id = id.Replace("v","") 'get rid of the v in vVARIABLEID Local expr:String = tokens[2].Replace("[","") expr = expr.Replace("]","") expr = expr.Trim() If expr = "" 'cant have an empty expression expr = "0" EndIf ' need to check if it already exists If Not variables[id.toInt()] = Null error("Variable already delcared") EndIf Local temp:Integer = New Integer 'create a new int object, it automatically gets added to the var list 'set up its parameters temp.identifier = tokens[1] temp.value = Int(parseExpression(expr)) variables[id.toInt()] = temp 'put in var list EndFunction
'This file contains the variable types
'The base class from which all variables are extended, includes generic functionality Type Variable Field varType:Int 'stores the var type, 1=int, 2=float, 3 =string, 4 = bool Field identifier:String 'the name of the variable Global varList:TList = New TList Method getType:Int() Return Self.varType EndMethod EndType
Type Integer Extends Variable
'The value of this variable object Field value:Int 'constructor Method New() varType = 1 varList.addLast(Self) EndMethod 'Converts this object to a StringVar, and retruns the StringVar Method convertToString:StringVar() Local temp:StringVar= New StringVar temp.value = String.FromInt(Self.value) Return temp EndMethod EndType
Type FloatingPoint Extends Variable 'The value of this variable object Field value:Float 'constructor Method New() varType = 2 varList.addLast(Self) EndMethod 'Converts this object to a StringVar, and retruns the StringVar Method convertToString:StringVar() Local temp:StringVar= New StringVar temp.value = String.FromFloat(Self.value) Return temp EndMethod EndType
Type StringVar Extends Variable 'The value of this variable object Field value:String 'constructor Method New() varType = 3 varList.addLast(Self) EndMethod 'converts the object into an Integer and returns that int Method convertToInt:Integer() Local temp:Integer = New Integer temp.value = Int(Self.value) Return temp EndMethod 'converts the object into a Float and returns that Float Method convertToFloat:FloatingPoint() Local temp:FloatingPoint = New FloatingPoint temp.value = Float(Self.value) Return temp EndMethod EndType
Type Boolean Extends Variable 'The value of this variable object Field value:Short 'constructor Method New() varType = 4 varList.addLast(Self) EndMethod EndType
Heh, I did do things similar to your way for the variables. Looking at your code has given me a few good ideas, but I don't plan on going any further (at least for now since I have three projects for school ;P). I'd need to think of a good design before going any further. By the way, is Blitzmax compiled to native code, byte code, or is it interpreted? I'm just curious because if it's interpreted that's pretty funny. ;P Why don't you use C instead? You'll get the best speed with that language. The worst part by far was the While loop. That took a long time to get right, and to be honest it still isnt right. Also I am thinking of building a parsed "command tree", apparently thats the normal way of doing things. Yeah, I bet a lot of that stuff is tricky. It would be fun to try and implement it, though. I've heard of a command tree somewhere (I think from one of my professors), but I've haven't used one before. If it's the standard way for doing things then my guess is it would make things much easier for you in the long run.
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 18, 2011 10:33:31 GMT
Post by xcessive on Apr 18, 2011 10:33:31 GMT
An interpreted language inside an interpreted language? Yo dawg we put interpreters in your interpreters so you can code while you code!
I use Blitzmax because it gets compiled as C. Its just has a prettier syntax and a LOT of useless command libraries built in. If you look at the speed of compiled code its almost as fast as straight up C, the different is probably the GC. Put simply Blitzmax is a language, not a compiler. It just uses a preprocessor to convert it too C and gcc to compile itself. So yeh, its pretty fast, as really easy to use because I can compile to any platform without worrying about little things (BMX abstracts all that stuff away).
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 18, 2011 19:10:10 GMT
Post by Jordan on Apr 18, 2011 19:10:10 GMT
Haha. ;P
And damn, I honestly didn't even know that there were high level languages that were translated to other high level languages to be compiled. That's brilliant!
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 18, 2011 23:44:14 GMT
Post by xcessive on Apr 18, 2011 23:44:14 GMT
Haha. ;P And damn, I honestly didn't even know that there were languages that were translated to other languages to be compiled. That's brilliant! There are a few languages that get converted to other languages to be compiled. Java, Haskell, Ocaml, PHP (with Zend engine), C (Assembly -> Machine), off the top of my head. I guess its a matter of using someone elses compiler, when its really optimized haha.
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 19, 2011 0:12:54 GMT
Post by Jordan on Apr 19, 2011 0:12:54 GMT
Haha. ;P And damn, I honestly didn't even know that there were languages that were translated to other languages to be compiled. That's brilliant! There are a few languages that get converted to other languages to be compiled. Java, Haskell, Ocaml, PHP (with Zend engine), C (Assembly -> Machine), off the top of my head. I guess its a matter of using someone elses compiler, when its really optimized haha. I'm referring to one high level language getting translated into another high level language to be compiled. Java gets compiled to byte code (similar to C#) which is executed in a virtual machine, it's not translated into a form of code you'd normally write yourself. Php is interpreted by C/C++ if I remember correctly, and I know C is translated into assembly (like C++) which can be directly translated into binary since all the assembly commands reprecent binary commands that the processor can execute. I took a whole class on assembly and I'm glad it's over. ;P
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 19, 2011 2:44:33 GMT
Post by xcessive on Apr 19, 2011 2:44:33 GMT
There are a few languages that get converted to other languages to be compiled. Java, Haskell, Ocaml, PHP (with Zend engine), C (Assembly -> Machine), off the top of my head. I guess its a matter of using someone elses compiler, when its really optimized haha. I'm referring to one high level language getting translated into another high level language to be compiled. Java gets compiled to byte code (similar to C#) which is executed in a virtual machine, it's not translated into a form of code you'd normally write yourself. Php is interpreted by C/C++ if I remember correctly, and I know C is translated into assembly (like C++) which can be directly translated into binary since all the assembly commands reprecent binary commands that the processor can execute. I took a whole class on assembly and I'm glad it's over. ;P Ah well, high level to high level is a rarity indeed. I didn't think thats what you meant. I think only Blitzmax and the "compiled" versions of Python and PHP do that.
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 19, 2011 4:31:58 GMT
Post by Jordan on Apr 19, 2011 4:31:58 GMT
It's a neat idea, though, because like you said above, you can use a highly optimized compiler like C's so you know you are going to get good speed as well as platform independence.
And I just realized that "represent" is a censored word on here because it gets replaced with "reprecent"...I modified my post above to fix it thinking it was a typo but was also wondering how the hell I made that typo.
|
|
Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
Post by Nick on Apr 23, 2011 2:49:47 GMT
How did you learn to do this? Any books or web articles you'd recommend?
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 23, 2011 3:46:02 GMT
Post by xcessive on Apr 23, 2011 3:46:02 GMT
How did you learn to do this? Any books or web articles you'd recommend? By being super cool. I didn't learn to do this, this is me experimenting, this is HOW I learn. There are a lot of good books on compilers and interpreters though, just search for it on amazon, I've seen heaps round.
|
|
Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
Post by Nick on Apr 23, 2011 12:47:34 GMT
How did you learn to do this? Any books or web articles you'd recommend? By being super cool. I didn't learn to do this, this is me experimenting, this is HOW I learn. There are a lot of good books on compilers and interpreters though, just search for it on amazon, I've seen heaps round. So I got one step down! Wooo! And yeah. Thats a good way to learn. I cant just learn stuff by reading. Are you developing this on Windows?
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
xBasic
Apr 24, 2011 1:00:17 GMT
Post by xcessive on Apr 24, 2011 1:00:17 GMT
I am developing it on all platforms. I compiled it on mac and linux a few weeks ago and it worked fine. I don't use any non-generic modules. I am doing most of the source code work in Windows, but ironically it runs faster on Mac :S
|
|
Jordan
Elite Poster
[M:5000]
Posts: 286
|
xBasic
Apr 24, 2011 5:18:34 GMT
Post by Jordan on Apr 24, 2011 5:18:34 GMT
Nick, I suggest you learn a programming language first, and I mean really learn the language. Php does not count as a programming language by the way. Also, learn about data structures such as stacks, heaps, binary search trees, queue's etc. Get a good foundation of knowledge before attempting a project such as this.
$0.02
|
|
Nick
VIP
v5 Beta Tester[M:5000]
Philadelphia Eagles: 8-8
Posts: 2,239
|
xBasic
Apr 24, 2011 6:03:50 GMT
Post by Nick on Apr 24, 2011 6:03:50 GMT
Nick, I suggest you learn a programming language first, and I mean really learn the language. Php does not count as a programming language by the way. Also, learn about data structures such as stacks, heaps, binary search trees, queue's etc. Get a good foundation of knowledge before attempting a project such as this. $0.02 Yeah, I've actually been working on Java for 2-3 weeks now because as you said, PHP isn't really an actual program language And I've also been reading up on the workings of computers. Circuitry and stuff. I don't know if you have played the game Minecraft, but it allows you to set up circuits and I've build some simple binary calculators. I recently built a 4 bit calculator that could add and subtract. And I will probably not attempt this project, in the near future at least I'm just very curious and like to know/figure out how things work. Thanks for the advice, and the two cents! Even though USD is way down, so I'd be lucky to have a penny.
|
|