private void PopProc()
            {
                procs.Pop();

                if (procs.Count > 0)
                {
                    currentProc = procs.Peek();
                }
                else
                {
                    currentProc = null;
                }
            }
 private void PushStoreProc(int cnt)
 {
     currentProc = new AssemblerProcedure(cnt);
     procs.Push(currentProc);
     storedProcs.Add(currentProc);
 }
 private void PushExistingProc(int cnt)
 {
     currentProc = storedProcs.Where(p => p.ProcLineNumber == cnt).FirstOrDefault();
     procs.Push(currentProc);
 }
            public string ProcessContent()
            {
                storedSegments.Clear();
                storedProcs.Clear();
                segments.Clear();
                procs.Clear();
                currentProc    = null;
                currentSegment = null;

                Match  m;
                string line;

                StringBuilder sb = new StringBuilder();

                using (StringReader sr = new StringReader(content))
                {
                    int cnt = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        cnt++;

                        m = pushReg.Match(line);

                        if (m != null && m.Success && !string.IsNullOrWhiteSpace(m.Groups[1].Value))
                        {
                            PushNamespaceSegment(m.Groups[1].Value);
                            continue;
                        }

                        if (popReg.IsMatch(line))
                        {
                            PopNamespaceSegment();
                            continue;
                        }

                        if (procReg.IsMatch(line))
                        {
                            PushStoreProc(cnt);
                            continue;
                        }

                        if (endProcReg.IsMatch(line))
                        {
                            PopProc();
                            continue;
                        }

                        m = forcedNamespacelabelReg.Match(line);

                        if (m != null && m.Success && !string.IsNullOrWhiteSpace(m.Groups[1].Value))
                        {
                            var pathParts = m.Groups[1].Value.Split(".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                            string lastNamespace = pathParts[0];
                            string label         = pathParts.Last();
                            string path          = "." + string.Join(".", pathParts.Skip(1).Take(pathParts.Length - 2)) + ".";

                            if (path == "..")
                            {
                                path = "";
                            }

                            var namespaceSegment = storedSegments.Where(ss => ss.SegmentName == lastNamespace && ss.ParentPath == path).FirstOrDefault();

                            if (namespaceSegment == null)
                            {
                                namespaceSegment = new NamespaceSegment(path, lastNamespace);
                                storedSegments.Add(namespaceSegment);
                            }

                            namespaceSegment.AddLabel(label);
                        }

                        if (currentProc != null)
                        {
                            currentProc.ScanSentence(line);
                        }

                        if (currentSegment != null)
                        {
                            currentSegment.ScanSentence(line, procs);
                        }

                        if (line.Contains("__PRINT_INIT"))
                        {
                            line = line;
                        }
                    }
                }

                segments.Clear();
                procs.Clear();

                using (StringReader sr = new StringReader(content))
                {
                    int cnt = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        cnt++;

                        m = pushReg.Match(line);

                        if (m != null && m.Success && !string.IsNullOrWhiteSpace(m.Groups[1].Value))
                        {
                            PushNamespaceSegment(m.Groups[1].Value);
                            continue;
                        }

                        if (popReg.IsMatch(line))
                        {
                            PopNamespaceSegment();
                            continue;
                        }

                        if (procReg.IsMatch(line))
                        {
                            PushExistingProc(cnt);
                            sb.AppendLine(line);
                            continue;
                        }

                        if (endProcReg.IsMatch(line))
                        {
                            PopProc();
                            sb.AppendLine(line);
                            continue;
                        }

                        if (currentSegment != null)
                        {
                            line = currentSegment.ParseSentence(line, procs);
                        }

                        sb.AppendLine(line);
                    }
                }

                return(sb.ToString());
            }