Guest User

Untitled

a guest
Apr 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. public List<Chunk> ParseChunkList()
  2.         {
  3.             List<Chunk> chunks = new List<Chunk>();
  4.             if (!lex.AtBeginning && !lex.IsAt('{') && !lex.IsAt('}', -1))
  5.             {
  6.                 throw new Exception("precondition");
  7.             }
  8.             while (!lex.AtEnd)
  9.             {
  10.                 Chunk next;
  11.                 if (lex.IsAt('{'))
  12.                 {
  13.                     lex.Eat();
  14.                     lex.EatWhitespace();
  15.                 }
  16.                 if (lex.IsMatch(OPEN_FORMAT) || lex.IsMatch(OPEN_SCRIPT))
  17.                 {
  18.                     next = ParseTaggedChunk();
  19.                 }
  20.                 else
  21.                 {
  22.                     next = ParseTextChunk();
  23.                 }
  24.  
  25.                 if (next == null) throw new Exception();
  26.  
  27.                 chunks.Add(next);
  28.  
  29.                 if (lex.IsAt('}'))
  30.                 {
  31.                     lex.Eat();
  32.                     break;
  33.                 }
  34.             }
  35.  
  36.             if (!lex.IsAt(CLOSE_CURL, -1) && !lex.AtEnd)
  37.             {
  38.                 throw new Exception("postcondition");
  39.             }
  40.  
  41.             return chunks;
  42.         }
Add Comment
Please, Sign In to add comment