SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
lx.cpp
Go to the documentation of this file.
1 // Lexical-Chars
3 void TLxChDef::SetUcCh(const TStr& Str){
4  for (int CC=1; CC<Str.Len(); CC++){
5  UcChV[Str[CC]-TCh::Mn]=TCh(Str[0]);}
6 }
7 
8 void TLxChDef::SetChTy(const TLxChTy& ChTy, const TStr& Str){
9  for (int CC=0; CC<Str.Len(); CC++){
10  ChTyV[Str[CC]-TCh::Mn]=TInt(ChTy);}
11 }
12 
14  ChTyV(TCh::Vals), UcChV(TCh::Vals){
15 
16  if (ChDefTy==lcdtUsAscii){
17  // Character-Types
19  SetChTy(lctNum, "0123456789");
20  SetChTy(lctAlpha, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
21  SetChTy(lctAlpha, "abcdefghijklmnopqrstuvwxyz");
22  SetChTy(lctAlpha, "@_");
23  SetChTy(lctSSym, "\"'.,:;+-*/%!#|&<=>?()[]{}");
27 
28  // Upper-Case
29  for (int Ch=TCh::Mn; Ch<=TCh::Mx; Ch++){UcChV[Ch-TCh::Mn]=TCh(char(Ch));}
30  SetUcCh("Aa"); SetUcCh("Bb"); SetUcCh("Cc"); SetUcCh("Dd"); SetUcCh("Ee");
31  SetUcCh("Ff"); SetUcCh("Gg"); SetUcCh("Hh"); SetUcCh("Ii"); SetUcCh("Jj");
32  SetUcCh("Kk"); SetUcCh("Ll"); SetUcCh("Mm"); SetUcCh("Nn"); SetUcCh("Oo");
33  SetUcCh("Pp"); SetUcCh("Qq"); SetUcCh("Rr"); SetUcCh("Ss"); SetUcCh("Tt");
34  SetUcCh("Uu"); SetUcCh("Vv"); SetUcCh("Ww"); SetUcCh("Xx"); SetUcCh("Yy");
35  SetUcCh("Zz");
36  } else
37  if (ChDefTy==lcdtYuAscii){
38  // Character-Types
40  SetChTy(lctNum, "0123456789");
41  SetChTy(lctAlpha, "ABC^]D\\EFGHIJKLMNOPQRS[TUVWXYZ@");
42  SetChTy(lctAlpha, "abc~}d|efghijklmnopqrs{tuvwxyz`");
43  SetChTy(lctAlpha, "_");
44  SetChTy(lctSSym, "\".,:;+-*/%!#&<=>?()");
48 
49  // Upper-Case
50  for (int Ch=TCh::Mn; Ch<=TCh::Mx; Ch++){UcChV[Ch-TCh::Mn]=TCh(char(Ch));}
51  SetUcCh("Aa"); SetUcCh("Bb"); SetUcCh("Cc"); SetUcCh("^~"); SetUcCh("]}");
52  SetUcCh("Dd"); SetUcCh("\\|"); SetUcCh("Ee"); SetUcCh("Ff"); SetUcCh("Gg");
53  SetUcCh("Hh"); SetUcCh("Ii"); SetUcCh("Jj"); SetUcCh("Kk"); SetUcCh("Ll");
54  SetUcCh("Mm"); SetUcCh("Nn"); SetUcCh("Oo"); SetUcCh("Pp"); SetUcCh("Qq");
55  SetUcCh("Rr"); SetUcCh("Ss"); SetUcCh("[{"); SetUcCh("Tt"); SetUcCh("Uu");
56  SetUcCh("Vv"); SetUcCh("Ww"); SetUcCh("Xx"); SetUcCh("Yy"); SetUcCh("Zz");
57  SetUcCh("@`");
58  } else {
59  Fail;
60  }
61 }
62 
63 bool TLxChDef::IsNmStr(const TStr& Str) const {
64  if (Str.Len()==0){return false;}
65  if (!IsAlpha(Str.GetCh(0))){return false;}
66  for (int ChN=1; ChN<Str.Len(); ChN++){
67  if (!IsAlNum(Str.GetCh(ChN))){return false;}}
68  return true;
69 }
70 
71 TStr TLxChDef::GetUcStr(const TStr& Str) const {
72  TChA UcStr;
73  for (int ChN=0; ChN<Str.Len(); ChN++){
74  UcStr.AddCh(GetUc(Str.GetCh(ChN)));}
75  return UcStr;
76 }
77 
78 
80  static PLxChDef UsAsciiChDef=NULL;
81  static PLxChDef YuAsciiChDef=NULL;
82  switch (ChDefTy){
83  case lcdtUsAscii:
84  if (UsAsciiChDef.Empty()){UsAsciiChDef=TLxChDef::New(lcdtUsAscii);}
85  return UsAsciiChDef;
86  case lcdtYuAscii:
87  if (YuAsciiChDef.Empty()){YuAsciiChDef=TLxChDef::New(lcdtYuAscii);}
88  return YuAsciiChDef;
89  default: Fail; return NULL;
90  }
91 }
92 
93 //TLxChDef& TLxChDef::GetChDefRef(const TLxChDefTy& ChDefTy){
94 // switch (ChDefTy){
95 // case lcdtUsAscii: return *UsAsciiChDef;
96 // case lcdtYuAscii: return *YuAsciiChDef;
97 // default: Fail; return *UsAsciiChDef;;
98 // }
99 //}
100 
102 // Lexical-Symbols
103 const TStr TLxSymStr::UndefStr="<undefined>";
104 const TStr TLxSymStr::LnStr="<line>";
105 const TStr TLxSymStr::TabStr="<tab>";
106 const TStr TLxSymStr::IntStr="<integer>";
107 const TStr TLxSymStr::FltStr="<float>";
108 const TStr TLxSymStr::StrStr="<string>";
109 const TStr TLxSymStr::IdStrStr="<id-string>";
110 const TStr TLxSymStr::QStrStr="<q-string>";
111 const TStr TLxSymStr::PeriodStr=".";
112 const TStr TLxSymStr::DPeriodStr="..";
113 const TStr TLxSymStr::CommaStr=",";
114 const TStr TLxSymStr::ColonStr=":";
115 const TStr TLxSymStr::DColonStr="::";
116 const TStr TLxSymStr::SemicolonStr=";";
117 const TStr TLxSymStr::PlusStr="+";
118 const TStr TLxSymStr::MinusStr="-";
119 const TStr TLxSymStr::AsteriskStr="*";
120 const TStr TLxSymStr::SlashStr="/";
121 const TStr TLxSymStr::PercentStr="%";
123 const TStr TLxSymStr::VBarStr="|";
124 const TStr TLxSymStr::AmpersandStr="&";
125 const TStr TLxSymStr::QuestionStr="?";
126 const TStr TLxSymStr::HashStr="#";
127 const TStr TLxSymStr::EqStr="=";
128 const TStr TLxSymStr::NEqStr="<>";
129 const TStr TLxSymStr::LssStr="<";
130 const TStr TLxSymStr::GtrStr=">";
131 const TStr TLxSymStr::LEqStr="<=";
132 const TStr TLxSymStr::GEqStr=">=";
133 const TStr TLxSymStr::LParenStr="(";
134 const TStr TLxSymStr::RParenStr=")";
135 const TStr TLxSymStr::LBracketStr="[";
136 const TStr TLxSymStr::RBracketStr="]";
137 const TStr TLxSymStr::LBraceStr="{";
138 const TStr TLxSymStr::RBraceStr="}";
139 const TStr TLxSymStr::EolnStr="<end-of-line>";
140 const TStr TLxSymStr::EofStr="<end-of-file>";
141 
143  switch (Sym){
144  case syUndef: return UndefStr;
145  case syLn: return LnStr;
146  case syTab: return TabStr;
147  case syInt: return IntStr;
148  case syFlt: return FltStr;
149  case syStr: return StrStr;
150  case syIdStr: return IdStrStr;
151  case syQStr: return QStrStr;
152  case syPeriod: return PeriodStr;
153  case syDPeriod: return DPeriodStr;
154  case syComma: return CommaStr;
155  case syColon: return ColonStr;
156  case syDColon: return DColonStr;
157  case sySemicolon: return SemicolonStr;
158  case syPlus: return PlusStr;
159  case syMinus: return MinusStr;
160  case syAsterisk: return AsteriskStr;
161  case sySlash: return SlashStr;
162  case syPercent: return PercentStr;
163  case syExclamation: return ExclamationStr;
164  case syVBar: return VBarStr;
165  case syAmpersand: return AmpersandStr;
166  case syQuestion: return QuestionStr;
167  case syHash: return HashStr;
168  case syEq: return EqStr;
169  case syNEq: return NEqStr;
170  case syLss: return LssStr;
171  case syGtr: return GtrStr;
172  case syLEq: return LEqStr;
173  case syGEq: return GEqStr;
174  case syLParen: return LParenStr;
175  case syRParen: return RParenStr;
176  case syLBracket: return LBracketStr;
177  case syRBracket: return RBracketStr;
178  case syLBrace: return LBraceStr;
179  case syRBrace: return RBraceStr;
180  case syEoln: return EolnStr;
181  case syEof: return EofStr;
182  default: Fail; return TStr();
183  }
184 }
185 
187  static TStrIntH StrToLxSymH(100);
188  if (StrToLxSymH.Len()==0){
189  StrToLxSymH.AddDat(PeriodStr, syPeriod);
190  StrToLxSymH.AddDat(DPeriodStr, syDPeriod);
191  StrToLxSymH.AddDat(CommaStr, syComma);
192  StrToLxSymH.AddDat(ColonStr, syColon);
193  StrToLxSymH.AddDat(DColonStr, syDColon);
194  StrToLxSymH.AddDat(SemicolonStr, sySemicolon);
195  StrToLxSymH.AddDat(PlusStr, syPlus);
196  StrToLxSymH.AddDat(MinusStr, syMinus);
197  StrToLxSymH.AddDat(AsteriskStr, syAsterisk);
198  StrToLxSymH.AddDat(SlashStr, sySlash);
199  StrToLxSymH.AddDat(PercentStr, syPercent);
200  StrToLxSymH.AddDat(ExclamationStr, syExclamation);
201  StrToLxSymH.AddDat(VBarStr, syVBar);
202  StrToLxSymH.AddDat(AmpersandStr, syAmpersand);
203  StrToLxSymH.AddDat(QuestionStr, syQuestion);
204  StrToLxSymH.AddDat(HashStr, syHash);
205  StrToLxSymH.AddDat(EqStr, syEq);
206  StrToLxSymH.AddDat(NEqStr, syNEq);
207  StrToLxSymH.AddDat(LssStr, syLss);
208  StrToLxSymH.AddDat(GtrStr, syGtr);
209  StrToLxSymH.AddDat(LEqStr, syLEq);
210  StrToLxSymH.AddDat(GEqStr, syGEq);
211  StrToLxSymH.AddDat(LParenStr, syLParen);
212  StrToLxSymH.AddDat(RParenStr, syRParen);
213  StrToLxSymH.AddDat(LBracketStr, syLBracket);
214  StrToLxSymH.AddDat(RBracketStr, syRBracket);
215  StrToLxSymH.AddDat(LBraceStr, syLBrace);
216  StrToLxSymH.AddDat(RBraceStr, syRBrace);
217  }
218  int KeyId=StrToLxSymH.GetKeyId(Str);
219  if (KeyId==-1){
220  return syUndef;
221  } else {
222  return TLxSym(int(StrToLxSymH[KeyId]));
223  }
224 }
225 
226 bool TLxSymStr::IsSep(const TLxSym& PrevSym, const TLxSym& Sym){
227  static TFSet SepPrevSymSet=TFSet()|
230  syEoln|syEof;
231 
232  static TFSet SepSymSet=TFSet()|
234  syEq|
237  syEoln|syEof;
238 
239  return !SepPrevSymSet.In(PrevSym) && !SepSymSet.In(Sym);
240 }
241 
243 // Lexical-Symbol-State
245  Sym(syUndef),
246  Str(), UcStr(), CmtStr(),
247  Bool(false), Int(0), Flt(0),
248  SymLnN(-1), SymLnChN(-1), SymChN(-1){}
249 
251  Sym(SymSt.Sym),
252  Str(SymSt.Str), UcStr(SymSt.UcStr), CmtStr(SymSt.CmtStr),
253  Bool(SymSt.Bool), Int(SymSt.Int), Flt(SymSt.Flt),
254  SymLnN(SymSt.SymLnN), SymLnChN(SymSt.SymLnChN), SymChN(SymSt.SymChN){Fail;}
255 
257  Sym(Lx.Sym),
258  Str(Lx.Str), UcStr(Lx.UcStr), CmtStr(Lx.CmtStr),
259  Bool(Lx.Bool), Int(Lx.Int), Flt(Lx.Flt),
260  SymLnN(Lx.SymLnN), SymLnChN(Lx.SymLnChN), SymChN(Lx.SymChN){}
261 
263  Lx.Sym=Sym;
264  Lx.Str=Str; Lx.UcStr=UcStr; Lx.CmtStr=CmtStr;
265  Lx.Bool=Bool; Lx.Int=Int; Lx.Flt=Flt;
267 
269 // Lexical-Input
270 TILx::TILx(const PSIn& _SIn, const TFSet& OptSet, const TLxChDefTy& ChDefTy):
271  ChDef(TLxChDef::GetChDef(ChDefTy)),
272  SIn(_SIn), RSIn(*SIn),
273  PrevCh(' '), Ch(' '), LnN(0), LnChN(0-1), ChN(0-1),
274  PrevSymStStack(), RwStrH(50),
275  IsCmtAlw(false), IsRetEoln(false), IsSigNum(false),
276  IsUniStr(false), IsCsSens(false), IsExcept(false),
277  IsTabSep(false), IsList(false),
278  Sym(syUndef),
279  Str(), UcStr(), CmtStr(),
280  Bool(false), Int(0), Flt(0),
281  SymLnN(-1), SymLnChN(-1), SymChN(-1){
282  for (int Opt=0; Opt<iloMx; Opt++){
283  if (OptSet.In(Opt)){SetOpt(Opt, true);}}
284 }
285 
286 void TILx::SetOpt(const int& Opt, const bool& Val){
287  switch (Opt){
288  case iloCmtAlw: IsCmtAlw=Val; break;
289  case iloRetEoln: IsRetEoln=Val; break;
290  case iloSigNum: IsSigNum=Val; break;
291  case iloUniStr: IsUniStr=Val; break;
292  case iloCsSens: IsCsSens=Val; break;
293  case iloExcept: IsExcept=Val; break;
294  case iloTabSep: IsTabSep=Val; break;
295  case iloList: IsList=Val; break;
296  default: Fail;
297  }
298 }
299 
300 TLxSym TILx::AddRw(const TStr& Str){
302  TStr UcStr=ChDef->GetUcStr(Str);
303  IAssert(!RwStrH.IsKey(UcStr));
304  TLxSym RwSym=TLxSym(syMnRw+RwStrH.Len());
305  RwStrH.AddDat(Str, TInt(int(RwSym)));
306  return RwSym;
307 }
308 
309 PSIn TILx::GetSIn(const char& SepCh){
311  while ((Ch!=TCh::EofCh)&&(Ch!=SepCh)){GetCh();}
312  return SIn;
313 }
314 
315 TLxSym TILx::GetSym(const TFSet& Expect){
316  CmtStr.Clr();
317  if (!PrevSymStStack.Empty()){
318  // symbols already on the stack
320  } else
321  if (Expect.In(syLn)){
322  // symbol is the whole line string
323  if (Ch==TCh::EofCh){
324  Sym=syEof;
325  } else {
326  Str.Clr();
327  if (IsBof()){GetCh();}
328  while (!ChDef->IsTerm(Ch)){Str.AddCh(Ch); GetCh();}
329  bool _IsRetEoln=IsRetEoln; IsRetEoln=true;
331  IsRetEoln=_IsRetEoln;
332  }
333  } else
334  if (IsTabSep){
335  // symbol is between tab characters
336  if (IsBof()){GetCh();}
337  if (Ch==TCh::TabCh){ // tab character
338  Sym=syTab; GetCh();
339  } else
340  if (ChDef->IsTerm(Ch)){ // eoln & eof characters
341  bool _IsRetEoln=IsRetEoln; IsRetEoln=true; IsTabSep=false;
343  IsRetEoln=_IsRetEoln; IsTabSep=true;
344  } else {
345  Str.Clr();
346  while ((!ChDef->IsTerm(Ch))&&(Ch!=TCh::TabCh)){
347  Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
348  Sym=syStr; QuoteP=false;
349  }
350  } else {
351  // usual symbol
352  while (ChDef->IsSpace(Ch)){GetCh();}
354 
355  if (ChDef->IsAlpha(Ch)){
356  if (IsUniStr){Sym=syStr;} else {Sym=syIdStr;}
357  Str.Clr(); UcStr.Clr(); QuoteP=false;
358  do {Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch));}
359  while (ChDef->IsAlNum(GetCh()));
360  if (!RwStrH.Empty()){
361  TStr RwStr=Str; if (!IsCsSens){RwStr=UcStr;}
362  int SymKeyId=RwStrH.GetKeyId(RwStr);
363  if (SymKeyId!=-1){Sym=TLxSym(int(RwStrH[SymKeyId]));}
364  }
365  if (Expect.In(syBool)){
368  }
369  } else
370  if ((Ch=='"')||(Ch=='\'')){
371  if (IsUniStr){Sym=syStr;} else {Sym=syQStr;}
372  Str.Clr(); UcStr.Clr(); QuoteP=true; QuoteCh=Ch;
373  GetCh();
374  forever{
375  while ((Ch!=QuoteCh)&&(Ch!='\\')&&(Ch!=TCh::EofCh)){
376  Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
377  if (Ch==TCh::EofCh){
378  Sym=syUndef; break;
379  } else if (Ch==QuoteCh){
380  GetCh(); break;
381  } else {
382  GetCh();
383  switch (Ch){
384  case '"': Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
385  case '\\': Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
386  case '\'': Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
387  case '/': Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
388  case 'b': Str.AddCh('\b'); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
389  case 'f': Str.AddCh('\f'); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
390  case 'n': Str.AddCh('\n'); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
391  case 'r': Str.AddCh('\r'); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
392  case 't': Str.AddCh('\t'); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh(); break;
393  case 'u': {
394  // unicode character, represented using 4 hexadecimal digits
395  GetCh(); EAssertR(TCh::IsHex(Ch), "Invalid hexadecimal digit in unicode escape");
396  int UChCd = TCh::GetHex(Ch);
397  GetCh(); EAssertR(TCh::IsHex(Ch), "Invalid hexadecimal digit in unicode escape");
398  UChCd = 16 * UChCd + TCh::GetHex(Ch);
399  GetCh(); EAssertR(TCh::IsHex(Ch), "Invalid hexadecimal digit in unicode escape");
400  UChCd = 16 * UChCd + TCh::GetHex(Ch);
401  GetCh(); EAssertR(TCh::IsHex(Ch), "Invalid hexadecimal digit in unicode escape");
402  UChCd = 16 * UChCd + TCh::GetHex(Ch);
403  // get as UTF8 encoded characters
404  TUnicode::EncodeUtf8(UChCd, Str);
405  TUnicode::EncodeUtf8(UChCd, UcStr); }
406  GetCh(); break;
407  default: Sym=syUndef; break;
408  }
409  if (Sym==syUndef){
410  throw PExcept(new TExcept("Invalid Escape Sequence in Quoted String"));}
411  }
412  }
413  } else
414  if ((ChDef->IsNum(Ch))||(IsSigNum&&((Ch=='+')||(Ch=='-')))){
415  Str.Clr(); bool IntP=true;
416  do {Str.AddCh(Ch);} while (ChDef->IsNum(GetCh()));
417  if (Expect.In(syFlt)){
418  if (Ch=='.'){
419  Str.AddCh(Ch); IntP=false;
420  while (ChDef->IsNum(GetCh())){Str.AddCh(Ch);}
421  }
422  if ((Ch=='e')||(Ch=='E')){
423  Str.AddCh(Ch); GetCh(); IntP=false;
424  if ((Ch=='+')||(Ch=='-')){Str.AddCh(Ch); GetCh();}
425  while (ChDef->IsNum(Ch)){Str.AddCh(Ch); GetCh();}
426  }
427  }
428  UcStr=Str;
429  if (IntP&&(Expect.In(syInt))){
430  Sym=syInt; Int=atoi(Str.CStr());
431  } else {
432  Sym=syFlt; Flt=atof(Str.CStr());
433  }
434  } else
435  if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
436  Sym=syEoln;
437  if (Ch==TCh::CrCh){if (GetCh()==TCh::LfCh){GetCh();}} else
438  if (Ch==TCh::LfCh){if (GetCh()==TCh::CrCh){GetCh();}}
439  LnN++; LnChN=0; if (!IsRetEoln){GetSym(Expect);}
440  } else
441  if (Ch=='/'){
442  GetCh();
443  if ((IsCmtAlw)&&(Ch=='/')){
444  TChA _CmtStr;
445  do {_CmtStr+=GetCh();} while (!ChDef->IsTerm(Ch));
446  _CmtStr.Pop(); _CmtStr.Trunc();
447  if (Ch==TCh::CrCh){
448  if (GetCh()==TCh::LfCh){GetCh();}
449  } else
450  if (Ch==TCh::LfCh){
451  if (GetCh()==TCh::CrCh){GetCh();}
452  }
453  if (IsRetEoln){Sym=syEoln;} else {GetSym(Expect);}
454  CmtStr=_CmtStr;
455  } else
456  if (Ch=='*'){
457  TChA _CmtStr;
458  do {
459  while (GetCh()!='*'){_CmtStr+=Ch;}
460  _CmtStr+=GetCh();
461  } while (Ch!='/');
462  _CmtStr.Pop(); _CmtStr.Pop(); _CmtStr.Trunc();
463  GetCh(); GetSym(Expect);
464  CmtStr=_CmtStr;
465  } else {
466  Sym=sySlash;
467  }
468  } else
469  if (Ch==TCh::EofCh){
470  Sym=syEof;
471  } else {
472  switch (Ch){
473  case '.':
474  if (GetCh()=='.'){Sym=syDPeriod; GetCh();}
475  else {Sym=syPeriod;} break;
476  case ',': Sym=syComma; GetCh(); break;
477  case ':':
478  if (GetCh()==':'){Sym=syDColon; GetCh();}
479  else {Sym=syColon;} break;
480  case ';': Sym=sySemicolon; GetCh(); break;
481  case '+': Sym=syPlus; GetCh(); break;
482  case '-': Sym=syMinus; GetCh(); break;
483  case '*': Sym=syAsterisk; GetCh(); break;
484  case '/': Sym=sySlash; GetCh(); break;
485  case '%': Sym=syPercent; GetCh(); break;
486  case '!': Sym=syExclamation; GetCh(); break;
487  case '|': Sym=syVBar; GetCh(); break;
488  case '&': Sym=syAmpersand; GetCh(); break;
489  case '=': Sym=syEq; GetCh(); break;
490  case '<':
491  GetCh();
492  if (Ch=='='){Sym=syLEq; GetCh();}
493  else if (Ch=='>'){Sym=syNEq; GetCh();}
494  else {Sym=syLss;} break;
495  case '>':
496  if (GetCh()=='='){Sym=syGEq; GetCh();}
497  else {Sym=syGtr;} break;
498  case '?': Sym=syQuestion; GetCh(); break;
499  case '#':
500  if (IsCmtAlw){
501  TChA _CmtStr;
502  do {_CmtStr+=GetCh();} while (!ChDef->IsTerm(Ch));
503  _CmtStr.Pop(); _CmtStr.Trunc();
504  if (Ch==TCh::CrCh){
505  if (GetCh()==TCh::LfCh){GetCh();}
506  } else
507  if (Ch==TCh::LfCh){
508  if (GetCh()==TCh::CrCh){GetCh();}
509  }
510  if (IsRetEoln){Sym=syEoln;} else {GetSym(Expect);}
511  CmtStr=_CmtStr;
512  } else {
513  Sym=syHash; GetCh();
514  }
515  break;
516  case '(': Sym=syLParen; GetCh(); break;
517  case ')': Sym=syRParen; GetCh(); break;
518  case '[': Sym=syLBracket; GetCh(); break;
519  case ']': Sym=syRBracket; GetCh(); break;
520  case '{': Sym=syLBrace; GetCh(); break;
521  case '}': Sym=syRBrace; GetCh(); break;
522  default: Sym=syUndef; GetCh(); break;
523  }
524  }
525  }
526 
527  if ((!Expect.In(Sym))&&(!Expect.Empty())){
528  if (IsExcept){
529  TStr MsgStr=
530  TStr("Unexpected symbol (")+GetSymStr()+") ["+GetFPosStr()+"]";
531  throw PExcept(new TExcept(MsgStr));
532  } else {
533  Fail;
534  }
535  }
536  return Sym;
537 }
538 
539 TStr TILx::GetStrToCh(const char& ToCh){
540  Sym=syStr; Str.Clr(); UcStr.Clr();
541  while ((Ch!=ToCh)&&(Ch!=TCh::EofCh)){
542  Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
543  return Str;
544 }
545 
546 TStr TILx::GetStrToEolnOrCh(const char& ToCh){
547  Sym=syStr; Str.Clr(); UcStr.Clr();
548  while ((Ch!=ToCh)&&(Ch!=TCh::CrCh)&&(Ch!=TCh::LfCh)&&(Ch!=TCh::EofCh)){
549  Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
550  return Str;
551 }
552 
553 TStr TILx::GetStrToEoln(const bool& DoTrunc){
554  Sym=syStr; Str.Clr(); UcStr.Clr();
555  while ((Ch!=TCh::CrCh)&&(Ch!=TCh::LfCh)&&(Ch!=TCh::EofCh)){
556  Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
557  if (DoTrunc){Str.ToTrunc(); UcStr.ToTrunc();}
558  return Str;
559 }
560 
561 TStr TILx::GetStrToEolnAndCh(const char& ToCh){
562  Sym=syStr; Str.Clr(); UcStr.Clr();
563  if (IsBof()){GetCh();}
564  forever {
565  if (Ch==TCh::EofCh){break;}
566  if (((ChN==0)||(PrevCh==TCh::CrCh)||(PrevCh==TCh::LfCh))&&(Ch==ToCh)){
567  GetCh(); break;}
568  else {Str.AddCh(Ch); UcStr.AddCh(ChDef->GetUc(Ch)); GetCh();}
569  }
570  return Str;
571 }
572 
574  while ((Ch!=TCh::CrCh)&&(Ch!=TCh::LfCh)&&(Ch!=TCh::EofCh)){
575  GetCh();}
576  if (Ch==TCh::CrCh){if (GetCh()==TCh::LfCh){GetCh();}} else
577  if (Ch==TCh::LfCh){if (GetCh()==TCh::CrCh){GetCh();}}
578 }
579 
580 TLxSym TILx::PeekSym(const int& Syms){
581  TILxSymSt CurSymSt(*this);
582  TSStack<TILxSymSt> SymStStack;
583  for (int SymN=0; SymN<Syms; SymN++){
584  GetSym(); SymStStack.Push(TILxSymSt(*this));}
585  TLxSym PeekedSym=Sym;
586  while (!SymStStack.Empty()){
587  SymStStack.Top().Restore(*this); SymStStack.Pop();
588  PutSym();
589  }
590  CurSymSt.Restore(*this);
591  return PeekedSym;
592 }
593 
595  switch (Sym){
596  case syInt: return Str;
597  case syFlt: return Str;
598  case syStr: return Str;
599  case syIdStr: return Str;
600  case syQStr: return Str;
601  default:
602  if ((syMnRw<=Sym)&&(Sym<=syMxRw)){return Str;}
603  else {return TLxSymStr::GetSymStr(Sym);}
604  }
605 }
606 
608  TChA ChA;
609  ChA+="File:"; ChA+=SIn->GetSNm();
610  ChA+=" Line:"; ChA+=TInt::GetStr(LnN+1);
611  ChA+=" Char:"; ChA+=TInt::GetStr(LnChN);
612  return ChA;
613 }
614 
615 TStr TILx::GetQStr(const TStr& Str, const bool& QuoteP, const char& QuoteCh){
616  if (QuoteP){
617  TChA ChA;
618  ChA+=QuoteCh;
619  int StrLen=Str.Len();
620  for (int ChN=0; ChN<StrLen; ChN++){
621  char Ch=Str.CStr()[ChN];
622  if (Ch==QuoteCh){ChA+=QuoteCh; ChA+=QuoteCh;}
623  else {ChA+=Ch;}
624  }
625  ChA+=QuoteCh;
626  return ChA;
627  } else {
628  return Str;
629  }
630 }
631 
632 void TILx::GetVarBoolV(const TStr& VarNm, TBoolV& BoolV, const bool& NewLn){
633  BoolV.Clr();
634  GetVar(VarNm, true, NewLn);
635  while (GetSym(syRBracket, syBool)==syQStr){
636  BoolV.Add(Bool); if (NewLn){GetEoln();}}
637  if (NewLn){GetEoln();}
638 }
639 
640 void TILx::GetVarIntV(const TStr& VarNm, TIntV& IntV, const bool& NewLn){
641  IntV.Clr();
642  GetVar(VarNm, true, NewLn);
643  while (GetSym(syRBracket, syInt)==syInt){
644  IntV.Add(Int); if (NewLn){GetEoln();}}
645  if (NewLn){GetEoln();}
646 }
647 
648 void TILx::GetVarFltV(const TStr& VarNm, TFltV& FltV, const bool& NewLn){
649  FltV.Clr();
650  GetVar(VarNm, true, NewLn);
651  while (GetSym(syRBracket, syFlt)==syFlt){
652  FltV.Add(Flt); if (NewLn){GetEoln();}}
653  if (NewLn){GetEoln();}
654 }
655 
656 void TILx::GetVarStrV(const TStr& VarNm, TStrV& StrV, const bool& NewLn){
657  StrV.Clr();
658  GetVar(VarNm, true, NewLn);
659  while (GetSym(syRBracket, syQStr)==syQStr){
660  StrV.Add(Str); if (NewLn){GetEoln();}}
661  if (NewLn){GetEoln();}
662 }
663 
664 void TILx::GetVarStrPrV(const TStr& VarNm, TStrPrV& StrPrV, const bool& NewLn){
665  StrPrV.Clr();
666  GetVar(VarNm, true, NewLn);
668  TStr Str1=GetQStr(); TStr Str2=GetQStr();
670  StrPrV.Add(TStrPr(Str1, Str2)); if (NewLn){GetEoln();}
671  }
672  if (NewLn){GetEoln();}
673 }
674 
675 void TILx::GetVarStrVV(const TStr& VarNm, TVec<TStrV>& StrVV, const bool& NewLn){
676  StrVV.Clr();
677  GetVar(VarNm, true, NewLn);
679  StrVV.Add();
680  while (GetSym(syQStr, syRBracket)==syQStr){
681  StrVV.Last().Add(Str);}
682  if (NewLn){GetEoln();}
683  }
684  if (NewLn){GetEoln();}
685 }
686 
687 void TILx::GetLnV(const TStr& FNm, TStrV& LnV){
688  TFIn SIn(FNm); LnV.Clr(); TChA Ln;
689  if (!SIn.Eof()){
690  char Ch=SIn.GetCh();
691  while (!SIn.Eof()){
692  if ((Ch==TCh::CrCh)||(Ch==TCh::LfCh)){
693  if (!SIn.Eof()){
694  char PrevCh=Ch; Ch=SIn.GetCh();
695  if (!SIn.Eof()){
696  if (PrevCh==TCh::CrCh){if (Ch==TCh::LfCh){Ch=SIn.GetCh();}} else
697  if (PrevCh==TCh::LfCh){if (Ch==TCh::CrCh){Ch=SIn.GetCh();}}
698  }
699  }
700  LnV.Add(Ln); Ln.Clr();
701  } else {
702  Ln+=Ch; Ch=SIn.GetCh();
703  }
704  }
705  if (!Ln.Empty()){
706  LnV.Add(Ln);}
707  }
708 }
709 
711 // Lexical-Output
712 void TOLx::PutSep(const TLxSym& Sym){
713  if (TLxSymStr::IsSep(PrevSym, Sym)){
714  if (IsTabSep){RSOut.PutCh(TCh::TabCh);} else {RSOut.PutCh(' ');}}
715  PrevSym=Sym;
716 }
717 
718 TOLx::TOLx(const PSOut& _SOut, const TFSet& OptSet, const TLxChDefTy& ChDefTy):
719  ChDef(TLxChDef::GetChDef(ChDefTy)), SOut(_SOut), RSOut(*SOut),
720  IsCmtAlw(false), IsFrcEoln(false), IsSigNum(false),
721  IsUniStr(false), IsCsSens(false), IsTabSep(false), IsVarIndent(false),
722  VarIndentLev(0),
723  RwStrH(50), RwSymH(50), PrevSym(syUndef){
724  for (int Opt=0; Opt<oloMx; Opt++){
725  if (OptSet.In(Opt)){SetOpt(Opt, true);}}
726 }
727 
728 void TOLx::SetOpt(const int& Opt, const bool& Val){
729  switch (Opt){
730  case oloCmtAlw: IsCmtAlw=Val; break;
731  case oloFrcEoln: IsFrcEoln=Val; break;
732  case oloSigNum: IsSigNum=Val; break;
733  case oloUniStr: IsUniStr=Val; break;
734  case oloCsSens: IsCsSens=Val; break;
735  case oloTabSep: IsTabSep=Val; break;
736  case oloVarIndent: IsVarIndent=Val; break;
737  default: Fail;
738  }
739 }
740 
741 TLxSym TOLx::AddRw(const TStr& Str){
743  TStr UcStr=ChDef->GetUcStr(Str);
744  IAssert(!RwStrH.IsKey(UcStr));
745  TLxSym RwSym=TLxSym(syMnRw+RwStrH.Len());
746  RwStrH.AddDat(Str, TInt(int(RwSym)));
747  RwSymH.AddDat(TInt(int(RwSym)), Str);
748  return RwSym;
749 }
750 
751 void TOLx::PutSym(const TLxSym& Sym){
752  TStr Str;
753  if ((syMnRw<=Sym)&&(Sym<=syMxRw)){
754  Str=Str=RwSymH[Sym];
755  } else {
756  Str=TLxSymStr::GetSymStr(Sym);
757  }
758  PutSep(Sym); RSOut.PutStr(Str);
759 }
760 
761 void TOLx::PutVarBoolV(const TStr& VarNm, const TBoolV& BoolV,
762  const bool& NewLn, const bool& CheckIdStr){
763  PutVar(VarNm, true, NewLn, CheckIdStr);
764  for (int BoolN=0; BoolN<BoolV.Len(); BoolN++){
766  PutBool(BoolV[BoolN]);
767  if (NewLn){PutLn();}
768  }
769  PutVarEnd(true, NewLn);
770 }
771 
772 void TOLx::PutVarIntV(const TStr& VarNm, const TIntV& IntV,
773  const bool& NewLn, const bool& CheckIdStr){
774  PutVar(VarNm, true, NewLn, CheckIdStr);
775  for (int IntN=0; IntN<IntV.Len(); IntN++){
777  PutInt(IntV[IntN]);
778  if (NewLn){PutLn();}
779  }
780  PutVarEnd(true, NewLn);
781 }
782 
783 void TOLx::PutVarFltV(const TStr& VarNm, const TFltV& FltV,
784  const bool& NewLn, const bool& CheckIdStr){
785  PutVar(VarNm, true, NewLn, CheckIdStr);
786  for (int FltN=0; FltN<FltV.Len(); FltN++){
788  PutFlt(FltV[FltN]);
789  if (NewLn){PutLn();}
790  }
791  PutVarEnd(true, NewLn);
792 }
793 
794 void TOLx::PutVarStrV(const TStr& VarNm, const TStrV& StrV,
795  const bool& NewLn, const bool& CheckIdStr){
796  PutVar(VarNm, true, NewLn, CheckIdStr);
797  for (int StrN=0; StrN<StrV.Len(); StrN++){
799  PutQStr(StrV[StrN]);
800  if (NewLn){PutLn();}
801  }
802  PutVarEnd(true, NewLn);
803 }
804 
805 void TOLx::PutVarStrPrV(const TStr& VarNm, const TStrPrV& StrPrV,
806  const bool& NewLn, const bool& CheckIdStr){
807  PutVar(VarNm, true, NewLn, CheckIdStr);
808  for (int StrPrN=0; StrPrN<StrPrV.Len(); StrPrN++){
811  PutQStr(StrPrV[StrPrN].Val1); PutQStr(StrPrV[StrPrN].Val2);
813  if (NewLn){PutLn();}
814  }
815  PutVarEnd(true, NewLn);
816 }
817 
818 void TOLx::PutVarStrVV(const TStr& VarNm, const TVec<TStrV>& StrVV,
819  const bool& NewLn, const bool& CheckIdStr){
820  PutVar(VarNm, true, NewLn, CheckIdStr);
821  for (int StrVN=0; StrVN<StrVV.Len(); StrVN++){
824  for (int StrN=0; StrN<StrVV[StrVN].Len(); StrN++){
825  PutQStr(StrVV[StrVN][StrN]);}
827  if (NewLn){PutLn();}
828  }
829  PutVarEnd(true, NewLn);
830 }
831 
833 // Preprocessor
835  Assert(Ch!=TCh::EofCh);
836  PrevCh=Ch;
837  Ch=((SIn->Eof()) ? TCh::EofCh : SIn->GetCh());
838  //putchar(Ch);
839  return Ch;
840 }
841 
842 bool TPreproc::IsSubstId(const TStr& SubstId, TStr& SubstValStr) const {
843  if (SubstIdToKeyIdValPrVH.IsKey(SubstId)){
844  const TStrPrV& KeyIdValPrV=SubstIdToKeyIdValPrVH.GetDat(SubstId);
845  for (int KeyN=0; KeyN<KeyIdValPrV.Len(); KeyN++){
846  if (SubstKeyIdV.IsIn(KeyIdValPrV[KeyN].Val1)){
847  SubstValStr=KeyIdValPrV[KeyN].Val2;
848  return true;
849  }
850  }
851  return false;
852  } else {
853  return false;
854  }
855 }
856 
857 TPreproc::TPreproc(const TStr& InFNm, const TStr& OutFNm,
858  const TStr& SubstFNm, const TStrV& _SubstKeyIdV):
859  SIn(), SubstKeyIdV(_SubstKeyIdV),
860  PrevCh('\0'), Ch('\0'){
861  // load substitution file
862  if (!SubstFNm.Empty()){
863  PXmlDoc XmlDoc=TXmlDoc::LoadTxt(SubstFNm);
864  // get list of substitutions
865  TXmlTokV SubstTokV; XmlDoc->GetTok()->GetTagTokV("Subst", SubstTokV);
866  for (int SubstTokN=0; SubstTokN<SubstTokV.Len(); SubstTokN++){
867  PXmlTok SubstTok=SubstTokV[SubstTokN];
868  // get substitution-id
869  TStr SubstId=SubstTok->GetArgVal("Id", "");
870  if (!SubstId.Empty()){
871  // create substitution
872  TStrPrV& KeyIdValPrV=SubstIdToKeyIdValPrVH.AddDat(SubstId);
873  // get list of substitution-strings
874  TXmlTokV StrTokV; SubstTok->GetTagTokV("Str", StrTokV);
875  for (int StrTokN=0; StrTokN<StrTokV.Len(); StrTokN++){
876  PXmlTok StrTok=StrTokV[StrTokN];
877  // get key-value pair
878  TStr KeyId=StrTok->GetArgVal("Key", "");
879  TStr ValStr=StrTok->GetTokStr(false);
880  // assign key-value-pair
881  if (!KeyId.Empty()){
882  KeyIdValPrV.Add(TStrPr(KeyId, ValStr));
883  }
884  }
885  }
886  }
887  }
888  // substitution
889  // open files
890  SIn=TFIn::New(InFNm);
891  PSOut SOut=TFOut::New(OutFNm);
892  // set copy & ignore mode
893  bool CopyModeP=false; bool IgnoreModeP=false;
894  GetCh();
895  while (Ch!=TCh::EofCh){
896  if (isalpha(Ch)||(((PrevCh=='\0')||(PrevCh=='\r')||(PrevCh=='\n'))&&(Ch=='#'))){
897  // collect identifier
898  TChA IdChA;
899  do {
900  IdChA+=Ch; GetCh();
901  } while ((Ch!=TCh::EofCh)&&(isalnum(Ch)));
902  // check identifier
903  if (IdChA=="#ifdef"){
904  // collect condition-key-id
905  TChA CondKeyIdChA;
906  while ((Ch!=TCh::EofCh)&&(Ch!='\n')&&(Ch!='\r')){
907  CondKeyIdChA+=Ch; GetCh();}
908  // skip eoln
909  if (Ch=='\n'){GetCh(); if (Ch=='\r'){GetCh();}}
910  else if (Ch=='\r'){GetCh(); if (Ch=='\n'){GetCh();}}
911  // check for key
912  CondKeyIdChA.Trunc();
913  IAssert(CopyModeP==false);
914  IAssert(IgnoreModeP==false);
915  if (SubstKeyIdV.IsIn(CondKeyIdChA)){
916  CopyModeP=true; IgnoreModeP=false;
917  } else {
918  CopyModeP=false; IgnoreModeP=true;
919  }
920  } else
921  if (IdChA=="#endif"){
922  // move to eoln
923  while ((Ch!=TCh::EofCh)&&(Ch!='\n')&&(Ch!='\r')){
924  GetCh();}
925  // skip eoln
926  if (Ch=='\n'){GetCh(); if (Ch=='\r'){GetCh();}}
927  else if (Ch=='\r'){GetCh(); if (Ch=='\n'){GetCh();}}
928  // reset copy&ignore modes
929  IAssert(CopyModeP||IgnoreModeP);
930  CopyModeP=false; IgnoreModeP=false;
931  } else {
932  // substitution or add id-as-seen
933  TStr SubstValStr;
934  if ((!CopyModeP)&&(IsSubstId(IdChA, SubstValStr))){
935  if (!IgnoreModeP){SOut->PutStr(SubstValStr);}
936  } else {
937  if (!IgnoreModeP){SOut->PutStr(IdChA);}
938  }
939  }
940  } else {
941  // single character
942  if (!IgnoreModeP){SOut->PutCh(Ch);}
943  GetCh();
944  }
945  }
946 }
947 
#define IAssert(Cond)
Definition: bd.h:262
static bool IsHex(const char &Ch)
Definition: dt.h:1070
char Ch
Definition: lx.h:134
void PutLn(const int &IndentLev=0)
Definition: lx.h:302
TLxChDef(const TLxChDefTy &ChDefTy)
Definition: lx.cpp:13
Definition: lx.h:248
Definition: lx.h:49
Definition: lx.h:49
Definition: lx.h:127
Definition: lx.h:50
bool IsTabSep
Definition: lx.h:257
Definition: lx.h:6
bool Empty()
Definition: ds.h:2591
bool IsCsSens
Definition: lx.h:138
int SymLnN
Definition: lx.h:152
static const TStr QuestionStr
Definition: lx.h:81
TStr GetStr() const
Definition: dt.h:1200
TILx(const PSIn &_SIn, const TFSet &OptSet=TFSet(), const TLxChDefTy &ChDefTy=lcdtUsAscii)
Definition: lx.cpp:270
static PSOut New(const TStr &FNm, const bool &Append=false)
Definition: fl.cpp:442
int Len() const
Definition: dt.h:490
Definition: lx.h:53
bool IsAlNum(const char &Ch) const
Definition: lx.h:30
static PLxChDef New(const TLxChDefTy &ChDefTy=lcdtUsAscii)
Definition: lx.h:16
bool IsSubstId(const TStr &SubstId, TStr &SubstValStr) const
Definition: lx.cpp:842
void GetVarIntV(const TStr &VarNm, TIntV &IntV, const bool &NewLn=true)
Definition: lx.cpp:640
void PutVarStrPrV(const TStr &VarNm, const TStrPrV &StrPrV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:805
Definition: lx.h:45
char PrevCh
Definition: lx.h:364
TStr GetStrToEoln(const bool &DoTrunc=false)
Definition: lx.cpp:553
TPt< TExcept > PExcept
Definition: bd.h:198
TPair< TStr, TStr > TStrPr
Definition: ds.h:107
TLxChTy
Definition: lx.h:5
virtual int PutCh(const char &Ch)=0
void GetEoln()
Definition: lx.h:189
static const TStr CommaStr
Definition: lx.h:69
void PutVar(const TStr &VarNm, const bool &LBracket=false, const bool &NewLn=false, const bool &CheckIdStr=true)
Definition: lx.h:309
Definition: lx.h:50
Definition: lx.h:5
void PutSym()
Definition: lx.h:199
Definition: lx.h:49
Definition: lx.h:45
TStr GetSymStr() const
Definition: lx.cpp:594
bool IsIn(const TVal &Val) const
Checks whether element Val is a member of the vector.
Definition: ds.h:828
bool IsUniStr
Definition: lx.h:256
bool Empty() const
Definition: bits.h:145
#define forever
Definition: bd.h:6
void PutBool(const TBool &Bool)
Definition: lx.h:275
TStrIntH RwStrH
Definition: lx.h:137
Definition: lx.h:48
static const TStr DPeriodStr
Definition: lx.h:68
TVal & Top()
Definition: ds.h:2595
Definition: lx.h:46
void SkipToEoln()
Definition: lx.cpp:573
int Int
Definition: lx.h:111
bool Empty() const
Definition: dt.h:260
bool IsTabSep
Definition: lx.h:139
#define Fail
Definition: bd.h:238
bool IsSpace(const char &Ch) const
Definition: lx.h:27
bool Empty() const
Definition: bd.h:501
static const TStr EofStr
Definition: lx.h:96
static const TStr ColonStr
Definition: lx.h:70
TStrV SubstKeyIdV
Definition: lx.h:363
bool IsList
Definition: lx.h:139
TLxSym
Definition: lx.h:44
void Clr()
Definition: dt.h:258
Definition: lx.h:45
void AddCh(const char &Ch, const int &MxLen=-1)
Definition: dt.h:271
bool IsAlpha(const char &Ch) const
Definition: lx.h:28
Definition: lx.h:48
Definition: bits.h:119
Definition: lx.h:47
Definition: lx.h:5
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int VarIndentLev
Definition: lx.h:258
TStr GetStrToEolnOrCh(const char &ToCh)
Definition: lx.cpp:546
void PutInt(const TInt &Int)
Definition: lx.h:277
bool Empty() const
Definition: hash.h:227
void GetVarStrV(const TStr &VarNm, TStrV &StrV, const bool &NewLn=true)
Definition: lx.cpp:656
Definition: lx.h:51
static int GetHex(const char &Ch)
Definition: dt.h:1072
void PutVarBoolV(const TStr &VarNm, const TBoolV &BoolV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:761
Definition: lx.h:45
int ChN
Definition: lx.h:135
void GetVar(const TStr &VarNm, const bool &LBracket=false, const bool &NewLn=false)
Definition: lx.h:209
Definition: lx.h:52
Definition: lx.h:45
PLxChDef ChDef
Definition: lx.h:253
bool IsRetEoln
Definition: lx.h:138
void PutSep(const TLxSym &Sym)
Definition: lx.cpp:712
void Restore(TILx &Lx)
Definition: lx.cpp:262
void GetVarFltV(const TStr &VarNm, TFltV &FltV, const bool &NewLn=true)
Definition: lx.cpp:648
void PutSym(const TLxSym &Sym)
Definition: lx.cpp:751
Definition: lx.h:5
TLxSym AddRw(const TStr &Str)
Definition: lx.cpp:741
void PutQStr(const TStr &Str)
Definition: lx.h:289
Definition: lx.h:47
bool QuoteP
Definition: lx.h:153
Definition: lx.h:126
void SetOpt(const int &Opt, const bool &Val)
Definition: lx.cpp:286
bool IsFrcEoln
Definition: lx.h:256
Definition: lx.h:49
Definition: fl.h:275
TLxSym AddRw(const TStr &Str)
Definition: lx.cpp:300
static const TStr PercentStr
Definition: lx.h:77
static const TStr PlusStr
Definition: lx.h:73
TLxChDefTy
Definition: lx.h:6
char GetUc(const char &Ch) const
Definition: lx.h:32
TLxSym Sym
Definition: lx.h:149
void PutIndent(const int &IndentLev)
Definition: lx.h:299
TStr Str
Definition: lx.h:110
TOLx(const PSOut &_SOut, const TFSet &OptSet, const TLxChDefTy &ChDefTy=lcdtUsAscii)
Definition: lx.cpp:718
static bool GetValFromStr(const TStr &Str)
Definition: dt.cpp:1850
char QuoteCh
Definition: lx.h:154
static bool IsSep(const TLxSym &PrevSym, const TLxSym &Sym)
Definition: lx.cpp:226
Definition: lx.h:126
TSOut & RSOut
Definition: lx.h:255
TStr GetTokStr(const bool &XmlP=true) const
Definition: xml.h:316
Definition: lx.h:126
TILxSymSt()
Definition: lx.cpp:244
static const char EofCh
Definition: dt.h:1040
static const char Mx
Definition: dt.h:1033
Definition: lx.h:107
static const TStr IntStr
Definition: lx.h:62
void SetOpt(const int &Opt, const bool &Val)
Definition: lx.cpp:728
void PutVarStrVV(const TStr &VarNm, const TVec< TStrV > &StrVV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:818
Definition: lx.h:50
TChA UcStr
Definition: lx.h:150
double Flt
Definition: lx.h:111
static PSIn New(const TStr &FNm)
Definition: fl.cpp:290
static void GetLnV(const TStr &FNm, TStrV &LnV)
Definition: lx.cpp:687
PSIn GetSIn(const char &SepCh)
Definition: lx.cpp:309
static const TStr HashStr
Definition: lx.h:82
TStr GetArgVal(const TStr &ArgNm) const
Definition: xml.h:273
int LnN
Definition: lx.h:135
Definition: lx.h:126
static const TStr QStrStr
Definition: lx.h:66
bool IsSigNum
Definition: lx.h:138
static const TStr VBarStr
Definition: lx.h:79
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
Definition: lx.h:45
Definition: lx.h:6
TStr GetStrToCh(const char &ToCh)
Definition: lx.cpp:539
TLxSym GetSym()
Definition: lx.h:171
static const TStr EqStr
Definition: lx.h:83
PSIn SIn
Definition: lx.h:132
char * CStr()
Definition: dt.h:255
virtual bool Eof()=0
Definition: lx.h:5
bool IsVarIndent
Definition: lx.h:257
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1229
Definition: dt.h:1028
static const char TabCh
Definition: dt.h:1037
static const char Mn
Definition: dt.h:1032
Definition: lx.h:47
TPreproc(const TStr &InFNm, const TStr &OutFNm, const TStr &SubstFNm, const TStrV &_SubstKeyIdV)
Definition: lx.cpp:857
char GetCh()
Definition: fl.h:302
Definition: lx.h:49
Definition: lx.h:51
Definition: lx.h:129
static const TStr SlashStr
Definition: lx.h:76
char PrevCh
Definition: lx.h:134
#define Assert(Cond)
Definition: bd.h:251
static const TStr LssStr
Definition: lx.h:85
bool IsUniStr
Definition: lx.h:138
static const TStr ExclamationStr
Definition: lx.h:78
void GetVarStrPrV(const TStr &VarNm, TStrPrV &StrPrV, const bool &NewLn=true)
Definition: lx.cpp:664
static const TStr RBraceStr
Definition: lx.h:94
bool IsExcept
Definition: lx.h:139
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:579
TIntV ChTyV
Definition: lx.h:10
TStr GetQStr(const TStr &QStr=TStr())
Definition: lx.h:187
bool Eof()
Definition: fl.h:298
bool IsSigNum
Definition: lx.h:256
static const TStr GtrStr
Definition: lx.h:86
static const TStr LBracketStr
Definition: lx.h:91
char GetCh()
Definition: lx.cpp:834
Definition: lx.h:50
static const TStr AsteriskStr
Definition: lx.h:75
bool IsNum(const char &Ch) const
Definition: lx.h:29
static const TStr FltStr
Definition: lx.h:63
char GetCh(const int &ChN) const
Definition: dt.h:486
bool IsCmtAlw
Definition: lx.h:138
void Trunc()
Definition: dt.cpp:420
void PutFlt(const TFlt &Flt, const int &Width=-1, const int &Prec=-1)
Definition: lx.h:280
Definition: lx.h:49
Definition: lx.h:45
TChA Str
Definition: lx.h:150
static const char LfCh
Definition: dt.h:1038
bool IsCmtAlw
Definition: lx.h:256
static const TStr LBraceStr
Definition: lx.h:93
Definition: dt.h:1137
Definition: lx.h:249
Definition: lx.h:248
TChV UcChV
Definition: lx.h:11
Definition: lx.h:8
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TSStack< TILxSymSt > PrevSymStStack
Definition: lx.h:136
Definition: lx.h:127
bool Bool
Definition: lx.h:151
Definition: lx.h:47
Definition: dt.h:201
int SymLnChN
Definition: lx.h:112
void Push()
Definition: ds.h:2597
Definition: ut.h:161
void GetVarStrVV(const TStr &VarNm, TVec< TStrV > &StrVV, const bool &NewLn=true)
Definition: lx.cpp:675
Definition: lx.h:48
TLxSym PeekSym()
Definition: lx.h:200
bool IsBof() const
Definition: lx.h:167
void SetChTy(const TLxChTy &ChTy, const TStr &Str)
Definition: lx.cpp:8
int SymLnChN
Definition: lx.h:152
char GetCh()
Definition: lx.h:140
static const TStr EolnStr
Definition: lx.h:95
static bool IsValStr(const TStr &Str)
Definition: dt.cpp:1842
static TLxSym GetSSym(const TStr &Str)
Definition: lx.cpp:186
static const TStr SemicolonStr
Definition: lx.h:72
Definition: lx.h:46
Definition: lx.h:50
int SymLnN
Definition: lx.h:112
void Pop()
Definition: ds.h:2599
static const TStr UndefStr
Definition: lx.h:58
Definition: dt.h:412
static const TStr NEqStr
Definition: lx.h:84
bool Empty() const
Definition: dt.h:491
static const TStr DColonStr
Definition: lx.h:71
int LnChN
Definition: lx.h:135
Definition: lx.h:249
int PutStr(const char *CStr)
Definition: fl.cpp:117
void GetTagTokV(const TStr &TagPath, TXmlTokV &XmlTokV) const
Definition: xml.cpp:1158
bool IsTerm(const char &Ch) const
Definition: lx.h:26
TLxSym PrevSym
Definition: lx.h:261
PSIn SIn
Definition: lx.h:362
static const TStr LEqStr
Definition: lx.h:87
TIntStrH RwSymH
Definition: lx.h:260
static const char CrCh
Definition: dt.h:1039
void SetUcCh(const TStr &Str)
Definition: lx.cpp:3
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
static TStr GetSymStr(const TLxSym &Sym)
Definition: lx.cpp:142
Definition: lx.h:46
static PXmlDoc LoadTxt(TXmlLx &Lx)
Definition: xml.cpp:1401
static const TStr LnStr
Definition: lx.h:59
PLxChDef ChDef
Definition: lx.h:131
void GetVarBoolV(const TStr &VarNm, TBoolV &BoolV, const bool &NewLn=true)
Definition: lx.cpp:632
static const TStr StrStr
Definition: lx.h:64
virtual TStr GetSNm() const
Definition: fl.cpp:20
static const TStr IdStrStr
Definition: lx.h:65
int Int
Definition: lx.h:151
void PutVarEnd(const bool &RBracket=false, const bool &NewLn=false)
Definition: lx.h:315
bool IsCsSens
Definition: lx.h:257
TStr GetStrToEolnAndCh(const char &ToCh)
Definition: lx.cpp:561
Definition: lx.h:47
int SymChN
Definition: lx.h:152
bool Bool
Definition: lx.h:111
TStr UcStr
Definition: lx.h:110
Definition: lx.h:46
TStr GetUcStr(const TStr &Str) const
Definition: lx.cpp:71
Definition: lx.h:5
Definition: lx.h:248
Definition: lx.h:45
char Ch
Definition: lx.h:364
int SymChN
Definition: lx.h:112
static PLxChDef GetChDef(const TLxChDefTy &ChDefTy=lcdtUsAscii)
Definition: lx.cpp:79
static const TStr PeriodStr
Definition: lx.h:67
virtual char GetCh()=0
THash< TStr, TStrPrV > SubstIdToKeyIdValPrVH
Definition: lx.h:365
int EncodeUtf8(const TIntV &src, TIntV &dest) const
Definition: unicode.h:1792
TStr GetFPosStr() const
Definition: lx.cpp:607
Definition: lx.h:127
static const TStr MinusStr
Definition: lx.h:74
Definition: lx.h:248
static const TStr GEqStr
Definition: lx.h:88
TLxSym Sym
Definition: lx.h:109
static const TStr RBracketStr
Definition: lx.h:92
TChA & ToTrunc()
Definition: dt.cpp:568
char * CStr()
Definition: dt.h:479
char Pop()
Definition: dt.h:265
bool IsKey(const TKey &Key) const
Definition: hash.h:258
Definition: lx.h:46
Definition: lx.h:45
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TChA CmtStr
Definition: lx.h:150
Definition: lx.h:249
bool IsNmStr(const TStr &Str) const
Definition: lx.cpp:63
static const TStr TabStr
Definition: lx.h:60
int Len() const
Definition: hash.h:228
Definition: lx.h:46
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
Definition: lx.h:48
Definition: lx.h:50
void PutVarIntV(const TStr &VarNm, const TIntV &IntV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:772
double Flt
Definition: lx.h:151
void PutVarStrV(const TStr &VarNm, const TStrV &StrV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:794
static const TStr LParenStr
Definition: lx.h:89
static const TStr RParenStr
Definition: lx.h:90
TStr CmtStr
Definition: lx.h:110
void PutVarFltV(const TStr &VarNm, const TFltV &FltV, const bool &NewLn=true, const bool &CheckIdStr=true)
Definition: lx.cpp:783
Definition: lx.h:127
Definition: lx.h:126
static const TStr AmpersandStr
Definition: lx.h:80
TStrIntH RwStrH
Definition: lx.h:259
bool In(const int &FlagN) const
Definition: bits.h:156