Ejemplo n.º 1
0
 public void ReadFile()
 {
     Lexer lexer = new Lexer();
     Parser parser = new Parser();
     var lines = GetFileTextLinesAsync().ToList();
     List<Block> block = new List<Block>();
     for (int i = 0; i < lines.Count; i++)
     {
         var tokenList = lexer.ReadLine(lines[i], i);
         foreach (var item in tokenList)
         {
             do
             {
                 parser.Push(item);
             } while (parser.IsLoopingForReduce);
             if (parser.IsAccepted)
             {
                 block.Add(parser.Block);
                 parser.Reset();
                 if (block[block.Count - 1].BlockType == BlockTypes.SETTINGS)
                 /// ACC will not push current item,
                 /// it will cause error
                 {
                     parser.Push(item);
                 }
             }
         }
     }
     Block = block.ToArray();
 }
Ejemplo n.º 2
0
        private IEnumerable<Block> ReadLines(IList<string> lines)
        {
            List<Block> block = new List<Block>();
            Lexer lexer = new Lexer();
            Parser parser = new Parser();
            for (int i = 0; i < lines.Count; i++)
            {
                var tokenList = lexer.ReadLine(lines[i], i);
                foreach (var item in tokenList)
                {
                    do
                    {
                        parser.Push(item);
                    } while (parser.IsLoopingForReduce);
                    if (parser.IsAccepted)
                    {
                        block.Add(parser.Block);
                        parser.Reset();
                        if (block[block.Count-1].BlockType == BlockTypes.SETTINGS)
                        /// ACC will not push current item,
                        /// it will cause error 
                        {
                            parser.Push(item);
                        }
                    }

                }
            }
            return block;
        }