Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

file_parser.hpp File Reference

This file contains the basic file parser used to extract the information regarding the equations from the input file. It contains a basic lexical analyser and parser clubbed into one. More...

#include <map>
#include <vector>
#include <fstream>
#include <stdexcept>
#include <string>
#include <cctype>
#include <sstream>
#include "udefs.hpp"

Go to the source code of this file.

Namespaces

namespace  eqn_cruncher


Detailed Description

This file contains the basic file parser used to extract the information regarding the equations from the input file. It contains a basic lexical analyser and parser clubbed into one.

The input file will be something like this:

1. It contains an integer as the first data member in the file.
2. It contains 'n' number of equations. Each having a syntax described by the productions given below.

Productions for the Context Free Language describing the syntax of the linear equations.

EQN -> LHS = RHS
DOUBLE ->(0..9)* | (0..9)*.(0..9)(0..9)*
RHS -> (+ | - | e)DOUBLE
LHS -> LHS(+ | -)TERM | TERM
TERM -> (+ | - | e)DOUBLE_VAR
VAR -> (a..z)(a..z)*

This CFL is coded below using istreams, and traditional parsing methods.

NOTE: There can be any number of spaces between the +/- signs and the TERMs which are appearing before/after the sign. However, if the sign is associated with a particular DOUBLE, then there should not be any spaces between the sogn and the DOUBLE. For example:
23x + 54y + -65z = 33 <- VALID
23x + 54y + - 65z = 33 <- INVALID

There can also be any number of spaces between the 2 terms on either side of the = sign, or any spaces after the RHS. Also, ther may be any number of empty lines between 2 successibe equations.


Generated on Mon Oct 11 13:09:26 2004 for Equation Cruncher by doxygen1.2.18