EOF() 공개 메소드

public EOF ( ) : bool
리턴 bool
예제 #1
0
파일: tok.cs 프로젝트: ydunk/masters
/* get an identifier */
        public void scan()
        {
            skipWhite();
            if (Char.IsLetter(io.getNextChar()))
            {
                LoadName();
            }
            else if (Char.IsDigit(io.getNextChar()))
            {
                LoadNum();
            }
            else if (isOp(io.getNextChar()))
            {
                LoadOp();
            }
            else if (io.EOF())
            {
                value    = null;
                token_id = T_EOF;
            }
            else
            {
                value = new StringBuilder(MyC.MAXSTR);
                value.Append(io.getNextChar());
                token_id = T_UNKNOWN;
                io.ReadChar();
            }
            skipWhite();
#if DEBUG
            Console.WriteLine("[tok.scan tok=[" + this + "]");
#endif
        }
예제 #2
0
/*
 * parse the outerBlock seperately from inner block.
 * specifically parse the declarations at the beginning of an outerblock
 * the variable r tracks if the last statement was a return or not
 */
        void blockOuter(String olabel, String ilabel)
        {
            bool r = false;

#if DEBUG
            Console.WriteLine("blockOuter1 token=[" + tok + "]\n");
#endif
            CommentToken(); /* mark the position in insn stream */
            tok.scan();
#if DEBUG
            Console.WriteLine("blockOuter2 token=[" + tok + "]\n");
#endif
            declInner();
            emit.LocalVars(localvar);

            while (tok.getFirstChar() != '}')
            {
#if DEBUG
                Console.WriteLine("blockOuter3 token=[" + tok + "]\n");
#endif
                if (io.EOF())
                {
                    io.Abort("Expected statement, end of file encountered");
                }
                r = false;
                switch (tok.getId())
                {
                case Tok.T_IF: fcIf(olabel, ilabel); continue; /* fcIf updates tok */

                case Tok.T_WHILE: fcWhile(); break;

                case Tok.T_FOR: fcFor(); break;

                case Tok.T_BREAK: fcBreak(olabel); break;

                case Tok.T_CONTINUE: fcContinue(ilabel); break;

                case Tok.T_RETURN: fcReturn(); r = true; break;

                default: statement(); break;
                }
#if DEBUG
                Console.WriteLine("blockOuter4 token=[" + tok + "]\n");
#endif
            }
            if (!r)                                  /* if no outerscope return specified, try to default */
            {
                Var e = emit.GetFunc();              /* get function def */
                if (e.getTypeId() != Tok.T_VOID)     /* make sure we can default to void */
                {
                    if (!e.getName().Equals("main")) /* is it not main? */
                    {
                        io.Abort("No return value specified for non void function");
                    }
                    emit.LoadConst("0"); /* special case a dummy ret value */
                }
                emit.Ret();
            }
            CommentToken(); /* mark the position in insn stream */
            tok.scan();     /* read beyond end of block */
#if DEBUG
            Console.WriteLine("blockOuter5 token=[" + tok + "]\n");
#endif
        }