Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 5th, 2004, 3:56 PM   #1
ra21vi
Newbie
 
Join Date: Oct 2004
Posts: 2
Rep Power: 0 ra21vi is on a distinguished road
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
ra21vi is offline   Reply With Quote
Old Oct 8th, 2004, 8:04 PM   #2
ghostils
Newbie
 
Join Date: Oct 2004
Posts: 5
Rep Power: 0 ghostils is on a distinguished road
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]
ghostils is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC