There are few places in MIB sytax that allows comma separated list (we can even generalized it by some character delimited list), here is one snippet of rtc1213 mib file.
| RFC1213-MIB.mib |
IMPORTS
mgmt, NetworkAddress, IpAddress, Counter, Gauge,
TimeTicks
FROM RFC1155-SMI
OBJECT-TYPE
FROM RFC-1212;
|
For this I have used following parsing rules:
| Mib.xtext |
Import:
'IMPORTS' defs+=ImpDef+ ';';
ImpDef:
(objects+=Object ','?)+ 'FROM' def=ID;
Object:
name=ID;
|
I have noticed quite a few tutorial sites would write it as
| Mib.xtext |
Import:
'IMPORTS' defs+=ImpDef+ ';';
ImpDef:
objects+=Object (',' objects+=Object)* 'FROM' def=ID;
Object:
name=ID;
|
And they are right, my rule even thought looks simple but its not bullet proof; in fact it allows incorrect syntax - "mgmt NetworkAddress ...", I have fixed these occurrences through out my grammar file (6 places), next time when I add grammar snippet, you will noticed it of the updated version.
Thanks. Glad you liked it
ReplyDelete