Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by Indra ( 14 years ago )
public class TTree
{
public string Str { get; set; }
public int Len { get; set; }
public string Rul { get; set; }
public byte number { get; set; }
public List<TTree> next { get; set; }
}
public class TRule
{
public string rule { get; set; }
public TRule next { get; set; }
public byte number { get; set; }
}
public class PRule
{
public char Ch { get; set; }
public int Len { get; set; }
public TRule PTRue { get; set; }
}
public class TAutomat
{
public char Cons { get; set; }
public int ind { get; set; }
public string chain { get; set; }
public Stack<int> stack { get; set; }
public int el { get; set; }
}
//Global
public List<PRule> index = new List<PRule>();
TTree head;
string Tree;
Boolean find;
int GetIn;
string Chain;
int count;
TAutomat raspoz;
string RulChain;
string Consists;
string st1;
//определяет терминальные символы
public Boolean term(char ch)
{
int i;
for (i = 0; i < index.Count(); i++)
{
if (ch == index[i].Ch)
{
GetIn = i;
return false;
}
}
return true;
}
// определяет количество термин. символов в строке
public int Len(string st)
{
int i, t;
t = 0;
for (i = 0; i < st.Length; i++)
if (term(st[i]))
t++;
return t;
}
//генерация цепочек
public TTree Rec(string st, TTree pp, int CouL, string rul)
{
int i, j;
string S1, S2;
Boolean find;
TRule p;
i = Len(st);
if (i > numericUpDown2.Value)
{
MessageBox.Show("длина больше допустимой", "Ошибка!");
return null;
}
if ((st.Length - i) > numericUpDown2.Value)
{
MessageBox.Show("длина больше допустимой", "Ошибка!");
return null;//Change messageBoxn null;
}
if (CouL > numericUpDown2.Value)
{
MessageBox.Show("длина больше допустимой", "Ошибка!");
return null;
}
find = false;
for (i = 0; i < st.Length; i++)
{
if (pp == null)
{
pp = new TTree();
pp.Str =st;
pp.Rul = rul;
pp.Len = 0;
return pp;
}
if(!term(st[i]))
{
find=true;
S1 = st.Substring(0,i-1);
S2 = st.Substring(i+1,st.Length);
p=index[GetIn].PTRue;
pp.Len = index[GetIn].Len;
}
}
return null;
}
Revise this Paste