1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| public void ADM_Handling(string FilePath)
{
int linenumber = 0;
int column = 0;
string ENDCATEGORY = "(?si:END(\\s)*CATEGORY)";
string ENDPOLICY = "(?si:END(\\s)*POLICY)";
string KEYNAME = "(?si:"(\w+\\[\w]+)*")";
string STRINGS = @"(?mi:^[.*\])";
string description = "(?si:^=\".*\\w+)\"$";
string words = @"(?s-i:\w+)";
string others= "(?si:[^A-Za-z0-9_ \f\t\v\r])";
if (File.Exists(FilePath))
{
string ADM_Text = File.ReadAllText(FilePath);
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(words+ "|" + others + "|" + ENDCATEGORY + "|" + ENDPOLICY, System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Match m;
m = r.Match(ADM_Text);
while (m.Success & m.Index + m.Length < ADM_Text.Length + 1)
{
Token tok = new Token(m.Value, linenumber, column, m.Index, Free);
TList.Add(tok);
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("\\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Match regm;
regm = reg.Match(m.Value);
column = column + m.Value.Length;
if (regm.Success)
{
linenumber = linenumber + 1;
column = 0;
}
m = m.NextMatch();
}
Token tok2 = new Token("EOF", linenumber, 0, -1, false);
TList.Add(tok2);
pointerList = 0;
} |