我有一个像这样的大型结构化语言文件:
TASK SchM_Task {
TYPE = AUTO;
SCHEDULE = NON;
PRIORITY = 160;
ACTIVATION = 1;
TIMING_PROTECTION = FALSE;
AUTOSTART = FALSE;
EVENT = SchM_Event;
RESOURCE = SystemS_Resource;
StackSize = 1024;
NotUsingSchedule = FALSE;
}: "BSW task for calling of bsw runnables";
ALARM SchM_Alarm {
COUNTER = SystemTimer;
ACTION = SETEVENT
{
TASK = SchM_Task;
EVENT = SchM_Event;
};
AUTOSTART = FALSE
{
StaticAlarm = FALSE;
};
};
RESOURCE SystemS_Resource {
RESOURCEPROPERTY = INTERNAL;
}: "Via this resource the cooperativ behavior can be set";
EVENT SchM_Event {
MASK = AUTO;
};
ISR CanIsr_1 {
CATEGORY = 2;
TIMING_PROTECTION = FALSE;
EnableNesting = TRUE;
InterruptLevel = 30;
InterruptSource = CAN1IRQ;
StackSize = 1024;
UseSpecialFunctionName = FALSE;
}: "CAN Send/Receive (main CAN)";
我对python和脚本真的很陌生。如何使用 python 将此文本文件解析为 AST。在网上搜索时,我发现 python 中的 grako 可能是一个选项。您能否解释一下 grako 如何使用示例代码工作。提前谢谢。