Exemple #1
0
        private void readFile(string path)
        {
            string       line;
            StreamReader file = new StreamReader(path);

            while ((line = file.ReadLine()) != null)
            {
                StringTokenized ps = new StringTokenized(line);
                m_Lines.Add(ps);
            }
            file.Close();
        }
Exemple #2
0
 private bool passMatchBrackets(List <StringTokenized> lines)
 {
     m_Brackets = new List <BracketPair>();
     for (iLine = 0; iLine < lines.Count; iLine++)
     {
         bool            line_has_brackets = false;
         StringTokenized line = lines[iLine];
         for (int iToken = 0; iToken < line.Tokens.Count; iToken++)
         {
             Token token = line.Tokens[iToken];
             if (token.TokenType == TokenType.Bracket)
             {
                 if (line_has_brackets)
                 {
                     return(false);
                 }
                 line_has_brackets = true;
                 if (token.Value == "{")
                 {
                     m_Brackets.Add(new BracketPair(iLine, -1));
                 }
                 else if (token.Value == "}")
                 {
                     bool found_match = false;
                     for (int j = m_Brackets.Count - 1; j >= 0; j--)
                     {
                         if (m_Brackets[j].LineEnd == -1)
                         {
                             m_Brackets[j].Index   = Interpreter.NextIndex;
                             m_Brackets[j].LineEnd = iLine;
                             found_match           = true;
                             break;
                         }
                     }
                     if (!found_match)
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Exemple #3
0
 private bool passGetControlFlow(List <StringTokenized> lines)
 {
     m_ControlLines = new List <ControlLine>();
     for (iLine = 0; iLine < lines.Count; iLine++)
     {
         StringTokenized line = lines[iLine];
         if (line.Tokens.Count > 0 && line.Tokens[0].TokenType == TokenType.ControlFlow)
         {
             if (line.Tokens.Count == 1 && line.Tokens[0].Value == ".else")
             {
                 // automatically included
             }
             else
             {
                 if (line.Tokens.Count != 4)
                 {
                     return(false);
                 }
                 if ((line.Tokens[1].TokenType != TokenType.Register) &&
                     (line.Tokens[1].TokenType != TokenType.Variable))
                 {
                     return(false);
                 }
                 if (line.Tokens[2].TokenType != TokenType.Operator)
                 {
                     return(false);
                 }
                 if ((line.Tokens[3].TokenType != TokenType.Variable) &&
                     (line.Tokens[3].TokenType != TokenType.Indexed))
                 {
                     return(false);
                 }
             }
             m_ControlLines.Add(new ControlLine(iLine, line));
         }
     }
     return(true);
 }
Exemple #4
0
 public ControlLine(int index, StringTokenized line)
 {
     LineIndex = index;
     Line      = line;
 }