private static int seekProcBodies(int i, ref List <Token> ts, string F, ref int L)
        {
            int oldL = L;
            int oldI = i;

            while (i < ts.Count)
            {
                if (ts[i].Type == TknType.Operator && ts[i].Text == Syntax.OP_BEGIN)
                {
                    return(i);
                }

                if (ts[i].Type == TknType.Word && Syntax.IsKeyWord(ts[i].Text))
                {
                    if (ts[i].Text != Syntax.KW_PROCESS)
                    {
                        new CompileException(F, L, ErrCode.BadTokenArea, ts[i].Text);
                    }
                    else
                    {
                        new CompileException(F, oldL, ErrCode.ProcBodyNotFound);
                    }
                }

                if (ts[i].Type == TknType.FilePtr)
                {
                    new CompileException(F, inLine(ref ts, oldI), ErrCode.ProcBodyNotFound);
                }

                if (ts[i].Type != TknType.Word && ts[i].Type != TknType.NewLine)
                {
                    new CompileException(F, L, ErrCode.BadTokenArea, ts[i].Text);
                }

                L += ts[i].Type == TknType.NewLine ? 1 : 0;

                i++;
            }

            new CompileException(F, oldL, ErrCode.ProcBodyNotFound);

            return(-1);
        }
 private static bool isKeyWordOrProcName(Token t)
 {
     return(t.Type == TknType.Word && (Syntax.IsKeyWord(t.Text) || defProcs.Contains(t.Text)));
 }
        private static void seekProcDefs(ref List <Token> ts)
        {
            defProcs = new List <string>();

            int    L   = 1;
            string F   = "[not found]";
            int    lvl = 0;

            for (int i = 0; i < ts.Count; i++)
            {
                if (Syntax.IsTokenHasKeyWord(ts[i], Syntax.KW_PROCESS))
                {
                    if (lvl != 0)
                    {
                        new CompileException(F, L, ErrCode.ProcInProc);
                    }

                    i++;
                    if (ts[i].Type != TknType.Word)
                    {
                        new CompileException(F, L, ErrCode.ProcNameNotFound);
                    }

                    if (!Syntax.IsKeyWord(ts[i].Text))
                    {
                        addUniqueProcName(ts[i].Text);
                    }
                    else
                    {
                        new CompileException(F, L, ErrCode.KeyProc, ts[i].Text);
                    }
                    //skip args...
                    i = seekProcBodies(i, ref ts, F, ref L);
                }
                else
                {
                    if (ts[i].Type != TknType.FilePtr && ts[i].Type != TknType.NewLine && lvl == 0)
                    {
                        new CompileException(F, L, ErrCode.BadTokenArea, ts[i].Text);
                    }
                }

                if (ts[i].Type == TknType.Operator)
                {
                    if (ts[i].Text == Syntax.OP_BEGIN)
                    {
                        lvl++;
                    }
                    if (ts[i].Text == Syntax.OP_END)
                    {
                        lvl--;
                    }
                }

                if (ts[i].Type == TknType.FilePtr)
                {
                    F = ts[i].Text;
                    L = 1;
                }

                L += ts[i].Type == TknType.NewLine ? 1 : 0;
            }
        }