All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni_hildesheim.sse.vil.rt.RtVil.xtext Maven / Gradle / Ivy

grammar de.uni_hildesheim.sse.vil.rt.RtVil with de.uni_hildesheim.sse.VilBuildLanguage

generate rtVil "http://www.uni_hildesheim.de/sse/vil/rt/RtVil"

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

ImplementationUnit:
    {ImplementationUnit}
    imports+=Import*
    requires+=Require*
    scripts+=LanguageUnit*
;

LanguageUnit: // do not rename - required for reuse
    (advices+=Advice)*
    'rtVilScript' name=Identifier 
    '(' param=ParameterList? ')'
    (parent=ScriptParentDecl)?
    '{'
       version=VersionStmt?
       rtContents=rtContents
    '}' ';'?
;

rtContents:
    {rtContents} // ensure object creation
    (
        elements += GlobalVariableDeclaration
        | elements += RuleDeclaration
        | elements += StrategyDeclaration
        | elements += TacticDeclaration
        | elements += TypeDef
        | elements += Compound
    )*
;

GlobalVariableDeclaration:
    persistent = 'persistent'?
    varDecl = VariableDeclaration
;

StrategyDeclaration:
    {StrategyDeclaration}
    'strategy' name=Identifier
    '(' (paramList=ParameterList)? ')'
    '=' conditions = RuleConditions?
    '{'
    varDecls += VariableDeclaration*
    ('objective' objective=Expression ';')?
    ('breakdown' '{' weighting=WeightingStatement? breakdown += BreakdownElement+ '}')
    post += RuleElement*
    '}'
    ';'?
;

BreakdownElement:
    varDecl=VariableDeclaration
    | exprStmt=ExpressionStatement
    | breakdownStmt=BreakdownStatement
;

WeightingStatement:
    'weighting' '(' name=Identifier ':' expr=Expression ')' ';'
;

BreakdownStatement:
    type = ('strategy' | 'tactic')
    (
      '(' guard = LogicalExpression ')' 
    )?
    name = QualifiedPrefix
    '(' param=ArgumentList? ')'
    (
      'with' '('
      part += BreakdownWithPart (',' part+= BreakdownWithPart)
      ')'  
    )?
    (
      '@' time = Expression
    )?
    ';'
;

BreakdownWithPart:
    name = Identifier
    '='
    value = Expression
;

TacticDeclaration:
    {TacticDeclaration}
    'tactic' name = Identifier
    '(' (paramList = ParameterList)? ')'
    '=' conditions = RuleConditions?
    block = RuleElementBlock
    ';'?
;

RuleElementBlock:
    {RuleElementBlock}
    '{'
       intent = IntentDeclaration?
       elements += RuleElement*
    '}'
;

RuleElement:
    varDecl=VariableDeclaration
    | exprStmt=ExpressionStatement
    | while=While ';'?
    | for=For ';'?
    | fail = FailStatement
;

IntentDeclaration:
    'intent' exprStmt=ExpressionStatement
;

FailStatement:
    ((name='fail' reason=Expression? ('with' code=Expression)?) | (name='refail')) ';'
;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy