If i use python to get the tokens then what i am to do next is build finite state automata model for my language, and just do things like this:
if (token1 == if && token2 == "(" && token3==ID) do this
or
switch(token1){
case: "if"
do this
case:reserved word
do this
case:number
do this
I mean now i can skip the lex and yacc stuff right? Because python can tokenize for me.
Wait, "if" isn't a valid token in your language.
I really think you are trying to get into code way too fast. I know you want to do code, but you are likely to make a TON of errors that you will have to go back and rework.
You don't understand.
I am going to use if and switch and string processing in python.
So the user writes a text file, and my python program translates it into assembler code. And from then the assembler executes. That is my compiler project.
oops, double post...
Given that 1) I don't know python, and 2) that I don't know HLA.
Can you provide an example of what the source might look like and what the "compiled" to HLA code should look like?
well you can check out the syntax on wikipedia or google
By the way why did you put compile in quotes? Would not that be a compiler? I mean, a c++ compiler for example first compiles to c and then c to assembler and only then to machine code.
Here's my issue: I can't imagine anything meaningful that you could compile "32.4+57.3" into.
Oh i see.
Well I am really on new ground here so, I am starting very slow. So this will be like an excercise for assembler arithmetics operations and translating high level into low.
Eventually i will get to construct variables, the iterator and recursion constructs, and some data structures.
But slowly, right now i have two tasks to do:
1. Try and see what you can do with lex and yacc
2. Once you get the hang of it, start writing a compiler that will translate a source file in your language into assembler.
What i have concluded from reading so far, is that i will have to use lex and yacc, otherwise it would be much complicated. So i hope to start sending some code these days. Thank you and cya soon for more
So i don't create new threads here i will send my questions related to this project.
1. The character handler is the section that communicates with the outside world, through the
operating system, to read in the characters that make up the source text. As character sets and file
handling vary from system to system, this phase is often machine or operating system dependent.
What would be the difference here between Linux and Windows for example?
The biggest difference between Windows and Linux is whether a "newline" is #10#13 or just #13.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks