4 DEBUG_TOKEN_MANAGER=false;
8 PARSER_BEGIN(ESFParser)
12 import org.lwes.util.Log;
14 public class ESFParser
16 private String currentEvent;
17 private EventTemplateDB eventTemplateDB;
19 public void setEventTemplateDB(EventTemplateDB DB)
20 { eventTemplateDB = DB; }
22 public EventTemplateDB getEventTemplateDB()
23 { return eventTemplateDB; }
25 public void setCurrentEvent(String evt)
26 { currentEvent = evt; }
28 public String getCurrentEvent()
29 { return currentEvent; }
40 | "#" : IN_LINE_COMMENT
43 <IN_LINE_COMMENT> SKIP:
50 <IN_LINE_COMMENT> MORE:
58 < ID: ["a"-"z","A"-"Z","_",":","0"-"9"] (["a"-"z","A"-"Z","_",":","0"-"9"])* >
70 event() ( event() )* <EOF>
80 eventName() "{" [ attributeList() ] "}"
84 * The name of an event, should be max 256 chars ([a-zA-Z0-9_]*)
93 if ( getEventTemplateDB().addEvent(t.image))
95 setCurrentEvent(t.image);
99 throw new ParseException("Problem adding event "+t.image);
104 void attributeList() :
107 attribute() ( attribute() )*
117 return Integer.parseInt(t.image);
128 aType=type() anAttribute=attributeName() [ "[" anArraySize = arraySize() "]" ] ";" {
129 if ( !( aType.equals("uint16") ||
130 aType.equals("int16") ||
131 aType.equals("uint32") ||
132 aType.equals("int32") ||
133 aType.equals("string") ||
134 aType.equals("ip_addr") ||
135 aType.equals("int64") ||
136 aType.equals("uint64") ||
137 aType.equals("byte") ||
138 aType.equals("boolean")
142 throw new ParseException("No such type '"+aType+"'");
145 String evt = getCurrentEvent();
146 if ( evt == null ) throw new ParseException("Bad Event");
148 if (anArraySize > 0) {
149 if (Log.isLogTrace()) {
150 Log.trace("ARRAY! type: "+aType+" attr: "+anAttribute+" size: "+anArraySize);
155 if ( !getEventTemplateDB().addEventAttribute(evt, anAttribute, aType, anArraySize))
157 throw new ParseException("Problem adding attribute "+evt+"("
158 +aType+","+anAttribute+")");
174 String attributeName() :