|
-
Mar 15th, 2008, 01:58 PM
#1
Thread Starter
New Member
Lexical? Simple Compiler for my Project
can anyone help me with my School project..since
My Teacher told me to make a simple basic compiler that has lexical analysis features
so it means onc you type an expression on a textbox..and verify that line
it will separate Identifier,operator,assignment operator and number
so lets say you type sum=a+b
then on the ListBox it will show
sum is an identifier
= is an Assignment Operator
a is an identifier
+ is an Operator
b is an identifier
just like that and if i inputted sum = 1 + 2 then it will show
sum is an identifier
= is an Assignment Operator
1 is a number
+ is an Operator
2 is a number
after that on the second listbox it will show
Sum = 3 (since 1+2 is inputted on the textbox)
I hope someone could help me and provide the easiest code as possible
-
Mar 16th, 2008, 01:14 PM
#2
Re: Lexical? Simple Compiler for my Project
You won't get code for an entire school project, that's frowned upon here since you're supposed to be learning, not copy-pasting.
For your purposes, I suggest you look at regular expressions. You should be able to write a regular expression that is able to identify that 'sum' is an identifier, 1 is a number, '+' is an operator, and so on in your given statement.
-
Mar 24th, 2008, 03:10 AM
#3
Re: Lexical? Simple Compiler for my Project
Some suggestions to help you get started with your project.
1) Mark the topics/keywords that was discussed in your class. This probably means tokens, words, language, input string, etc. (Sorry I forgot my Compiler class, should be in your book or whatever references you have).
2) Make a state diagram (automata) for your language and for each state create a function or object if you like. I'm assuming this is function you can make several functions and have a main switch for it.
3) Tie them up together (The transitions should be right, make your automata your guide on the flow of your program). Focus first on the logic, try to divide tasks as much as you can. In fact if you have the tasks listed you can get suggestions on what to do next, but it's better if you already have the logic for the program already.
4) If you encounter problems with the actual c0ding then buzz us. Make sure you have the c0d in hand though, because if you don't have the c0d then there is nothing for us to help you fix with.
-
Mar 24th, 2008, 11:15 AM
#4
Re: Lexical? Simple Compiler for my Project
What language are you using, and what have you got so far?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|