17 #ifndef AWALI_STTC_LR_PARSE_NUMBER_HH 
   18 #define AWALI_STTC_LR_PARSE_NUMBER_HH 
   24 #include<awali/common/qfraction.cc> 
   56     for (
unsigned x = 0; (
c = t[x]) != 
'\0'; x++)
 
   77                bool allow_empty = 
false, 
char value_if_empty = 
'\0')
 
   82       return value_if_empty;
 
   88       s2 = 
".."+s.substr(p-4,4);
 
   92                           + 
"\", i.e., starting from the right of \"" + s2
 
  108     while (i>0 && std::isdigit(
static_cast<unsigned char>(s[i-1])))
 
  110     unsigned res = (p-i);
 
  132                 unsigned value_if_empty = 0)
 
  136       std::stringstream ss (s.substr(i,p-i));
 
  143       return value_if_empty;
 
  148       s2 = 
".."+s.substr(p-4,4);
 
  149     throw parse_exception(
"Could not parse an unsigned integer right of position " 
  151                           + 
"\", i.e., starting from the right of \"" + s2
 
  165                 char value_if_empty=
'\0')
 
  167     return lr_parse_one(s,p, 
"+-", allow_empty, value_if_empty);
 
  179   lr_parse_e(std::string 
const& s, 
size_t& p, 
bool allow_empty=
true, 
 
  180                char value_if_empty=
'\0') 
 
  182     return lr_parse_one(s,p,
"eE", allow_empty, value_if_empty);
 
  194   char value_if_empty=
'\0') {
 
  195     return lr_parse_one(s,p,
".", allow_empty, value_if_empty);
 
  240                int value_if_empty = 0)
 
  244       std::stringstream ss (s.substr(i,p-i));
 
  251       return value_if_empty;
 
  256       s2 = 
".."+s.substr(p-4,4);
 
  259                           + 
"\", i.e., starting from the right of \"" + s2
 
  280     if (right_digits || 
dot || left_digits) {
 
  297       if (s[p] == 
'+' || s[p] == 
'-')
 
  369         den = pow(10,p-(pp+1));
 
  380       return value_if_empty;
 
  385       s2 = 
".."+s.substr(p-4,4);
 
  386     throw parse_exception(
"Could not parse a q fraction right of position" 
  388     "\", i.e., starting from the right of \"" + s2 + 
"\".");
 
  410                   double value_if_empty = 0)
 
  414       std::stringstream ss (s.substr(i,p-i));
 
  421       return value_if_empty;
 
  427       s2 = 
".."+s.substr(p-4,4);
 
  428     throw parse_exception(
"Could not parse a floating point number right of" 
  430                           + s + 
"\", i.e., starting from the right of \"" + s2
 
  459                   std::complex<double> value_if_empty = {0,0})
 
  466       for (
int x = 0; (x<2 && j>i) ; x++) {
 
  481       return value_if_empty;
 
  487       s2 = 
".."+s.substr(p-4,4);
 
  488     throw parse_exception(
"Could not parse a complex number right of position " 
  490                           + 
"\", i.e., starting from the right of \"" + s2
 
Definition: qfraction.hh:26
 
int num_t
Definition: qfraction.hh:28
 
unsigned int den_t
Definition: qfraction.hh:29
 
The semiring of complex numbers.
Definition: c.hh:44
 
unsigned lr_scan_double(std::string const &s, size_t &pp)
Definition: lr_parse_number.hh:265
 
unsigned lr_scan_digits(std::string const &s, size_t &p)
Scans for as many [0-9] digits as possible, left of position p in string s.
Definition: lr_parse_number.hh:105
 
unsigned lr_scan_int(std::string const &s, size_t &p)
Definition: lr_parse_number.hh:215
 
double lr_parse_double(std::string const &s, size_t &p, bool allow_empty=false, double value_if_empty=0)
Reads a double left of position p in string, by using as many characters as possible.
Definition: lr_parse_number.hh:409
 
int lr_parse_int(std::string const &s, size_t &p, bool allow_empty=false, int value_if_empty=0)
Reads an int written in decimal left of position p in string s, by using as many characters as possib...
Definition: lr_parse_number.hh:239
 
char lr_parse_e(std::string const &s, size_t &p, bool allow_empty=true, char value_if_empty='\0')
Parses the radix point.
Definition: lr_parse_number.hh:179
 
q_fraction_t lr_parse_qfraction(std::string const &s, size_t &p, bool allow_empty=false, q_fraction_t value_if_empty={1, 1})
Reads a q_fraction_t left of position p in string, by using as many characters as possible.
Definition: lr_parse_number.hh:353
 
unsigned lr_scan_sign(std::string const &s, size_t &p)
Definition: lr_parse_number.hh:158
 
unsigned lr_scan_one(std::string const &s, size_t &p, char const *t)
Scans for a character in t left of position p in s.
Definition: lr_parse_number.hh:51
 
unsigned lr_scan_complex(std::string const &s, size_t &pp)
Definition: lr_parse_number.hh:291
 
char lr_parse_dot(std::string const &s, size_t &p, bool allow_empty=true, char value_if_empty='\0')
Definition: lr_parse_number.hh:193
 
unsigned lr_parse_uint(std::string const &s, size_t &p, bool allow_empty=false, unsigned value_if_empty=0)
Reads an unsigned int written in decimal left of position p in string s, by using as many character a...
Definition: lr_parse_number.hh:131
 
unsigned lr_scan_dot(std::string const &s, size_t &p)
Definition: lr_parse_number.hh:187
 
char lr_parse_sign(std::string const &s, size_t &p, bool allow_empty=true, char value_if_empty='\0')
Definition: lr_parse_number.hh:164
 
std::complex< double > lr_parse_complex(std::string const &s, size_t &p, bool allow_empty=false, std::complex< double > value_if_empty={0, 0})
Reads a complex number left of position p in string, by using as many characters as possible.
Definition: lr_parse_number.hh:458
 
unsigned lr_scan_e(std::string const &s, size_t &p)
Definition: lr_parse_number.hh:172
 
char lr_parse_one(std::string const &s, size_t &p, char const *t, bool allow_empty=false, char value_if_empty='\0')
Checks whether there is in t left of position p in s.
Definition: lr_parse_number.hh:76
 
static unsigned powten(unsigned i)
Definition: lr_parse_number.hh:321
 
std::string to_string(identities i)
 
std::ostream & dot(const Aut &aut, std::ostream &out, bool dot2tex=false, bool keep_history=true, bool horizontal=true)
Definition: dot.hh:270
 
Main namespace of Awali.
Definition: ato.hh:22
 
Exceptions thrown during parsing.
Definition: parse_exception.hh:26