EP RScript

This commit is contained in:
2025-10-13 19:39:36 +08:00
commit d42726a4dc
12 changed files with 977 additions and 0 deletions

20
Matcher/BackMatcher.cs Normal file
View File

@@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
namespace Convention.RScript.Matcher
{
public class BackMatcher : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
Regex LabelRegex = new(@"back\s*\(\s*(.+)\s*\)");
var LabelMatch = LabelRegex.Match(expression);
if (LabelMatch.Success)
{
sentence.mode = RScriptSentence.Mode.Backpoint;
sentence.content = LabelMatch.Groups[1].Value;
return true;
}
return false;
}
}
}

20
Matcher/BreakMatcher.cs Normal file
View File

@@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
namespace Convention.RScript.Matcher
{
public class BreakMatcher : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
Regex LabelRegex = new(@"break\s*\(\s*(.+)\s*\)");
var LabelMatch = LabelRegex.Match(expression);
if (LabelMatch.Success)
{
sentence.mode = RScriptSentence.Mode.Breakpoint;
sentence.content = LabelMatch.Groups[1].Value;
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
namespace Convention.RScript.Matcher
{
public class DefineVariableMatcher : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
Regex DefineVariableRegex = new(@"(string|int|double|float|bool|var)\s+([a-zA-Z_][a-zA-Z0-9_]*)");
var DefineVariableMatch = DefineVariableRegex.Match(expression);
if (DefineVariableMatch.Success)
{
sentence.mode = RScriptSentence.Mode.DefineVariable;
sentence.info = new() { DefineVariableMatch.Groups[1].Value, DefineVariableMatch.Groups[2].Value };
return true;
}
return false;
}
}
}

22
Matcher/GotoMatcher.cs Normal file
View File

@@ -0,0 +1,22 @@
using System.Text.RegularExpressions;
namespace Convention.RScript.Matcher
{
public class GotoMatcher : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
Regex GotoRegex = new(@"goto\s*\(\s*(.+)\s*,\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\)");
var GotoMatch = GotoRegex.Match(expression);
if (GotoMatch.Success)
{
sentence.mode = RScriptSentence.Mode.Goto;
sentence.content = GotoMatch.Groups[2].Value;
sentence.info = new() { GotoMatch.Groups[1].Value, GotoMatch.Groups[2].Value };
return true;
}
return false;
}
}
}

20
Matcher/LabelMatcher.cs Normal file
View File

@@ -0,0 +1,20 @@
using System.Text.RegularExpressions;
namespace Convention.RScript.Matcher
{
public class LabelMatcher : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
Regex LabelRegex = new(@"label\s*\(\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\)");
var LabelMatch = LabelRegex.Match(expression);
if (LabelMatch.Success)
{
sentence.mode = RScriptSentence.Mode.Label;
sentence.content = LabelMatch.Groups[1].Value;
return true;
}
return false;
}
}
}

20
Matcher/NamespaceMater.cs Normal file
View File

@@ -0,0 +1,20 @@
namespace Convention.RScript.Matcher
{
public class NamespaceMater : IRSentenceMatcher
{
public bool Match(string expression, ref RScriptSentence sentence)
{
if (expression == "{")
{
sentence.mode = RScriptSentence.Mode.EnterNamespace;
return true;
}
else if (expression == "}")
{
sentence.mode = RScriptSentence.Mode.ExitNamespace;
return true;
}
return false;
}
}
}