public bool CodeFunc(ref TokenData ret) { ushort func = 0; if (!GetWord(ref func)) { Error("CodeFunc : GetWordError1"); return(false); } Deque <TokenData> parm = new Deque <TokenData>(); while (true) { TokenData data = new TokenData(); byte type = 0; if (!GetByte(ref type)) { Error("CodeFunc : GetByteError1"); return(false); } if (Convert.ToChar(type) == ';') { break; } var s = StringFunctions.StrChr("snfv?", Convert.ToChar(type)); if (string.IsNullOrEmpty(s)) { Error("CodeFunc: %c !strchr(\"snfv?\", type)", type); return(false); } if (!ReadValue(ref data)) { Error("CodeFunc: ReadValue(data)"); return(false); } switch (Convert.ToChar(type)) { case 's': data.SetType(TokenData.TokenDataType.STR); break; case 'n': data.SetType(TokenData.TokenDataType.NUM); break; case 'f': break; } parm.AddToBack(data); } bool ret1 = m_handler.OnFunc(func, parm, ref ret); return(ret1); }
internal bool Load(string fName, int verDate) { Clear(); int date; var content = File.ReadAllLines(fName, Encoding.GetEncoding(1252)); if (content.Length == 0) { return(true); } var firstLine = content[0]; if (verDate != 0) { if (firstLine != verDate.ToString()) { //return false; } } if (verDate != 0) { // version 날짜 있는경우 그건 빼고 계산한다. //fseek(fp, 8, SEEK_CUR); // XXXXXXXX(XXXX년XX월XX일) //m_bufSize -= 8; foreach (var line in content.Skip(1)) { m_line.AddToBack(line); } } else { foreach (var line in content) { m_line.AddToBack(line); } } RemoveComment(); return(true); }
public bool Run(string line, string reg) { m_phase.Clear(); Stack <string> phase = new Stack <string>(); int flag = 0; int depth = 0; int regPos = 0; string cur = ""; foreach (var pc in line) { if (flag != 0) { if (pc == '"') { flag = 0; } cur += pc; } else { switch (pc) { case '"': cur += pc; flag = 1; break; case '(': cur += " "; cur += string.Format("{0}{1}", reg, regPos); phase.Push(cur); cur = string.Format("{0}{1}=", reg, regPos); regPos++; depth++; break; case ')': if (depth <= 0) { return(false); } m_phase.AddToBack(cur); cur = phase.Peek(); phase.Pop(); depth--; break; default: cur += pc; break; } } } m_phase.AddToBack(cur); if (depth != 0) { return(false); } return(true); }