コード例 #1
0
ファイル: Edge.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// Passes an edge into the edge object
        /// </summary>
        /// <param name="T">Tokeniser to use</param>
        /// <returns></returns>
        public bool parseElement(Tokeniser T)
        {
            assertToken(T, Tokeniser.TokenType.T_Edge, "Edge expected");
            labelExpected(T, "name");
            T.getNextToken();
            name = T.getToken_string();
            labelExpected(T, "fromNodeName");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_String, "String expected");
            fromNodeName = T.getToken_string();

            labelExpected(T, "toNodeName");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_String, "String expected");
            toNodeName = T.getToken_string();

            T.getNextToken();
            if (T.getToken_string().Equals("hFromPortNumber"))
            {
                T.getNextToken();
                assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
                hFromPortNumber = T.getLongValue();
                T.getNextToken();
            }

            return(true);
        }
コード例 #2
0
 /// <summary>Expect a label in the input stream</summary>
 /// <param name="T"></param>
 /// <param name="labelName"></param>
 public void labelExpected(Tokeniser T, String labelName)
 {
     T.getNextToken();
     assertToken(T, Tokeniser.TokenType.T_Label, "A label starting with '// " +
                 labelName + "' expected.  Found '" + T.getToken_string() + "'.");
     System.Diagnostics.Debug.Assert(T.getToken_string().Equals(labelName),
                                     "// " + labelName + " expected. Found '" + T.getToken_string() + "'.");
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
        internal bool parseElement(Tokeniser T)
        {
            assertToken(T, Tokeniser.TokenType.T_Node, "Node expected");
            labelExpected(T, "name");
            T.getNextToken();
            name = T.getToken_string();
            labelExpected(T, "x");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
            x = T.getLongValue();
            labelExpected(T, "y");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
            y = T.getLongValue();
            labelExpected(T, "width");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
            width = T.getLongValue();
            labelExpected(T, "height");
            T.getNextToken();
            assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
            height = T.getLongValue();
            // optional fields
            T.getNextToken();
            if (T.getToken_string().Equals("numberOfInPorts"))
            {
                T.getNextToken();
                assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
                T.getLongValue();                  // read outPorts
                T.getNextToken();
            }

            if (T.getToken_string().Equals("numberOfOutPorts"))
            {
                T.getNextToken();
                assertToken(T, Tokeniser.TokenType.T_Number, "Number expected");
                T.getLongValue();                  // read outPorts
                T.getNextToken();
            }

            if (T.getToken_string().Equals("Editor Node"))
            {
                // longNode=true;
                T.getNextToken();                  // Ignore version
                T.getNextToken();                  // Get node text
                editorText = T.getToken_string();
                T.getNextToken();                  // Some object data e.g Reason.MapperViewFactory3#CNodeViewReason2 9
                T.getNextToken();                  // some hex number e.g. 0x0
                T.getNextToken();                  // some hex number e.g. 0xcaffca
                T.getNextToken();                  // some integer number e.g. 1
                T.getNextToken();                  // some hex number and space delimited information
                T.getNextToken();                  // Version 1.1 Info
                if (T.getToken_string().Equals("Version 1.1 Info"))
                {
                    T.getNextToken();                      // Get comment if there
                    CommentText = T.getToken_string();
                    T.getNextToken();
                }
            }
            return(true);
        }