我有一个像这样的大型结构化语言文件:
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如何使用示例代码。谢谢。