www.cemf.ir
tokenI.hpp
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 // based on OpenFOAM stream, with some modifications/simplifications
21 // to be tailored to our needs
22 
23 
24 #include <algorithm>
25 
26 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
27 
29 {
30  token tok;
31  tok.type_ = tokenType::BOOL;
32  tok.data_.int64Val = on;
33 
34  return tok;
35 }
36 
37 
38 inline pFlow::token pFlow::token::flag(int bitmask)
39 {
40  token tok;
41  tok.type_ = tokenType::FLAG;
42  tok.data_.flagVal = bitmask;
43 
44  return tok;
45 }
46 
47 
48 inline bool pFlow::token::isseparator(int c)
49 {
50  // NOTE: keep synchronized with ISstream::read(token&)
51 
52  switch (c)
53  {
55  case token::BEGIN_LIST :
56  case token::END_LIST :
57  case token::BEGIN_SQR :
58  case token::END_SQR :
59  case token::BEGIN_BLOCK :
60  case token::END_BLOCK :
61  case token::COLON :
62  case token::COMMA :
63  // Excluded token::SUBTRACT since it could start a number
64  case token::DIVIDE :
65  {
66  return true;
67  }
68 
69  default:
70  break;
71  }
72 
73  return false;
74 }
75 
76 
77 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
78 
80 {
81  type_ = tokenType::UNDEFINED;
82  data_.int64Val = 0; // bit-wise zero for union content
83 
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
89 inline constexpr pFlow::token::token() noexcept
90 :
91  data_(), // bit-wise zero for union content
92  type_(tokenType::UNDEFINED),
93  lineNumber_(0)
94 {}
95 
96 
97 inline pFlow::token::token(const token& tok)
98 :
99  data_(tok.data_), // bit-wise copy of union content
100  type_(tok.type_),
101  lineNumber_(tok.lineNumber_)
102 {
103  // Fundamental: values already handled by bit-wise copy
104  // Pointer: duplicate content or increase refCount
105 
106  switch (type_)
107  {
108  case tokenType::WORD:
109  case tokenType::DIRECTIVE:
110  {
111  data_.wordPtr = new word(*tok.data_.wordPtr);
112  break;
113  }
114 
115  case tokenType::STRING:
116  case tokenType::VARIABLE:
117  {
118  data_.stringPtr = new word(*tok.data_.stringPtr);
119  break;
120  }
121  default:
122  break;
123  }
124 }
125 
126 
128 :
129  data_(tok.data_), // bit-wise copy of union content
130  type_(tok.type_),
131  lineNumber_(tok.lineNumber_)
132 {
133  tok.setUndefined(); // zero the union content without any checking
134  tok.lineNumber_ = 0;
135 }
136 
137 
139 :
140  data_(),
141  type_(tokenType::PUNCTUATION),
142  lineNumber_(lineNumber)
143 {
144  data_.punctuationVal = p;
145 }
146 
147 inline pFlow::token::token(const uint64 val, int32 lineNumber)
148 :
149  data_(),
150  type_(tokenType::INT64),
151  lineNumber_(lineNumber)
152 {
153  data_.int64Val = static_cast<int64>(val);
154 }
155 
156 inline pFlow::token::token(const uint32 val, int32 lineNumber)
157 :
158  data_(),
159  type_(tokenType::INT64),
160  lineNumber_(lineNumber)
161 {
162  data_.int64Val = static_cast<int64>(val);
163 }
164 
165 inline pFlow::token::token(const uint8 val, int32 lineNumber)
166 :
167  data_(),
168  type_(tokenType::INT64),
169  lineNumber_(lineNumber)
170 {
171  data_.int64Val = static_cast<int64>(val);
172 }
173 
174 inline pFlow::token::token(const int64 val, int32 lineNumber)
175 :
176  data_(),
177  type_(tokenType::INT64),
178  lineNumber_(lineNumber)
179 {
180  data_.int64Val = val;
181 }
182 
183 inline pFlow::token::token(const int32 val, int32 lineNumber)
184 :
185  data_(),
186  type_(tokenType::INT64),
187  lineNumber_(lineNumber)
188 {
189  data_.int64Val = static_cast<int64>(val);
190 }
191 
192 inline pFlow::token::token(const int8 val, int32 lineNumber)
193 :
194  data_(),
195  type_(tokenType::INT64),
196  lineNumber_(lineNumber)
197 {
198  data_.int64Val = static_cast<int64>(val);
199 }
200 
201 inline pFlow::token::token(const float val, int32 lineNumber)
202 :
203  data_(),
204  type_(tokenType::FLOAT),
205  lineNumber_(lineNumber)
206 {
207  data_.floatVal = val;
208 }
209 
210 
211 inline pFlow::token::token(const double val, int32 lineNumber)
212 :
213  data_(),
214  type_(tokenType::DOUBLE),
215  lineNumber_(lineNumber)
216 {
217  data_.doubleVal = val;
218 }
219 
220 
221 inline pFlow::token::token(const word& w, int32 lineNumber, bool isString)
222 :
223  data_(),
224  type_(tokenType::WORD),
225  lineNumber_(lineNumber)
226 {
227  if(isString)
228  {
229  data_.stringPtr = new word(w);
230  type_ = tokenType::STRING;
231  } else
232  {
233  data_.wordPtr = new word(w);
234  }
235 }
236 
237 
238 inline pFlow::token::token(word&& w, int32 lineNumber, bool isString)
239 :
240  data_(),
241  type_(tokenType::WORD),
242  lineNumber_(lineNumber)
243 {
244  if(isString)
245  {
246  data_.stringPtr = new word(std::move(w));
247  type_ = tokenType::STRING;
248  } else
249  {
250  data_.wordPtr = new word(std::move(w));
251  }
252 }
253 
254 
256 {
257  reset();
258 }
259 
260 
261 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
262 
263 inline void pFlow::token::reset()
264 {
265  switch (type_)
266  {
267  case tokenType::WORD:
268  case tokenType::DIRECTIVE:
269  {
270  delete data_.wordPtr;
271  break;
272  }
273 
274  case tokenType::STRING:
275  case tokenType::VARIABLE:
276  {
277  delete data_.stringPtr;
278  break;
279  }
280 
281  default:
282  break;
283  }
284 
285  setUndefined();
286 }
287 
288 
289 inline void pFlow::token::swap(token& tok)
290 {
291  if (this == &tok)
292  {
293  return; // Self-swap is a no-op
294  }
295 
296  std::swap(data_, tok.data_);
297  std::swap(type_, tok.type_);
298  std::swap(lineNumber_, tok.lineNumber_);
299 }
300 
301 
303 {
304  return type_;
305 }
306 
307 
309 {
310  if (type_ == tokType)
311  {
312  // No change required
313  return true;
314  }
315 
316  switch (tokType)
317  {
318  case tokenType::BOOL:
319  case tokenType::INT64:
320  {
321  switch (type_)
322  {
323  case tokenType::BOOL:
324  case tokenType::INT64:
325  type_ = tokType;
326  return true;
327  break;
328 
329  default:
330  break;
331  }
332  }
333  break;
334 
335  case tokenType::WORD:
336  case tokenType::DIRECTIVE:
337  {
338  switch (type_)
339  {
340  case tokenType::WORD:
341  case tokenType::DIRECTIVE:
342  type_ = tokType;
343  return true;
344  break;
345 
346  default:
347  break;
348  }
349  }
350  break;
351 
352  case tokenType::STRING:
353  case tokenType::VARIABLE:
354  {
355  switch (type_)
356  {
357  // could also go from WORD to STRING etc - to be decided
358  case tokenType::STRING:
359  case tokenType::VARIABLE:
360  type_ = tokType;
361  return true;
362  break;
363 
364  default:
365  break;
366  }
367  }
368  break;
369 
370  default:
371  break;
372  }
373 
374  return false;
375 }
376 
377 
379 {
380  return lineNumber_;
381 }
382 
383 
385 {
386  return lineNumber_;
387 }
388 
389 
390 inline bool pFlow::token::good() const
391 {
392  return (type_ != tokenType::UNDEFINED && type_ != tokenType::ERROR);
393 }
394 
395 
396 inline bool pFlow::token::undefined() const
397 {
398  return (type_ == tokenType::UNDEFINED);
399 }
400 
401 
402 inline bool pFlow::token::error() const
403 {
404  return (type_ == tokenType::ERROR);
405 }
406 
407 
408 inline bool pFlow::token::isBool() const
409 {
410  return (type_ == tokenType::BOOL);
411 }
412 
413 
414 inline bool pFlow::token::boolToken() const
415 {
416  if (type_ == tokenType::BOOL || type_ == tokenType::INT64)
417  {
418  return data_.int64Val;
419  }
420 
421  parseError("bool");
422  return false;
423 }
424 
425 
426 inline bool pFlow::token::isFlag() const
427 {
428  return (type_ == tokenType::FLAG);
429 }
430 
431 
432 inline int pFlow::token::flagToken() const
433 {
434  if (type_ == tokenType::FLAG)
435  {
436  return data_.flagVal;
437  }
438 
439  parseError("flag bitmask");
440  return NO_FLAG;
441 }
442 
443 
444 inline bool pFlow::token::isPunctuation() const
445 {
446  return (type_ == tokenType::PUNCTUATION);
447 }
448 
449 inline bool pFlow::token::isEndStatement() const
450 {
451  if( type_ == tokenType::PUNCTUATION )
452  {
453  return pToken() == punctuationToken::END_STATEMENT;
454  }
455 
456  return false;
457 }
458 
459 
460 inline bool pFlow::token::isEndBlock() const
461 {
462  if( type_ == tokenType::PUNCTUATION )
463  {
464  return pToken() == punctuationToken::END_BLOCK;
465  }
466 
467  return false;
468 }
469 
471 {
472  if (type_ == tokenType::PUNCTUATION)
473  {
474  return data_.punctuationVal;
475  }
476 
477  parseError("punctuation character");
478  return punctuationToken::NULL_TOKEN;
479 }
480 
481 
482 inline bool pFlow::token::isSeparator() const
483 {
484  return
485  (
486  type_ == tokenType::PUNCTUATION
487  && isseparator(data_.punctuationVal)
488  );
489 }
490 
491 
492 inline bool pFlow::token::isInt64() const
493 {
494  return (type_ == tokenType::INT64);
495 }
496 
497 inline bool pFlow::token::isInt32() const
498 {
499  return (type_ == tokenType::INT64);
500 }
501 
503 {
504  if (type_ == tokenType::INT64)
505  {
506  return data_.int64Val;
507  }
508 
509  parseError("int64");
510  return 0;
511 }
512 
514 {
515  return static_cast<int32>(int64Token());
516 }
517 
518 inline bool pFlow::token::isFloat() const
519 {
520  return (type_ == tokenType::FLOAT);
521 }
522 
523 
524 inline float pFlow::token::floatToken() const
525 {
526  if (type_ == tokenType::FLOAT)
527  {
528  return data_.floatVal;
529  }
530 
531  parseError("float");
532  return 0;
533 }
534 
535 
536 inline bool pFlow::token::isDouble() const
537 {
538  return (type_ == tokenType::DOUBLE);
539 }
540 
541 
542 inline double pFlow::token::doubleToken() const
543 {
544  if (type_ == tokenType::DOUBLE)
545  {
546  return data_.doubleVal;
547  }
548 
549  parseError("double");
550  return 0;
551 }
552 
553 
554 inline bool pFlow::token::isReal() const
555 {
556  return
557  (
558  type_ == tokenType::FLOAT
559  || type_ == tokenType::DOUBLE
560  );
561 }
562 
563 
565 {
566  if (type_ == tokenType::FLOAT)
567  {
568  return data_.floatVal;
569  }
570  else if (type_ == tokenType::DOUBLE)
571  {
572  return data_.doubleVal;
573  }
574 
575  parseError("real");
576  return 0;
577 }
578 
579 
580 inline bool pFlow::token::isNumber() const
581 {
582  return (type_ == tokenType::INT64 || isReal());
583 }
584 
585 
587 {
588  if (isInt64())
589  {
590  return int64Token();
591  }
592  if (isReal())
593  {
594  return realToken();
595  }
596 
597  parseError("number (int64 or real)");
598  return 0;
599 }
600 
601 
602 inline bool pFlow::token::isWord() const
603 {
604  return
605  (
606  type_ == tokenType::WORD
607  || type_ == tokenType::DIRECTIVE
608  );
609 }
610 
611 
612 inline bool pFlow::token::isDirective() const
613 {
614  return (type_ == tokenType::DIRECTIVE);
615 }
616 
617 
619 {
620  if
621  (
622  type_ == tokenType::WORD
623  || type_ == tokenType::DIRECTIVE
624  )
625  {
626  return *data_.wordPtr;
627  }
628 
629  parseError("word");
630  return nullWord;
631 }
632 
633 inline bool pFlow::token::isString() const
634 {
635  return
636  (
637  type_ == tokenType::STRING
638  || type_ == tokenType::VARIABLE
639  );
640 }
641 
643 {
644  if
645  (
646  type_ == tokenType::STRING
647  || type_ == tokenType::VARIABLE
648  )
649  {
650  return *data_.stringPtr;
651  }
652  else if
653  (
654  type_ == tokenType::WORD
655  || type_ == tokenType::DIRECTIVE
656  )
657  {
658  // pFlow::word derives from pFlow::string, no need to cast.
659  return *data_.wordPtr;
660  }
661 
662  parseError("string");
663  return nullWord;
664 }
665 
666 inline bool pFlow::token::isVariable() const
667 {
668  return (type_ == tokenType::VARIABLE);
669 }
670 
671 inline bool pFlow::token::isStringType() const
672 {
673  return (isWord() || isString());
674 }
675 
676 inline void pFlow::token::setBad()
677 {
678  reset();
679  type_ = tokenType::ERROR;
680 }
681 
682 
683 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
684 
685 inline void pFlow::token::operator=(const token& tok)
686 {
687  if (this == &tok)
688  {
689  return; // Self-assignment is a no-op
690  }
691 
692  reset();
693 
694  type_ = tok.type_;
695  data_ = tok.data_; // bit-wise copy of union content
696  lineNumber_ = tok.lineNumber_;
697 
698  // Fundamental: values already handled by bit-wise copy
699  // Pointer: duplicate content or increase refCount
700 
701  switch (type_)
702  {
703  case tokenType::WORD:
704  case tokenType::DIRECTIVE:
705  {
706  data_.wordPtr = new word(*tok.data_.wordPtr);
707  }
708  break;
709 
710  case tokenType::STRING:
711  case tokenType::VARIABLE:
712  {
713  data_.stringPtr = new word(*tok.data_.stringPtr);
714  }
715  break;
716 
717  default:
718  break;
719  }
720 }
721 
722 
723 inline void pFlow::token::operator=(token&& tok)
724 {
725  if (this == &tok)
726  {
727  return; // Self-assignment is a no-op
728  }
729 
730  reset();
731  lineNumber_ = 0;
732  swap(tok);
733 }
734 
735 
737 {
738  reset();
739  type_ = tokenType::PUNCTUATION;
740  data_.punctuationVal = p;
741 }
742 
743 
744 inline void pFlow::token::operator=(const int64 val)
745 {
746  reset();
747  type_ = tokenType::INT64;
748  data_.int64Val = val;
749 }
750 
751 inline void pFlow::token::operator=(const int32 val)
752 {
753  reset();
754  type_ = tokenType::INT64;
755  data_.int64Val = static_cast<int64>(val);
756 }
757 
758 
759 inline void pFlow::token::operator=(const float val)
760 {
761  reset();
762  type_ = tokenType::FLOAT;
763  data_.floatVal = val;
764 }
765 
766 
767 inline void pFlow::token::operator=(const double val)
768 {
769  reset();
770  type_ = tokenType::DOUBLE;
771  data_.doubleVal = val;
772 }
773 
774 
775 inline void pFlow::token::operator=(const word& w)
776 {
777  reset();
778  type_ = tokenType::WORD;
779  data_.wordPtr = new word(w);
780 }
781 
782 
784 {
785  reset();
786  type_ = tokenType::WORD;
787  data_.wordPtr = new word(std::move(w));
788 }
789 
790 
791 inline bool pFlow::token::operator==(const token& tok) const
792 {
793  if (type_ != tok.type_)
794  {
795  return false;
796  }
797 
798  switch (type_)
799  {
800  case tokenType::UNDEFINED:
801  return true;
802 
803  case tokenType::BOOL:
804  return data_.int64Val == tok.data_.int64Val;
805 
806  case tokenType::FLAG:
807  return data_.flagVal == tok.data_.flagVal;
808 
809  case tokenType::PUNCTUATION:
810  return data_.punctuationVal == tok.data_.punctuationVal;
811 
812  case tokenType::INT64:
813  return data_.int64Val == tok.data_.int64Val;
814 
815  case tokenType::FLOAT:
816  return equal(data_.floatVal, tok.data_.floatVal);
817 
818  case tokenType::DOUBLE:
819  return equal(static_cast<real>(data_.doubleVal), static_cast<real>(tok.data_.doubleVal));
820 
821  case tokenType::WORD:
822  case tokenType::DIRECTIVE:
823  return *data_.wordPtr == *tok.data_.wordPtr;
824 
825  case tokenType::STRING:
826  case tokenType::VARIABLE:
827  return *data_.stringPtr == *tok.data_.stringPtr;
828 
829  case tokenType::ERROR:
830  return true;
831  }
832 
833  return false;
834 }
835 
836 
837 inline bool pFlow::token::operator==(const punctuationToken p) const
838 {
839  return (type_ == tokenType::PUNCTUATION && data_.punctuationVal == p);
840 }
841 
842 
843 inline bool pFlow::token::operator==(const int64 val) const
844 {
845  return
846  (
847  type_ == tokenType::INT64
848  && data_.int64Val == val
849  );
850 }
851 
852 inline bool pFlow::token::operator==(const int32 val) const
853 {
854  return
855  (
856  type_ == tokenType::INT64
857  && data_.int64Val == static_cast<int64>(val)
858  );
859 }
860 
861 
862 inline bool pFlow::token::operator==(const float val) const
863 {
864  return
865  (
866  type_ == tokenType::FLOAT
867  && equal(data_.floatVal, val)
868  );
869 }
870 
871 
872 inline bool pFlow::token::operator==(const double val) const
873 {
874  return
875  (
876  type_ == tokenType::DOUBLE
877  && equal( static_cast<real>(data_.doubleVal), static_cast<real>(val))
878  );
879 }
880 
881 inline bool pFlow::token::operator==(const word& w) const
882 {
883  return
884  (
885  type_== tokenType::WORD
886  && *data_.wordPtr == w
887  );
888 }
889 
890 inline bool pFlow::token::operator!=(const token& tok) const
891 {
892  return !operator==(tok);
893 }
894 
895 
896 inline bool pFlow::token::operator!=(const punctuationToken p) const
897 {
898  return !operator==(p);
899 }
900 
901 
902 inline bool pFlow::token::operator!=(const int64 val) const
903 {
904  return !operator==(val);
905 }
906 
907 inline bool pFlow::token::operator!=(const int32 val) const
908 {
909  return !operator==(val);
910 }
911 
912 
913 inline bool pFlow::token::operator!=(const float val) const
914 {
915  return !operator==(val);
916 }
917 
918 
919 inline bool pFlow::token::operator!=(const double val) const
920 {
921  return !operator==(val);
922 }
923 
924 
925 inline bool pFlow::token::operator!=(const word& w) const
926 {
927  return !operator==(w);
928 }
929 
930 
931 // ************************************************************************* //
pFlow::token::setType
bool setType(const tokenType tokType)
Change the token type, for similar types.
Definition: tokenI.hpp:308
pFlow::token::isBool
bool isBool() const
Token is BOOL.
Definition: tokenI.hpp:408
pFlow::token::operator==
bool operator==(const token &tok) const
Definition: tokenI.hpp:791
pFlow::token::type
tokenType type() const
Return the token type.
Definition: tokenI.hpp:302
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::token::undefined
bool undefined() const
Token is UNDEFINED.
Definition: tokenI.hpp:396
pFlow::token::~token
~token()
Destructor.
Definition: tokenI.hpp:255
pFlow::token::data_
content data_
The data content (as a union).
Definition: token.hpp:181
pFlow::token::pToken
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.hpp:470
pFlow::token::isFloat
bool isFloat() const
Token is float.
Definition: tokenI.hpp:518
pFlow::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.hpp:83
pFlow::token::content::stringPtr
word * stringPtr
Definition: token.hpp:173
pFlow::token::isEndBlock
bool isEndBlock() const
Token is end endBlock.
Definition: tokenI.hpp:460
pFlow::token::isPunctuation
bool isPunctuation() const
Token is PUNCTUATION.
Definition: tokenI.hpp:444
pFlow::token::stringToken
const word & stringToken() const
Return const reference to the string contents.
Definition: tokenI.hpp:642
pFlow::token::END_BLOCK
@ END_BLOCK
Begin block [isseparator].
Definition: token.hpp:96
pFlow::token::error
bool error() const
Token is ERROR.
Definition: tokenI.hpp:402
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::operator==
INLINE_FUNCTION_HD bool operator==(const box &b1, const box &b2)
Definition: box.hpp:142
pFlow::token::good
bool good() const
True if token is not UNDEFINED or ERROR.
Definition: tokenI.hpp:390
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::token::isDouble
bool isDouble() const
Token is double.
Definition: tokenI.hpp:536
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::token::number
real number() const
Return int64, float or double value.
Definition: tokenI.hpp:586
pFlow::token::isVariable
bool isVariable() const
Token is VARIABLE (string variant)
Definition: tokenI.hpp:666
pFlow::token::boolean
static token boolean(bool on)
Create a bool token.
Definition: tokenI.hpp:28
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::token::int64Token
int64 int64Token() const
Return int64 value.
Definition: tokenI.hpp:502
pFlow::token::isSeparator
bool isSeparator() const
Token is PUNCTUATION and isseparator.
Definition: tokenI.hpp:482
pFlow::token::content::punctuationVal
punctuationToken punctuationVal
Definition: token.hpp:167
pFlow::token::boolToken
bool boolToken() const
Return boolean token value.
Definition: tokenI.hpp:414
pFlow::token::isStringType
bool isStringType() const
Token is WORD, DIRECTIVE, STRING, VARIABLE or VERBATIM.
Definition: tokenI.hpp:671
pFlow::nullWord
const word nullWord
null/empty word
Definition: bTypesFunctions.hpp:49
pFlow::token::BEGIN_BLOCK
@ BEGIN_BLOCK
End dimensions [isseparator].
Definition: token.hpp:95
pFlow::token::setUndefined
void setUndefined()
Set as UNDEFINED and zero the union content without any checking.
Definition: tokenI.hpp:79
pFlow::token::flagToken
int flagToken() const
Return flag bitmask value.
Definition: tokenI.hpp:432
pFlow::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.hpp:263
pFlow::token::token
constexpr token() noexcept
Default construct, initialized to an UNDEFINED token.
Definition: tokenI.hpp:89
pFlow::token::doubleToken
double doubleToken() const
Return double value.
Definition: tokenI.hpp:542
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::token::realToken
real realToken() const
Return float or double value.
Definition: tokenI.hpp:564
pFlow::token::isseparator
static bool isseparator(int c)
True if the character is a punctuation separator (eg, in ISstream).
Definition: tokenI.hpp:48
pFlow::token::lineNumber_
int32 lineNumber_
Line number in the file the token was read from.
Definition: token.hpp:187
pFlow::token::flag
static token flag(int bitmask)
Create a token with stream flags, no sanity check.
Definition: tokenI.hpp:38
pFlow::token::content::flagVal
int flagVal
Definition: token.hpp:166
pFlow::token::END_LIST
@ END_LIST
Begin list [isseparator].
Definition: token.hpp:92
pFlow::token::floatToken
float floatToken() const
Return float value.
Definition: tokenI.hpp:524
pFlow::token::content::wordPtr
word * wordPtr
Definition: token.hpp:172
pFlow::token::isInt64
bool isInt64() const
Token is int64.
Definition: tokenI.hpp:492
pFlow::token::COLON
@ COLON
End block [isseparator].
Definition: token.hpp:97
pFlow::token::isInt32
bool isInt32() const
Token is int32.
Definition: tokenI.hpp:497
pFlow::token::END_STATEMENT
@ END_STATEMENT
Newline [isspace].
Definition: token.hpp:90
pFlow::token::isFlag
bool isFlag() const
Token is FLAG.
Definition: tokenI.hpp:426
pFlow::token::content::floatVal
float floatVal
Definition: token.hpp:168
pFlow::token::tokenType
tokenType
Enumeration defining the types of token.
Definition: token.hpp:51
pFlow::token::content::int64Val
int64_t int64Val
Definition: token.hpp:164
pFlow::token::content::doubleVal
double doubleVal
Definition: token.hpp:169
pFlow::token::BEGIN_LIST
@ BEGIN_LIST
End entry [isseparator].
Definition: token.hpp:91
pFlow::token::swap
void swap(token &tok)
Swap token contents: type, data, line-number.
Definition: tokenI.hpp:289
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
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::token::operator=
void operator=(const token &tok)
Copy assign.
Definition: tokenI.hpp:685
pFlow::token::operator!=
bool operator!=(const token &tok) const
Definition: tokenI.hpp:890
pFlow::token::type_
tokenType type_
The token type.
Definition: token.hpp:184
pFlow::token::isNumber
bool isNumber() const
Token is int, float or duble.
Definition: tokenI.hpp:580
pFlow::token::isEndStatement
bool isEndStatement() const
Token is end statement.
Definition: tokenI.hpp:449
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::token::isDirective
bool isDirective() const
Token is DIRECTIVE (word variant)
Definition: tokenI.hpp:612
pFlow::token::int32Token
int32 int32Token() const
Return int32 value.
Definition: tokenI.hpp:513
pFlow::token::END_SQR
@ END_SQR
Begin dimensions [isseparator].
Definition: token.hpp:94
pFlow::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.hpp:618
pFlow::token::setBad
void setBad()
Clear token and set to be ERROR.
Definition: tokenI.hpp:676
pFlow::token::isString
bool isString() const
Token is STRING, VARIABLE or VERBATIM string.
Definition: tokenI.hpp:633
pFlow::token::lineNumber
int32 lineNumber() const
The line number for the token.
Definition: tokenI.hpp:378
pFlow::token::isReal
bool isReal() const
Token is float or double.
Definition: tokenI.hpp:554
pFlow::token::isWord
bool isWord() const
Token is word or DIRECTIVE word.
Definition: tokenI.hpp:602