public bool AnalyzeLine(string str) { ScriptLine line = new ScriptLine(str); string word = new string(new char[STR_MAXLEN]); line.Skip(" \t"); if (!line.GetWord(ref word, " \t(=+-*/[")) { return(true); } TokenInfo tokenInfo; if (!m_tokenMap.Get(word, out tokenInfo)) { Error("AnalyzeLine - [{0}] is not a tokenMap", word); return(false); } if (tokenInfo.type == TOKENTYPE.TOKENTYPE_COMMAND) { if (!OnControl(line, tokenInfo.num)) { return(false); } } Parsing Parse = new Parsing(); if (!Parse.Run(line.GetBase(), "$")) { Error("(,) error type AnalyzeLine 1"); return(false); } for (int i = 0; i < Parse.GetNum(); i++) { var p = Parse.Get(i); if (!AnalyzeParse(ref p)) { return(false); } } return(true); }
public bool AnalyzeParse(ref string str) { ScriptLine line = new ScriptLine(str); string word = new string(new char[STR_MAXLEN]); line.Skip(" \t"); if (!line.GetWord(ref word, " \t(=+-*/%[")) { return(true); } TokenInfo tokenInfo = new TokenInfo(); if (!m_tokenMap.Get(word, out tokenInfo)) { if (word[0] != '$') { Error("AnalyzeParse - 1:[%s] is not in a tokenMap", word); return(false); } m_tokenMap.Set(word, TOKENTYPE.TOKENTYPE_VAR); if (!m_tokenMap.Get(word, out tokenInfo)) { Error("AnalyzeParse - 2:[%s] is not in a tokenMap", word); return(false); } } switch (tokenInfo.type) { case TOKENTYPE.TOKENTYPE_COMMAND: return(OnCommand(line, (CMD)tokenInfo.num)); case TOKENTYPE.TOKENTYPE_FUNC: return(OnFunc(line, tokenInfo.num, tokenInfo.str)); case TOKENTYPE.TOKENTYPE_VAR: return(OnVar(line, word)); } Error("[%s] token type not found", word, tokenInfo.type); return(false); }
public override bool OnFunc(ScriptLine line, int func, string parm) { if (!CheckSwitchBlock()) { return(false); } if (m_blockCheckMap.ContainsKey(func)) { if (!m_block.IsComplete()) { Error("위쪽 부분에 if 나 다중 선택문 블럭이 완성되지 않았습니다.\n __block 으로 확인하세요"); return(false); } } WriteCode(CODE.CODE_FUNC); WriteFunc((short)func); for (int i = 0; i < parm.Length; i++) { if (parm[i] == '.') { break; } if (parm[i] == 't') { var temp = string.Empty; line.Skip(" \t"); line.GetWord(ref temp, " \t"); continue; } //WriteType(parm[i]); bool flag; if (parm[i] == '?') { flag = false; } else { flag = true; } while (true) { WriteType(parm[i]); if (!Value(line, flag)) { if (flag) { Error("function parament error {0} [{1}]", parm, parm[i]); } else { WriteVar("NULL"); WriteOp(";"); break; } return(false); } if (flag) { break; } } } WriteType(';'); return(true); }