Exemplo n.º 1
0
 /// <summary>
 /// Expect a particular token in the input stream
 /// </summary>
 /// <param name="T"></param>
 /// <param name="token"></param>
 /// <param name="msg"></param>
 public void assertToken(Tokeniser T, Tokeniser.TokenType token, String msg)
 {
     if (T.getTokenType() == token)
     {
         return;
     }
     System.Diagnostics.Debug.Assert(false, T.getTokenType() + " token found," + token + " expected : " + msg);
 }
Exemplo n.º 2
0
 private bool readRE3(string fileName)
 {
     try
     {
         Tokeniser T = new Tokeniser(fileName);
         T.getNextToken();
         while (T.getTokenType() != Tokeniser.TokenType.T_Eof)
         {
             if (T.getTokenType() == Tokeniser.TokenType.T_Node)
             {
                 nodesLoaded++;
                 Node N = new Node();
                 elementList.Add(N);
                 N.parseElement(T);
             }
             // if (T.getTokenType() == Tokeniser.TokenType.T_Edges)
             //  ;
             if (T.getTokenType() == Tokeniser.TokenType.T_Edge)
             {
                 edgeCount++;
                 Edge E = new Edge();
                 elementList.Add(E);
                 E.parseElement(T);
             }
             if (T.getTokenType() != Tokeniser.TokenType.T_Edge & T.getTokenType() != Tokeniser.TokenType.T_Node)
             {
                 T.getNextToken();
             }
         }
         this.fileName = fileName;
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(
             String.Format("Error during re3 file read. {0}", e.Message));
         return(false);
     }
     if (nodesLoaded == 0)
     {
         System.Windows.Forms.MessageBox.Show(
             String.Format("No nodes found in {0}. Sure it is a Reason!able file?", fileName));
         return(false);
     }
     return(true);
 }