问题描述
您好,我目前正在使用基本的Sharp链接:https://github.com/Timu5/BasicSharp 这是基本的语言解释器。我们需要在此代码中使用合并字段,以将合并字段替换为值。
例如:
IF [Clients.Name] = "Patrick" THEN
#Do something
ENDIF
需要将合并字段设置为令牌,然后根据其类型来解析和替换其值。
因此上面的内容将被解析并替换为:
IF "Patrick" = "Patrick" THEN
#Do Something
ENDIF
任何帮助将不胜感激,如果有帮助的话,我可以在屏幕共享中详细介绍!
我尝试过的事情:
我尝试了解释器中的以下代码,因为它逐行解析。这是要求之一。由于可以在do while循环中使用它,因此数据库值可以更改:
void Line()
{
string lineText = GetLine();
// MessageBox.Show(lineText);
string regularExpressionPattern = @"\[.*?\]";
string inputText = lineText;
int intVal = 0;
double Double123 = 0.00;
Regex re = new Regex(regularExpressionPattern);
string finalvalue = "";
Run_Code rc = new Run_Code();
rc.case_ref = case_ref;
rc.CaseTypeIndex = CaseTypeIndex;
foreach (Match m in re.Matches(inputText))
{
inputText = inputText.Replace(m.Value,'"' + rc.getDBValue(m.Value.Replace("[","").Replace("]","")) + '"');
}
// skip empty new lines
while (lastToken == Token.NewLine) GetNextToken();
if (lastToken == Token.EOF)
{
exit = true;
return;
}
lineMarker = lex.TokenMarker; // save current line marker
Statment(); // evaluate statment
if (lastToken != Token.NewLine && lastToken != Token.EOF)
Error("Expect new line got " + Translatetoken(lastToken.ToString()));
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)