Abraham.DLXChecker.DFirst C# (CSharp) Method

DFirst() private method

private DFirst ( ) : void
return void
        void DFirst()
        {
            bool find_dot = false;
            bool got_data = false;
            //首先查找第一行有效代码,看是否是.data
            while (cur_token != 0 && !find_dot)
            {
                switch (cur_token)
                {
                    case ';':
                        C();
                        continue;
                    case ' ':
                    case '\t':
                        skip_space();
                        continue;
                    case '\n':
                        AppendContent();
                        get_src_token();
                        continue;
                    case '\r':
                        get_src_token();//ignore '\r', as each sentence end with "\n\r" in windows
                        continue;
                    default:
                        if (cur_token != '.')
                        {
                            error("第一行有效代码必须是.data!");
                        }
                        else
                        {
                            get_src_token();
                            find_dot = true;
                        }
                        break;

                }
            }
            if (cur_token != 0)
            {
                string word = get_word();
                if (word.ToUpper() != "DATA")
                {
                    error("第一行有效代码必须是.data!");
                }
                got_data = true;
                skip_space();
                format_line.Append(AppendSpace()).Append(".DATA");
                bool user_address = true;
                int d_base = -1;
                try
                {
                    string num_word = get_number_word();
                    d_base = parse_number_32(num_word);
                    format_line.AppendFormat("\t{0}", num_word);
                }
                catch (DLXException)
                {
                    //用户没有自定义初始地址,删除上面代码抛出的异常
                    delete_last_error();
                    user_address = false;
                }
                if (user_address && d_base % 4 != 0)
                    error("data段初始地址必须为4的倍数");
            }
            else//文件尾部检查
            {
                if (!got_data)
                {
                    error("第一行有效代码必须是.data!");
                }
                if(format_line.Length >0 || src_line.Length >0)
                    AppendContent();
            }
        }