尝试新增命名空间的命名, 用于具有名称的块或是函数
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace Convention.RScript.Matcher
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Convention.RScript.Matcher
|
||||
{
|
||||
public class NamespaceMater : IRSentenceMatcher
|
||||
{
|
||||
@@ -14,6 +16,21 @@
|
||||
sentence.mode = RScriptSentence.Mode.ExitNamespace;
|
||||
return true;
|
||||
}
|
||||
else if (expression.StartsWith("namespace"))
|
||||
{
|
||||
sentence.mode = RScriptSentence.Mode.NamedSpace;
|
||||
Regex regex = new(@"namespace\s*\(([a-zA-Z_][a-zA-Z0-9_]*)\)");
|
||||
var match = regex.Match(expression);
|
||||
if (match.Success)
|
||||
{
|
||||
sentence.content = match.Groups[1].Value;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RScriptRuntimeException("Invalid namespace declaration", -1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user