Algebraic Parser

D

DennisNedry

Any general ideas on techniques for creating parsers for algebraic and
linear equations?
 
V

Victor Bazarov

DennisNedry said:
Any general ideas on techniques for creating parsers for algebraic and
linear equations?

Yes. Create them. Any particular C++ language questions?
 
I

Ivan Vecerina

DennisNedry said:
Any general ideas on techniques for creating parsers for algebraic and
linear equations?

Some C++ (or C) tools that can help generate parsers include:
- Flex http://www.gnu.org/software/flex/
A good old proven solution for generating parsing code/tables.
- Boost::spirit http://www.boost.org/libs/spirit/
A template based solution (no separate code generation)
- ANTLR http://www.antlr.org/
Also a popular generator (for C++ & more), but I never used it.
Of course, hand-coding is possible as well, all depends on
the complexity of what you are trying to do.

hth -Ivan
 
D

DennisNedry

Okay. Is there a more efficient way to parse this data (in C++) than
doing character comparisons on the entire user input such as:

for(char='A';char<='Z';char++){
for(i=0;user_input!=NULL;i++){
if(user_input==char){

and then dumping the matches into a variable in a structure?
Sorry if this is a dumb question, I'm relatively new to C++.
 
V

Victor Bazarov

DennisNedry said:
Okay. Is there a more efficient way to parse this data (in C++) than
doing character comparisons on the entire user input such as:

for(char='A';char<='Z';char++){
for(i=0;user_input!=NULL;i++){
if(user_input==char){

and then dumping the matches into a variable in a structure?
Sorry if this is a dumb question, I'm relatively new to C++.


What books are you reading? If you are interested in expression
parsing, chapter 6 of "The C++ Programming Language" by Stroustrup
has a good example of that.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top