![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2004
Posts: 2
Rep Power: 0
![]() |
hi,
I am doing a college project i just initiated to help students. Actually I want to write Grapher, a program w hich takes mathematical expression, polynomial, trigonometric, complex and real, and then plots its graph on screen, 640x480. I need help to write down the parser and lexical analyser for the input provided by the user: y=sin(x)+tan(x)+3*x; x:10->20 states that find the values and graph for the expression with value ranging from 10 to 20 for x; In the program, i m only struck into writing efficient parser and lex. analy. What i m implementing right now is: Program Grammer: STATEMENT operator STATEMENT exp operator STATEMENT STATEMENT operator exp STATEMENT = exp operator exp And I m using a lot of tree and stack implementation. Real clumsy, that the program shows many errors and consumes time running simple sin[x]+x You can please help me giving any ideas, as i m really newbie in parsing and and writing parsers and lexical analyser. If possible, please include program source code as well. My email address(if you would like to send me the mail, ra21vi@rediffmail.com |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Oct 2004
Posts: 5
Rep Power: 0
![]() |
Do you know Perl? Because if you do, embedding perl in a C/C++ program is trivial. You could prolly whip up a simple parser that tokenizes the strings into a much more C/C++ friendly data structure, and you could write the lexer natively.
Either that or it will be time for you to sit down with LEX/YACC and configure those tools to generate the C code for your Parser/Lexer portions of code. I would not recomend writing the parser and tokenizer code in C by hand, its a headache, and very involved for even the simplest of grammers. Personally I would go the perl route since I'm familiar with that language. But if you have to learn either or both, lex/yacc is probably the better solution to your problem, as those tools are specifically designed to make parsers/lexers and used to build compilers. -ghost[iLs] |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|