예제 #1
0
        public bool CmdDeclare(ScriptLine line)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }

            int isNum = 0;
            var func  = string.Empty;
            var parm  = string.Empty;
            var code  = string.Empty;
            var sp    = string.Empty;

            line.Skip(" \t");
            if (!line.GetWord(ref func, " \t"))
            {
                //		Error("함수 이름이 없습니다");
                Error("no func name");
                return(false);
            }

            line.Skip(" \t");
            if (!line.GetWord(ref parm, " \t"))
            {
                //		Error("파라미터 정보가 없습니다");
                Error("no parameter info");
                return(false);
            }

            line.Skip(" \t");
            if (!GetDefVar(line, ref code, ref isNum))
            {
                //		Error("함수 코드 부분에 문제가 있습니다");
                Error("there are problem func code part");
                return(false);
            }

            line.Skip(" \t");
            line.GetWord(ref sp, " \t");

            /*
             * if (isNum != 0)
             * {
             *  //		Error("함수 코드에는 숫자만 올수 있습니다");
             *  Error("just only number at func code");
             *  return false;
             * }*/

            m_tokenMap.Set(func, TOKENTYPE.TOKENTYPE_FUNC, int.Parse(code), parm);
            m_asm.Commentf("declare {0} {1} {2}", func, parm, code);

            if (sp.Equals("blockcheck"))
            {
                m_blockCheckMap[Convert.ToInt32(code)] = true;
                m_asm.Comment("block check func");
            }

            return(true);
        }
예제 #2
0
        public bool CmdVar(ScriptLine line)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }

            var var = string.Empty;

            line.Skip(" \t");
            if (!line.GetWord(ref var, "= \t"))
            {
                //Error("변수 이름이 없습니다");
                Error("no value name");
                return(false);
            }

            m_tokenMap.Set(var, TOKENTYPE.TOKENTYPE_VAR);
            if (!OnVar(line, var))
            {
                return(false);
            }
            m_asm.Commentf("int {0}", var);
            return(true);
        }
예제 #3
0
        public bool CmdDefine(ScriptLine line)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }
            var name  = string.Empty;
            var data  = string.Empty;
            int isNum = 0;

            line.Skip(" \t");
            if (!line.GetWord(ref name, " \t"))
            {
                //		Error("정의어 이름이 없습니다");
                Error("no define name");
                return(false);
            }

            line.Skip(" \t");
            if (line.GetParse(ref data, '"'))
            {
                isNum = 0;
            }
            else if (!GetDefVar(line, ref data, ref isNum))
            {
                //		Error("정의 선언 값 부분에 문제가 있습니다");
                Error("problem of define value");
                return(false);
            }

            m_tokenMap.Set(name, TOKENTYPE.TOKENTYPE_DEFINE, isNum, data);

            m_asm.Commentf("define {0} {1}", name, data);
            return(true);
        }
예제 #4
0
        public bool GetDefVar(ScriptLine line, ref string data, ref int isNum)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }

            if (!line.GetWord(ref data, " \t+-"))
            {
                //		Error("정의 또는 숫자 정보가 없습니다");
                Error("there are no define or number");
                return(false);
            }

            if (IsNum(data))
            {
                isNum = 1;
                return(true);
            }

            TokenInfo pTokenInfo;

            if (!m_tokenMap.Get(data, out pTokenInfo))
            {
                //		Error("%s 는 정의되지 않은 토큰입니다", data);
                Error("{0} - not defined token", data);
                return(false);
            }

            data  = pTokenInfo.str;
            isNum = pTokenInfo.num;
            var op = string.Empty;

            if (line.GetOperator(ref op, "+-"))
            {
                int n = Convert.ToInt32(data);
                if (op.Equals("++"))
                {
                    n++;
                }
                else if (op.Equals("--"))
                {
                    n--;
                }
                else
                {
                    //			Error("%s 는 사용될수 없는 정의 연산자입니다", op);
                    Error("%s can not use define operater", op);
                    return(false);
                }

                pTokenInfo.str = n.ToString();
            }

            return(true);
        }
예제 #5
0
        public bool CmdDefCmd(ScriptLine line)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }

            var name = string.Empty;
            var data = string.Empty;

            line.Skip(" \t");
            if (!line.GetWord(ref name, " \t"))
            {
                //		Error("정의될 명령어가 없습니다");
                Error("there are no define command");
                return(false);
            }

            line.Skip(" \t");
            if (!line.GetWord(ref data, " \t"))
            {
                //		Error("기본 명령어가 없습니다");
                Error("there are no base command");
                return(false);
            }

            TokenInfo pTokenInfo;

            if (!m_tokenMap.Get(data, out pTokenInfo))
            {
                //		Error("%s 라는 명령어는 존재하지 않습니다", data);
                Error("%s not exist", data);
                return(false);
            }

            m_tokenMap.Set(name, pTokenInfo.type, pTokenInfo.num, pTokenInfo.GetStr());
            return(true);
        }
예제 #6
0
        public bool Value(ScriptLine line, bool flag = true)
        {
            var data = string.Empty;
            var op   = string.Empty;

            while (true)
            {
                line.Skip(" \t[");
                if (line.GetParse(ref data, '"'))
                {
                    if (data.Length >= 250)
                    {
                        Error("Value: 250 strlen(data) >= 250 {0}", data);
                        return(false);
                    }
                    WriteStr(data);
                }
                else if (line.GetParse(ref data, '#'))
                {
                    TokenInfo tokenInfo;
                    if (!m_tokenMap.Get(data, out tokenInfo))
                    {
                        Error("Value: [{0}]  is not in a token map - GetParse", data);
                        return(false);
                    }
                    if (tokenInfo.num > 0)
                    {
                        WriteNum(Convert.ToInt32(tokenInfo.GetStr()));
                    }
                    else
                    {
                        WriteStr(tokenInfo.GetStr());
                    }
                }
                else if (line.GetWord(ref data, "%!=+-/*&|>< \t[],"))
                {
                    if (IsNum(data))
                    {
                        WriteNum(Convert.ToInt32(data));
                    }
                    else
                    {
                        TokenInfo tokenInfo;

                        if (!m_tokenMap.Get(data, out tokenInfo))
                        {
                            Error("Value: [{0}] is not in a token map - GetWord", data);
                            return(false);
                        }
                        switch (tokenInfo.type)
                        {
                        case TOKENTYPE.TOKENTYPE_VAR:
                            WriteVar(data);
                            break;

                        case TOKENTYPE.TOKENTYPE_DEFINE:
                            if (tokenInfo.num > 0)
                            {
                                WriteNum(Convert.ToInt32(tokenInfo.GetStr()));
                            }
                            else
                            {
                                WriteStr(tokenInfo.GetStr());
                            }
                            break;

                        case TOKENTYPE.TOKENTYPE_FUNC:
                            WriteCall(data);
                            if (!OnFunc(line, tokenInfo.num, tokenInfo.GetStr()))
                            {
                                Error("Value: Func not found");
                                return(false);
                            }
                            break;

                        default:
                        {
                            //						    Error("Value: %s 토큰은 사용될수 없습니다 line:%s", data, line.GetBase());
                            Error("Value: {0} tokenInfo->type not found line:{1}", data, line.GetBase());
                            return(false);
                        }
                        }
                    }
                }
                else
                {
                    //			if (flag) Error("Value:값이 없습니다 line:%s", line.GetBase());
                    return(false);
                }

                line.Skip(" \t,");
                if (!line.GetOperator(ref op, "%=+-/*&|><!"))
                {
                    break;
                }
                if (string.IsNullOrEmpty(op))
                {
                    break;
                }

                if (!WriteOp(op))
                {
                    Error("Value: write error!");
                    return(false);
                }
            }
            line.Skip("]");
            WriteOp(";");
            return(true);
        }