#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 |
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.
1.2.18