diff options
author | 2021-02-16 01:11:15 +0100 | |
---|---|---|
committer | 2021-02-16 01:11:15 +0100 | |
commit | acb8dedc9d03e1d17f570e07c9f75a571bd66cf8 (patch) | |
tree | 56d4f9899af7c70fa006395ffb0b93ff339fac7b /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | |
parent | Minor adjsutments to CrossScen ad FamTree local case studies (diff) | |
download | VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.tar.gz VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.tar.zst VIATRA-Generator-acb8dedc9d03e1d17f570e07c9f75a571bd66cf8.zip |
Ready for strategies case study
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PExpressionGenerator.xtend | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PExpressionGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PExpressionGenerator.xtend index 62ff92b2..9835356e 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PExpressionGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PExpressionGenerator.xtend | |||
@@ -10,6 +10,8 @@ import org.eclipse.xtext.xbase.XNumberLiteral | |||
10 | import org.eclipse.xtext.xbase.XUnaryOperation | 10 | import org.eclipse.xtext.xbase.XUnaryOperation |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.PrimitiveTypeReference | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.PrimitiveTypeReference |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference |
13 | import org.eclipse.xtext.xbase.XIfExpression | ||
14 | import org.eclipse.xtext.xbase.XBlockExpression | ||
13 | 15 | ||
14 | class PExpressionGenerator { | 16 | class PExpressionGenerator { |
15 | static val N_Base = "org.eclipse.xtext.xbase.lib." | 17 | static val N_Base = "org.eclipse.xtext.xbase.lib." |
@@ -113,4 +115,17 @@ class PExpressionGenerator { | |||
113 | def dispatch CharSequence translateExpression(XExpression expression, Map<PVariable,String> valueName, Map<PVariable, PrimitiveTypeReference> variable2Type) { | 115 | def dispatch CharSequence translateExpression(XExpression expression, Map<PVariable,String> valueName, Map<PVariable, PrimitiveTypeReference> variable2Type) { |
114 | throw new UnsupportedOperationException('''Unsupported expression in check or eval: «expression.class.name», «expression»"''') | 116 | throw new UnsupportedOperationException('''Unsupported expression in check or eval: «expression.class.name», «expression»"''') |
115 | } | 117 | } |
118 | |||
119 | def dispatch CharSequence translateExpression(XIfExpression e, Map<PVariable,String> valueName, Map<PVariable, PrimitiveTypeReference> variable2Type) { | ||
120 | val i = e.^if.translateExpression(valueName,variable2Type) | ||
121 | val t = e.then.translateExpression(valueName,variable2Type) | ||
122 | val el = e.^else.translateExpression(valueName,variable2Type) | ||
123 | |||
124 | return '''(if(«i»){«t»}else{«el»})''' | ||
125 | } | ||
126 | |||
127 | def dispatch CharSequence translateExpression(XBlockExpression e, Map<PVariable,String> valueName, Map<PVariable, PrimitiveTypeReference> variable2Type) { | ||
128 | //Assuming 1-item blocks only | ||
129 | return (e as XBlockExpression).expressions.get(0).translateExpression(valueName,variable2Type) | ||
130 | } | ||
116 | } \ No newline at end of file | 131 | } \ No newline at end of file |