www.cemf.ir
Istream.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #include "Istream.hpp"
21 #include "token.hpp"
22 #include "error.hpp"
23 
24 
25 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
26 
27 // Truncate error message for readability
28 static constexpr const unsigned errLen = 80;
29 
30 
31 namespace
32 {
33 
34 // Convert a single character to a word with length 1
35 inline static pFlow::word charToWord(char c)
36 {
37  return pFlow::word(std::string(1, c), false);
38 }
39 
40 // Permit slash-scoping of entries
41 static inline bool validVariableChar(char c)
42 {
43  return (pFlow::validWord(c) || c == '/');
44 }
45 
46 } // End anonymous namespace
47 
48 
50 {
51  char c = 0;
52 
53  while (true)
54  {
55  // Get next non-whitespace character
56  while (get(c) && isspace(c))
57  {}
58 
59  // Return if stream is bad - ie, previous get() failed
60  if (bad() || isspace(c))
61  {
62  return 0;
63  }
64 
65  // Is this the start of a C/C++ comment?
66  if (c == '/')
67  {
68  if (!get(c))
69  {
70  // Cannot get another character - return this one
71  return '/';
72  }
73 
74  if (c == '/')
75  {
76  // C++ style single-line comment - skip through past end-of-line
77  while (get(c) && c != '\n')
78  {}
79  }
80  else if (c == '*')
81  {
82  // Within a C-style comment
83  while (true)
84  {
85  // Search for end of C-style comment - '*/'
86  if (get(c) && c == '*')
87  {
88  if (get(c))
89  {
90  if (c == '/')
91  {
92  // matched '*/'
93  break;
94  }
95  else if (c == '*')
96  {
97  // check again
98  putback(c);
99  }
100  }
101  }
102 
103  if (!good())
104  {
105  return 0;
106  }
107  }
108  }
109  else
110  {
111  // The '/' did not start a C/C++ comment - return it
112  putback(c);
113  return '/';
114  }
115  }
116  else
117  {
118  // A valid character - return it
119  return c;
120  }
121  }
122 
123  return 0;
124 }
125 
126 
128 {
129  word val;
130  if (read(val).bad())
131  {
132  t.setBad();
133  }
134  else
135  {
136  t = std::move(val); // Move contents to token
137  }
138 }
139 
140 
142 {
143  constexpr const unsigned maxLen = 1024;
144  static char buf[maxLen];
145 
146  unsigned nChar = 0;
147  unsigned depth = 0; // Track depth of (..) or {..} nesting
148  char c;
149 
150  // First character must be '$'
151  if (!get(c) || c != token::DOLLAR)
152  {
153  ioErrorInFile( name(), lineNumber())
154  << "Invalid first character found : " << c << nl;
155  fatalExit;
156  }
157  buf[nChar++] = c;
158 
159  // Next character should also exist.
160  // This should never fail, since it was checked before calling.
161  if (!get(c))
162  {
163  str.assign(buf, nChar);
165  << "Truncated variable name : " << str << nl;
166 
167  return *this;
168  }
169  buf[nChar++] = c;
170 
171  str.clear();
172  if (c == token::BEGIN_BLOCK)
173  {
174  // Processing ${...} style.
175  ++depth;
176 
177  // Could check that the next char is good and not one of '{}'
178  // since this would indicate "${}", "${{..." or truncated "${"
179 
180  while (get(c))
181  {
182  buf[nChar++] = c;
183  if (nChar == maxLen)
184  {
185  str.append(buf, nChar);
186  nChar = 0;
187  }
188  if (c == token::BEGIN_BLOCK)
189  {
190  ++depth;
191  }
192  else if (c == token::END_BLOCK)
193  {
194  --depth;
195  if (!depth)
196  {
197  // Found closing '}' character
198  str.append(buf, nChar);
199  return *this;
200  }
201  }
202  }
203 
204  // Should never reach here on normal input
205 
206  str.append(buf, nChar); // Finalize pending buffer input
207 
208  nChar = str.length();
209  if (str.length() > errLen)
210  {
211  str.erase(errLen);
212  }
213 
214  ioErrorInFile(name(), lineNumber())
215  << "stream terminated while reading variable '"
216  << str.c_str() << "...' [" << static_cast<int32>(nChar) << "]\n";
217  fatalExit;
218 
219  return *this;
220  }
221  else if (validVariableChar(c))
222  {
223  // Processing $var style
224 
225  while
226  (
227  (nChar < maxLen) && get(c)
228  && (validVariableChar(c))
229  )
230  {
231  if (c == token::BEGIN_LIST)
232  {
233  ++depth;
234  }
235  else if (c == token::END_LIST)
236  {
237  if (!depth)
238  {
239  break; // Closed ')' without an opening '(' ? ... stop
240  }
241  --depth;
242  }
243 
244  buf[nChar++] = c;
245  }
246  }
247  else
248  {
249  // Invalid character. Terminate string (for message) without
250  // including the invalid character in the count.
251 
252  buf[nChar--] = '\0';
253 
255  << "Bad variable name: " << buf << nl << endl;
256  }
257 
258  if (nChar >= maxLen)
259  {
260  buf[errLen] = '\0';
261 
262  ioErrorInFile(name(), lineNumber())
263  << "variable '" << buf << "...'\n"
264  << " is too long (max. " << static_cast<int32>(maxLen) << " characters)";
265  fatalExit;
266 
267  return *this;
268  }
269 
270  buf[nChar] = '\0'; // Terminate string
271 
272  if (bad())
273  {
274  // Could probably skip this check
275  buf[errLen] = '\0';
276 
277  ioErrorInFile(name(), lineNumber())
278  << "Problem while reading variable '" << buf << "...' after "
279  << static_cast<int32>(nChar) << " characters\n";
280  fatalExit;
281 
282  ioErrorInFile(name(), lineNumber());
283 
284  return *this;
285  }
286 
287  if (depth)
288  {
290  << "Missing " << static_cast<int32>(depth)
291  << " closing ')' while parsing" << nl << nl
292  << buf << nl << endl;
293  }
294 
295  // Finalize
296  str.assign(buf, nChar);
297  putback(c);
298 
299  return *this;
300 }
301 
302 
304 (
305  std::istream& is,
306  const word& streamName,
307  writeFormat wf
308 )
309 :
310  iIstream(wf),
311  name_(streamName),
312  is_(is)
313 {
314  if (is_.good())
315  {
316  setOpened();
317  setGood();
318  }
319  else
320  {
321  setState(is_.rdstate());
322  }
323 }
324 
326 {
327  is_.get(c);
328  setState(is_.rdstate());
329 
330  if (good() && c == '\n')
331  {
332  ++lineNumber_;
333  }
334 
335  return *this;
336 }
337 
338 
340 {
341  return is_.peek();
342 }
343 
344 
345 pFlow::Istream& pFlow::Istream::getLine(std::string& str, char delim)
346 {
347  std::getline(is_, str, delim);
348  setState(is_.rdstate());
349 
350  if (delim == '\n')
351  {
352  ++lineNumber_;
353  }
354 
355  return *this;
356 }
357 
358 
359 std::streamsize pFlow::Istream::getLine(std::nullptr_t, char delim)
360 {
361  is_.ignore(std::numeric_limits<std::streamsize>::max(), delim);
362  setState(is_.rdstate());
363 
364  std::streamsize count = is_.gcount();
365 
366  if (count && delim == '\n')
367  {
368  ++lineNumber_;
369  }
370 
371  return count;
372 }
373 
374 
376 {
377  if (c == '\n')
378  {
379  --lineNumber_;
380  }
381 
382  if (!is_.putback(c))
383  {
384  setBad();
385  }
386 
387  setState(is_.rdstate());
388 
389  return *this;
390 }
391 
393 {
394  constexpr const unsigned maxLen = 128; // Max length for units/scalars
395  static char buf[maxLen];
396 
397  // Return the put back token if it exists
398  if (Istream::getBack(t))
399  {
400  return *this;
401  }
402 
403  // Assume that the streams supplied are in working order.
404  // Lines are counted by '\n'
405 
406  // Get next 'valid character': i.e. proceed through any whitespace
407  // and/or comments until a semantically valid character is found
408 
409  char c = nextValid();
410 
411  // Set the line number of this token to the current stream line number
412  t.lineNumber() = lineNumber();
413 
414  // Return on error
415  if (!c)
416  {
417  t.setBad();
418  return *this;
419  }
420 
421  // Analyse input starting with this character.
422  switch (c)
423  {
424  // Check for punctuation first - same as token::isseparator()
425 
426  case token::END_STATEMENT :
427  case token::BEGIN_LIST :
428  case token::END_LIST :
429  case token::BEGIN_SQR :
430  case token::END_SQR :
431  case token::BEGIN_BLOCK :
432  case token::END_BLOCK :
433  case token::COLON :
434  case token::COMMA :
435  case token::DIVIDE :
436  {
438  return *this;
439  }
440 
441  // String: enclosed by double quotes.
442  case token::BEGIN_STRING :
443  {
444  putback(c);
445 
446  word val;
447  if (readString(val).bad())
448  {
449  t.setBad();
450  }
451  else
452  {
453  t = std::move(val); // Move contents to token
454  }
455 
456  return *this;
457  }
458  // Dictionary variable (as rvalue)
459  case token::DOLLAR :
460  {
461  char nextC;
462  if (read(nextC).bad())
463  {
464  // Return lone '$' as word
465  t = charToWord(c);
466  }
467  else
468  {
469  // Put back both so that '$...' is included in the variable
470  putback(nextC);
471  putback(c);
472 
473  word val;
474  if (readVariable(val).bad())
475  {
476  t.setBad();
477  }
478  else
479  {
480  t = std::move(val); // Move contents to token
481  t.setType(token::tokenType::VARIABLE);
482  }
483  }
484 
485  return *this;
486  }
487 
488  // Number: integer or floating point
489  //
490  // ideally match the equivalent of this regular expression
491  //
492  // /[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)([Ee][-+]?[0-9]+)?/
493  //
494  case '-' :
495  case '.' :
496  case '0' : case '1' : case '2' : case '3' : case '4' :
497  case '5' : case '6' : case '7' : case '8' : case '9' :
498  {
499  int64 int64Val = (c != '.'); // used as bool here
500 
501  unsigned nChar = 0;
502  buf[nChar++] = c;
503 
504  // get everything that could resemble a number and let
505  // readScalar determine the validity
506  while
507  (
508  is_.get(c)
509  && (
510  isdigit(c)
511  || c == '+'
512  || c == '-'
513  || c == '.'
514  || c == 'E'
515  || c == 'e'
516  )
517  )
518  {
519  if (int64Val)
520  {
521  int64Val = isdigit(c);
522  }
523 
524  buf[nChar++] = c;
525  if (nChar == maxLen)
526  {
527  // Runaway argument - avoid buffer overflow
528  buf[maxLen-1] = '\0';
529 
530  ioErrorInFile( name(), lineNumber())
531  << "number '" << buf << "...'\n"
532  << " is too long (max. " <<
533  static_cast<int32>(maxLen) << " characters)";
534  fatalExit;
535 
536  t.setBad();
537  return *this;
538  }
539  }
540  buf[nChar] = '\0'; // Terminate string
541 
542  setState(is_.rdstate());
543  if (is_.bad())
544  {
545  t.setBad();
546  }
547  else
548  {
549  is_.putback(c);
550 
551  if (nChar == 1 && buf[0] == '-')
552  {
553  // A single '-' is punctuation
555  }
556  else if (int64Val && readInt64(buf, int64Val))
557  {
558  t = int64Val;
559  }
560  else
561  {
562  real realVal;
563 
564  if (readReal(buf, realVal))
565  {
566  // A scalar or too big to fit as a unit
567  t = realVal;
568  }
569  else
570  {
571  t.setBad();
572  }
573  }
574  }
575 
576  return *this;
577  }
578 
579  // Should be a word (which can also be a single character)
580  default:
581  {
582  putback(c);
583  readWordToken(t);
584 
585  return *this;
586  }
587  }
588 }
589 
590 
592 {
593  c = nextValid();
594  return *this;
595 }
596 
597 
599 {
600 
601  constexpr const unsigned maxLen = 1024;
602  static char buf[maxLen];
603 
604  unsigned nChar = 0;
605  unsigned depth = 0; // Track depth of (..) nesting
606  char c;
607 
608  while
609  (
610  (nChar < maxLen)
611  && get(c)
612  && validWord(c)
613  )
614  {
615  if (c == token::BEGIN_LIST)
616  {
617  ++depth;
618  }
619  else if (c == token::END_LIST)
620  {
621  if (!depth)
622  {
623  break; // Closed ')' without an opening '(' ? ... stop
624  }
625  --depth;
626  }
627 
628  buf[nChar++] = c;
629  }
630 
631  if (nChar >= maxLen)
632  {
633  buf[errLen] = '\0';
634  ioErrorInFile(name(), lineNumber())
635  << "word '" << buf << "...'\n"
636  << " is too long (max. " <<
637  static_cast<int32>(maxLen) << " characters)";
638  fatalExit;
639 
640  return *this;
641  }
642 
643  buf[nChar] = '\0'; // Terminate string
644 
645  if (bad())
646  {
647  // Could probably skip this check
648  buf[errLen] = '\0';
649 
650  ioErrorInFile(name(), lineNumber())
651  << "Problem while reading word '" << buf << "...' after "
652  << static_cast<int32>(nChar) << " characters\n";
653  fatalExit;
654 
655  return *this;
656  }
657 
658  if (nChar == 0)
659  {
660  ioErrorInFile(name(), lineNumber())
661  << "Invalid first character found : " << c;
662  fatalExit;
663  }
664  else if (depth)
665  {
667  << "Missing " << static_cast<int32>(depth)
668  << " closing ')' while parsing" << nl << nl
669  << buf << nl << endl;
670  }
671 
672  // Finalize: content already validated, assign without additional checks.
673  str.assign(buf, nChar);
674  putback(c);
675 
676  return *this;
677 }
678 
679 
681 {
682  constexpr const unsigned maxLen = 1024;
683  static char buf[maxLen];
684 
685  char c;
686 
687  if (!get(c))
688  {
689  ioErrorInFile(name(), lineNumber())
690  << "cannot read start of string";
691  fatalExit;
692 
693  return *this;
694  }
695 
696  // Note, we could also handle single-quoted strings here (if desired)
697  if (c != token::BEGIN_STRING)
698  {
699  ioErrorInFile(name(), lineNumber())
700  << "Incorrect start of string character found : " << c;
701  fatalExit;
702 
703  return *this;
704  }
705 
706  unsigned nChar = 0;
707  bool escaped = false;
708 
709  while
710  (
711  (nChar < maxLen)
712  && get(c)
713  )
714  {
715  if (c == token::END_STRING)
716  {
717  if (escaped)
718  {
719  escaped = false;
720  --nChar; // Overwrite backslash
721  }
722  else
723  {
724  // Done reading
725  str.assign(buf, nChar);
726  return *this;
727  }
728  }
729  else if (c == token::NL)
730  {
731  if (escaped)
732  {
733  escaped = false;
734  --nChar; // Overwrite backslash
735  }
736  else
737  {
738  buf[errLen] = buf[nChar] = '\0';
739 
740  ioErrorInFile(name(), lineNumber())
741  << "found '\\n' while reading string \""
742  << buf << "...\"";
743  fatalExit;
744 
745  return *this;
746  }
747  }
748  else if (c == '\\')
749  {
750  escaped = !escaped; // toggle state (retains backslashes)
751  }
752  else
753  {
754  escaped = false;
755  }
756 
757  buf[nChar++] = c;
758  }
759 
760  if (nChar >= maxLen)
761  {
762  buf[errLen] = '\0';
763 
764  ioErrorInFile(name(), lineNumber())
765  << "string \"" << buf << "...\"\n"
766  << " is too long (max. " << static_cast<int32>(maxLen) << " characters)";
767  fatalExit;
768 
769  return *this;
770  }
771 
772  // Don't worry about a dangling backslash if string terminated prematurely
773  buf[errLen] = buf[nChar] = '\0';
774 
775  ioErrorInFile(name(), lineNumber())
776  << "Problem while reading string \"" << buf << "...\"";
777  fatalExit;
778 
779  return *this;
780 }
781 
783 {
784  is_ >> val;
785  setState(is_.rdstate());
786  return *this;
787 }
788 
790 {
791  is_ >> val;
792  setState(is_.rdstate());
793  return *this;
794 }
795 
796 
798 {
799  is_ >> val;
800  setState(is_.rdstate());
801  return *this;
802 }
803 
805 {
806  is_ >> val;
807  setState(is_.rdstate());
808  return *this;
809 }
810 
812 {
813  is_ >> val;
814  setState(is_.rdstate());
815  return *this;
816 }
817 
819 {
820  is_ >> val;
821  setState(is_.rdstate());
822  return *this;
823 }
824 
826 {
827  is_ >> val;
828  setState(is_.rdstate());
829  return *this;
830 }
831 
832 
834 {
835  is_ >> val;
836  setState(is_.rdstate());
837  return *this;
838 }
839 
841 (
842  char* buffer,
843  std::streamsize count
844 )
845 {
846  if ( !isBinary() )
847  {
848  fatalErrorInFunction<<"stream format is not binray. Stream name is "<<
849  name()<<'\n';
850  fatalExit;
851  }
852 
853  readBegin("binaryBlock");
854  is_.read(buffer, count);
855  readEnd("binaryBlock");
856 
857  setState(is_.rdstate());
858  return *this;
859 }
860 
862 {
863  size_t pos = 0;
864  char getChar = 'a';
865  unsigned char bFlag = 255;
866  int numFound = 0;
867 
868  while( is_.good() && !is_.eof() )
869  {
870  getChar = is_.get();
871  pos++;
872 
873  if( numFound <3 &&
874  static_cast<unsigned char>(getChar) == bFlag )
875  {
876  numFound++;
877  }
878  else if(numFound == 3 && static_cast<unsigned char>(getChar) == 0 )
879  {
880  return pos;
881  }
882  else
883  {
884  numFound = 0;
885  }
886  }
887 
888  return static_cast<size_t>(-1);
889 }
890 
892 {
893  lineNumber_ = 1; // Reset line number
894 
895  stdStream().clear(); // Clear the iostate error state flags
896  setGood(); // Sync local copy of iostate
897 
898  // pubseekpos() rather than seekg() so that it works with gzstream
899  stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
900 }
901 
902 void pFlow::Istream::seek(size_t pos)
903 {
904  stdStream().clear(); // Clear the iostate error state flags
905  setGood(); // Sync local copy of iostate
906  resetPutBack();
907  // pubseekpos() rather than seekg() so that it works with gzstream
908  stdStream().rdbuf()->pubseekpos(pos, std::ios_base::in);
909 }
910 
912 {
913 
914  auto pos = static_cast<size_t>(stdStream().tellg());
915  if(stdStream().fail())
916  {
918  "Error in getting current position from stream "<<
919  this->name()<<endl;
920  fatalExit;
921  }
922  return pos;
923 }
924 
925 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
926 
927 std::ios_base::fmtflags pFlow::Istream::flags() const
928 {
929  return is_.flags();
930 }
931 
932 
933 std::ios_base::fmtflags pFlow::Istream::flags(const ios_base::fmtflags f)
934 {
935  return is_.flags(f);
936 }
937 
938 
939 // ************************************************************************* //
pFlow::token::setType
bool setType(const tokenType tokType)
Change the token type, for similar types.
Definition: tokenI.hpp:308
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::Istream::nextValid
char nextValid()
Get the next valid character.
Definition: Istream.cpp:49
pFlow::Istream::readWordToken
void readWordToken(token &t)
Read a word token.
Definition: Istream.cpp:127
errLen
static constexpr const unsigned errLen
Definition: Istream.cpp:28
pFlow::Istream::findBinaryBlockStart
size_t findBinaryBlockStart() override
It seek for a character sequence that indicates the start of a binary block char sequence is 255 255 ...
Definition: Istream.cpp:861
pFlow::Istream::tell
size_t tell() override
Return current position indicator.
Definition: Istream.cpp:911
warningInFunction
#define warningInFunction
Report a warning.
Definition: error.hpp:95
pFlow::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.hpp:83
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::Istream::Istream
Istream(std::istream &is, const word &streamName, writeFormat wf=ASCII)
Construct wrapper around std::istream, set stream status.
Definition: Istream.cpp:304
pFlow::token::END_BLOCK
@ END_BLOCK
Begin block [isseparator].
Definition: token.hpp:96
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::readReal
bool readReal(const word &w, real &val)
Convert word to real.
Definition: bTypesFunctions.cpp:343
token.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::token::NL
@ NL
Tab [isspace].
Definition: token.hpp:88
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::validWord
bool validWord(char c)
Is the character valid for a word name?
Definition: bTypesFunctions.cpp:211
Istream.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::token::BEGIN_BLOCK
@ BEGIN_BLOCK
End dimensions [isseparator].
Definition: token.hpp:95
pFlow::readInt64
bool readInt64(const word &w, int64 &val)
Convert word to int64.
Definition: bTypesFunctions.cpp:279
pFlow::Istream::seek
void seek(size_t pos) override
Definition: Istream.cpp:902
pFlow::Istream::readString
virtual iIstream & readString(word &str) override
Read a string.
Definition: Istream.cpp:680
pFlow::Istream
Standard input stream for binary and ascii data.
Definition: Istream.hpp:39
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::IOstream::bad
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.hpp:204
pFlow::iIstream::getBack
bool getBack(token &tok)
Get the put back token if there is one and return true.
Definition: iIstream.cpp:45
pFlow::Istream::readVariable
Istream & readVariable(word &str)
Read a variable name starting with '$'.
Definition: Istream.cpp:141
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::Istream::read
virtual iIstream & read(token &t) override
Return next token from stream.
Definition: Istream.cpp:392
pFlow::token::BEGIN_STRING
@ BEGIN_STRING
Divide [isseparator].
Definition: token.hpp:106
pFlow::token::END_LIST
@ END_LIST
Begin list [isseparator].
Definition: token.hpp:92
pFlow::token::DOLLAR
@ DOLLAR
Comma [isseparator].
Definition: token.hpp:99
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::Istream::get
Istream & get(char &c)
Raw, low-level get character function.
Definition: Istream.cpp:325
pFlow::token::COLON
@ COLON
End block [isseparator].
Definition: token.hpp:97
pFlow::token::END_STATEMENT
@ END_STATEMENT
Newline [isspace].
Definition: token.hpp:90
pFlow::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.hpp:186
pFlow::Istream::rewind
void rewind() override
Rewind the stream so that it may be read again.
Definition: Istream.cpp:891
pFlow::token::SUBTRACT
@ SUBTRACT
Double quote.
Definition: token.hpp:103
pFlow::token::BEGIN_LIST
@ BEGIN_LIST
End entry [isseparator].
Definition: token.hpp:91
pFlow::token::BEGIN_SQR
@ BEGIN_SQR
End list [isseparator].
Definition: token.hpp:93
pFlow::token::DIVIDE
@ DIVIDE
Subtract or start of negative number.
Definition: token.hpp:104
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::token::COMMA
@ COMMA
Colon [isseparator].
Definition: token.hpp:98
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::Istream::peek
int peek()
Raw, low-level peek function.
Definition: Istream.cpp:339
pFlow::IOstream::writeFormat
writeFormat
Definition: IOstream.hpp:59
pFlow::Istream::flags
virtual ios_base::fmtflags flags() const
Return flags of output stream.
Definition: Istream.cpp:927
pFlow::token::END_STRING
@ END_STRING
Begin string with double quote.
Definition: token.hpp:107
pFlow::Istream::putback
Istream & putback(const char c)
Raw, low-level putback character function.
Definition: Istream.cpp:375
pFlow::Istream::getLine
Istream & getLine(word &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Definition: Istream.cpp:345
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::nl
constexpr char nl
Definition: iOstream.hpp:440
pFlow::token::END_SQR
@ END_SQR
Begin dimensions [isseparator].
Definition: token.hpp:94
pFlow::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.hpp:676
pFlow::token::lineNumber
int32 lineNumber() const
The line number for the token.
Definition: tokenI.hpp:378
error.hpp