Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Algebraic Parser

Reply
Thread Tools

Algebraic Parser

 
 
DennisNedry
Guest
Posts: n/a
 
      02-02-2005
Any general ideas on techniques for creating parsers for algebraic and
linear equations?

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      02-02-2005
DennisNedry wrote:
> Any general ideas on techniques for creating parsers for algebraic and
> linear equations?


Yes. Create them. Any particular C++ language questions?
 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      02-02-2005
"DennisNedry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form


 
Reply With Quote
 
DennisNedry
Guest
Posts: n/a
 
      02-02-2005
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[i]!=NULL;i++){
if(user_input[i]==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++.

 
Reply With Quote
 
Jeff Flinn
Guest
Posts: n/a
 
      02-02-2005
Ivan Vecerina wrote:
> "DennisNedry" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> 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)


Which has examples of doing exactly what you're asking for.

Jeff


 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      02-02-2005
DennisNedry wrote:
> 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[i]!=NULL;i++){
> if(user_input[i]==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
 
Reply With Quote
 
DennisNedry
Guest
Posts: n/a
 
      02-02-2005
Okay, thanks. I'll check that out.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
algebraic expression 'a*b+c' with CIN .Is it possible? Cristian C++ 9 08-23-2007 05:27 PM
simplifying algebraic expressions DavidM Python 6 06-30-2007 10:10 AM
Is x.f() <==>MyClass.f(x) a kind of algebraic structure? steve Python 3 10-23-2006 12:03 PM
Re: expressing a certain algebraic statement in C++ STL Michel Rosien C++ 0 04-22-2004 01:11 PM
Re: expressing a certain algebraic statement in C++ STL Mike Wahler C++ 1 04-01-2004 02:40 PM



Advertisments