Skip to content

Instantly share code, notes, and snippets.

@mzaks
Created July 15, 2011 21:02
Show Gist options
  • Save mzaks/1085541 to your computer and use it in GitHub Desktop.
Save mzaks/1085541 to your computer and use it in GitHub Desktop.
Xtext Petri Net definition
grammar de.bomzhi.petrinet.PetrinetDsl with org.eclipse.xtext.common.Terminals
generate petrinetDsl "http://www.bomzhi.de/petrinet/PetrinetDsl"
PetriNet:
(resources+=Resource)+
(places+=Place)+
(transactions+=Transaction)+
;
Resource:
'resource' name=ID;
Place:
'place' name=ID '{'
(storages+=Storage)*
'}'
;
Storage:
resourceRef=[Resource] ':' count=INT '/'(capacity=INT | '..')
;
Transaction:
'transaction' name=ID '{'
(assureStatements += AssureStatement)*
(takeStatements += TakeStatement)*
(putStatements += PutStatement)*
'}'
;
AssureStatement:
'assure' count=INT resourceRef = [Resource] 'in' placeRef=[Place]
;
TakeStatement:
'take' count=INT resourceRef = [Resource] 'from' placeRef=[Place]
;
PutStatement:
'put' count=INT resourceRef = [Resource] 'into' placeRef=[Place]
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment