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); }
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); }
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); }
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); }
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); }
public override bool OnVar(ScriptLine line, string name) { var op = string.Empty; line.Skip(" \t"); if (!line.GetOperator(ref op, "=+-*/%")) { //if (!op[0]) return true; //Error("OnVar1: !op [{0}] ", op); //return false; return(true); } CODE code = 0; if (op.Equals("=")) { code = CODE.CODE_MOV; } else if (op.Equals("+=")) { code = CODE.CODE_ADD; } else if (op.Equals("-=")) { code = CODE.CODE_SUB; } else if (op.Equals("*=")) { code = CODE.CODE_MUL; } else if (op.Equals("/=")) { code = CODE.CODE_DIV; } else if (op.Equals("++")) { code = CODE.CODE_INC; } else if (op.Equals("--")) { code = CODE.CODE_DEC; } else if (op.Equals("%=")) { code = CODE.CODE_MOD; } else { Error("OnVar2: [{0}] operator error1", op); return(false); } WriteCode(code); WriteVar(name); if (code == CODE.CODE_INC || code == CODE.CODE_DEC) { return(true); } if (!Value(line)) { Error("{0} OnVar: !Value(line)", name); return(false); } return(true); }