grammar org.eclipse.viatra.solver.language.Problem with org.eclipse.xtext.common.Terminals import "http://www.eclipse.org/emf/2002/Ecore" as ecore import "http://www.eclipse.org/viatra/solver/language/model/Problem" Problem: ("problem" name=ID ".")? statements+=Statement*; Statement: ClassDeclaration | PredicateDefinition | Assertion | ScopeDeclaration; ClassDeclaration: abstract?="abstract"? "class" name=ID ("extends" superTypes+=[ClassDeclaration|QualifiedName] ("," superTypes+=[ClassDeclaration|QualifiedName])*)? ("{" (referenceDeclarations+=ReferenceDeclaration ";"?)* "}" | "."); ReferenceDeclaration: (containment?="contains" | "refers") referenceType=[ClassDeclaration|QualifiedName] ("[" multiplicity=Multiplicity "]")? name=ID ("opposite" opposite=[ReferenceDeclaration|QualifiedName])?; PredicateDefinition: (error?="error" "pred"? | "pred") name=ID "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" (":-" bodies+=Conjunction (";" bodies+=Conjunction)*)? "."; Parameter: parameterType=[ClassDeclaration] name=ID; Conjunction: literals+=Literal ("," literals+=Literal)*; Literal: Atom | NegativeLiteral; NegativeLiteral: "!" atom=Atom; Atom: relation=[Relation|QualifiedName] transitiveClosure?="+"? "(" (arguments+=Argument ("," arguments+=Argument)*)? ")"; Argument: variable=[Variable]; Assertion: (relation=[Relation|QualifiedName] "(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")" ":" value=LogicValue | value=ShortLogicValue? relation=[Relation|QualifiedName] "(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")") "."; enum LogicValue: TRUE="true" | FALSE="false" | UNKNOWN="unknown"; enum ShortLogicValue returns LogicValue: FALSE="!" | UNKNOWN="?"; ScopeDeclaration: "scope" typeScopes+=TypeScope ("," typeScopes+=TypeScope)* "."; TypeScope: targetType=[ClassDeclaration] (increment?="+=" | "=") multiplicity=DefiniteMultiplicity; Multiplicity: UnboundedMultiplicity | DefiniteMultiplicity; DefiniteMultiplicity returns Multiplicity: RangeMultiplicity | ExactMultiplicity; UnboundedMultiplicity: {UnboundedMultiplicity}; RangeMultiplicity: lowerBound=INT ".." upperBound=UpperBound; ExactMultiplicity: exactValue=INT; UpperBound returns ecore::EInt: INT | "*"; QualifiedName: QUOTED_ID | ID (":" ID)* (":" QUOTED_ID)?; @Override terminal STRING: '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"'; terminal QUOTED_ID: "'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'";