【发布时间】:2009-04-23 15:54:24
【问题描述】:
我正在尝试从一个字符串中解析一个动态函数,例如:
char* func = "app.exe /path:\"@FileExists('filepath', @FileDelete('filepath'), @MsgBox('file not found','error',1))\";
我要解析
@FileExists('filepath', @FileDelete('filepath'), @MsgBox('file not found','error',1))
我该怎么做?
【问题讨论】:
-
“解析”是什么意思?当这一切结束时,你想以什么结束?解析树?令牌列表?你想基于这个执行一些东西吗?
-
是的,我想从文本中提取函数并执行
-
您需要更具体地确定您想要做什么。这些 @ 函数看起来像 Windows 脚本函数,在这种情况下,这可能是一个特定于 Windows 的问题,而不是(只是)一个 C++ 问题。
-
请看这个链接stackoverflow.com/questions/615040/writing-a-mini-language和stackoverflow.com/questions/391432/developing-a-simple-parser如何通过链接中的想法解析我的文字表达? @FileExists('','','') @FileDelete('') @MsgBox('','',0)