grammar org.myfirewall.MyFirewall with org.eclipse.xtext.common.Terminals generate myFirewall "http://www.myfirewall.org/MyFirewall" Model: scripts+=Script*; Script: 'script' name=STRING '{' 'interfaces internal' ifInternal=ID 'external' ifExternal=ID ';' hosts+=HostAlias* networks+=NetworkAlias* services+=ServiceDefinition* ('allow incoming {' incomingRules+=Rule+ '}')? ('allow outgoing {' outgoingRules+=Rule+ '}')? '}'; IPAddress: byte1=INT '.' byte2=INT '.' byte3=INT '.' byte4=INT; enum Protocol: TCP='tcp' | UDP='udp'; HostAlias: 'host' name=ID '=' ip=IPAddress ';'; NetworkAlias: 'net' name=ID '=' ip=IPAddress '/' cidrSuffix=INT ';'; Endpoint: ('host' host=[HostAlias]) | ('net' network=[NetworkAlias]); ServiceDefinition: 'service' name=ID '=' ('proto' (protocols+=Protocol | '(' protocols+=Protocol (',' protocols+=Protocol)+ ')'))? ('port' (ports+=INT | '(' ports+=INT (',' ports+=INT)+ ')'))? ';'; Rule: source=Endpoint 'to' destination=Endpoint ':' services+=[ServiceDefinition] (',' services+=[ServiceDefinition])* ';';