示例#1
0
        //C++
        public void Parse(string code)
        {
            List <string> chunked   = code.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <string> processed = new List <string>();

            chunked.ForEach(chunk => processed.Add(chunk.TrimStart()));
            List <string> headerChunks   = processed[0].Split(' ').Where(chunk => chunk != "").ToList();
            string        varExpectation = processed[1].Trim();
            string        declarations   = processed[2].Trim();
            int           beginIndex     = processed.IndexOf("SHURU");
            int           endIndex       = processed.IndexOf("KHATAM");

            if (ProcessHeader(headerChunks))
            {
                if (LOADEDMEMORY.Process(varExpectation, CPP) && LOADEDMEMORY.Process(declarations, CPP))
                {
                    if (LOGICBEGIN.Process(processed[beginIndex], CPP) || LOGICEND.Process(processed[endIndex], CPP))
                    {
                        for (int i = beginIndex + 1; i < endIndex; i++)
                        {
                            if (LOGICBLOCK.Process(processed[i], CPP))
                            {
                            }
                            else
                            {
                                CPP.Clear();
                                Machine.OnStateProcessedFailed("Apki logic theek nahi hai chanda.");
                            }
                        }
                    }
                    else
                    {
                        CPP.Clear();
                        Machine.OnStateProcessedFailed("Ajeeb logic lagai hai.");
                    }
                }
                else
                {
                    CPP.Clear();
                    Machine.OnStateProcessedFailed("Declaration sahi karo.");
                }
            }
            else
            {
                CPP.Clear();
                Machine.OnStateProcessedFailed("Header code theek karo.");
            }
            CPP.Append("}");
            Machine.OnParseSuccessful();
        }
示例#2
0
 public override bool Process(string fragment, StringBuilder cpp)
 {
     Machine.OnStateProcessed(SYMBOL);
     return(S_STAT.Process(fragment, cpp));
 }