diff options
author | 2017-06-10 19:05:05 +0200 | |
---|---|---|
committer | 2017-06-10 19:05:05 +0200 | |
commit | 60f01f46ba232ed6416054f0a6115cb2a9b70b4e (patch) | |
tree | 5edf8aeb07abc51f3fec63bbd15c926e1de09552 /Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src | |
parent | Initial commit, migrating from SVN (diff) | |
download | VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.gz VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.zst VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.zip |
Migrating Additional projects
Diffstat (limited to 'Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src')
8 files changed, 602 insertions, 0 deletions
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/GenerateSmtLanguage.mwe2 b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/GenerateSmtLanguage.mwe2 new file mode 100644 index 00000000..e27dbd64 --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/GenerateSmtLanguage.mwe2 | |||
@@ -0,0 +1,133 @@ | |||
1 | module hu.bme.mit.inf.dslreasoner.GenerateSmtLanguage | ||
2 | |||
3 | import org.eclipse.emf.mwe.utils.* | ||
4 | import org.eclipse.xtext.generator.* | ||
5 | import org.eclipse.xtext.ui.generator.* | ||
6 | |||
7 | var grammarURI = "classpath:/hu/bme/mit/inf/dslreasoner/SmtLanguage.xtext" | ||
8 | var fileExtensions = "smt2" | ||
9 | var projectName = "hu.bme.mit.inf.dslreasoner.smt.language" | ||
10 | var runtimeProject = "../${projectName}" | ||
11 | var generateXtendStub = true | ||
12 | var encoding = "UTF-8" | ||
13 | |||
14 | Workflow { | ||
15 | bean = StandaloneSetup { | ||
16 | scanClassPath = true | ||
17 | platformUri = "${runtimeProject}/.." | ||
18 | // The following two lines can be removed, if Xbase is not used. | ||
19 | registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage" | ||
20 | registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel" | ||
21 | } | ||
22 | |||
23 | component = DirectoryCleaner { | ||
24 | directory = "${runtimeProject}/src-gen" | ||
25 | } | ||
26 | |||
27 | component = DirectoryCleaner { | ||
28 | directory = "${runtimeProject}/model/generated" | ||
29 | } | ||
30 | |||
31 | component = DirectoryCleaner { | ||
32 | directory = "${runtimeProject}.ui/src-gen" | ||
33 | } | ||
34 | |||
35 | component = DirectoryCleaner { | ||
36 | directory = "${runtimeProject}.tests/src-gen" | ||
37 | } | ||
38 | |||
39 | component = Generator { | ||
40 | pathRtProject = runtimeProject | ||
41 | pathUiProject = "${runtimeProject}.ui" | ||
42 | //pathTestProject = "${runtimeProject}.tests" | ||
43 | projectNameRt = projectName | ||
44 | projectNameUi = "${projectName}.ui" | ||
45 | encoding = encoding | ||
46 | language = auto-inject { | ||
47 | uri = grammarURI | ||
48 | |||
49 | // Java API to access grammar elements (required by several other fragments) | ||
50 | fragment = grammarAccess.GrammarAccessFragment auto-inject {} | ||
51 | |||
52 | // generates Java API for the generated EPackages | ||
53 | fragment = ecore.EMFGeneratorFragment auto-inject {} | ||
54 | |||
55 | // the old serialization component | ||
56 | // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {} | ||
57 | |||
58 | // serializer 2.0 | ||
59 | fragment = serializer.SerializerFragment auto-inject { | ||
60 | generateStub = false | ||
61 | } | ||
62 | |||
63 | // a custom ResourceFactory for use with EMF | ||
64 | fragment = resourceFactory.ResourceFactoryFragment auto-inject {} | ||
65 | |||
66 | // The antlr parser generator fragment. | ||
67 | fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject { | ||
68 | // options = { | ||
69 | // backtrack = true | ||
70 | // } | ||
71 | } | ||
72 | |||
73 | // Xtend-based API for validation | ||
74 | fragment = validation.ValidatorFragment auto-inject { | ||
75 | // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" | ||
76 | // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" | ||
77 | } | ||
78 | |||
79 | // old scoping and exporting API | ||
80 | // fragment = scoping.ImportURIScopingFragment auto-inject {} | ||
81 | // fragment = exporting.SimpleNamesFragment auto-inject {} | ||
82 | |||
83 | // scoping and exporting API | ||
84 | fragment = scoping.ImportNamespacesScopingFragment auto-inject {} | ||
85 | fragment = exporting.QualifiedNamesFragment auto-inject {} | ||
86 | fragment = builder.BuilderIntegrationFragment auto-inject {} | ||
87 | |||
88 | // generator API | ||
89 | fragment = generator.GeneratorFragment auto-inject {} | ||
90 | |||
91 | // formatter API | ||
92 | fragment = formatting.FormatterFragment auto-inject {} | ||
93 | |||
94 | // labeling API | ||
95 | fragment = labeling.LabelProviderFragment auto-inject {} | ||
96 | |||
97 | // outline API | ||
98 | fragment = outline.OutlineTreeProviderFragment auto-inject {} | ||
99 | fragment = outline.QuickOutlineFragment auto-inject {} | ||
100 | |||
101 | // quickfix API | ||
102 | fragment = quickfix.QuickfixProviderFragment auto-inject {} | ||
103 | |||
104 | // content assist API | ||
105 | fragment = contentAssist.ContentAssistFragment auto-inject {} | ||
106 | |||
107 | // generates a more lightweight Antlr parser and lexer tailored for content assist | ||
108 | fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {} | ||
109 | |||
110 | // generates junit test support classes into Generator#pathTestProject | ||
111 | //fragment = junit.Junit4Fragment auto-inject {} | ||
112 | |||
113 | // rename refactoring | ||
114 | fragment = refactoring.RefactorElementNameFragment auto-inject {} | ||
115 | |||
116 | // provides the necessary bindings for java types integration | ||
117 | fragment = types.TypesGeneratorFragment auto-inject {} | ||
118 | |||
119 | // generates the required bindings only if the grammar inherits from Xbase | ||
120 | fragment = xbase.XbaseGeneratorFragment auto-inject {} | ||
121 | |||
122 | // generates the required bindings only if the grammar inherits from Xtype | ||
123 | fragment = xbase.XtypeGeneratorFragment auto-inject {} | ||
124 | |||
125 | // provides a preference page for template proposals | ||
126 | fragment = templates.CodetemplatesGeneratorFragment auto-inject {} | ||
127 | |||
128 | // provides a compare view | ||
129 | fragment = compare.CompareFragment auto-inject {} | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | |||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguage.xtext b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguage.xtext new file mode 100644 index 00000000..320e1cfe --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguage.xtext | |||
@@ -0,0 +1,222 @@ | |||
1 | grammar hu.bme.mit.inf.dslreasoner.SmtLanguage with org.eclipse.xtext.common.Terminals | ||
2 | |||
3 | generate smtLanguage "http://www.bme.hu/mit/inf/dslreasoner/SmtLanguage" | ||
4 | |||
5 | import "http://www.eclipse.org/emf/2002/Ecore" as ecore | ||
6 | |||
7 | SMTDocument: | ||
8 | input=SMTInput | ||
9 | ( | ||
10 | '--------------' | ||
11 | output=SMTOutput | ||
12 | )?; | ||
13 | |||
14 | SMTInput: | ||
15 | (options += SMTOption)* | ||
16 | ( | ||
17 | typeDeclarations+=SMTType | | ||
18 | functionDeclarations+=SMTFunctionDeclaration | | ||
19 | functionDefinition+=SMTFunctionDefinition | | ||
20 | assertions += SMTAssertion | ||
21 | )* | ||
22 | satCommand = SMTSatCommand | ||
23 | getModelCommand = SMTGetModelCommand; | ||
24 | |||
25 | SMTOutput:( | ||
26 | (satResult = SMTResult | ||
27 | getModelResult = SMTResult) | 'timeout' {SMTOutput}) | ||
28 | statistics=SMTStatisticsSection?; | ||
29 | |||
30 | ////////////////////////////////// | ||
31 | // SMT terminals | ||
32 | ////////////////////////////////// | ||
33 | |||
34 | terminal SL_COMMENT : ';' !('\n'|'\r')* ('\r'? '\n')?; | ||
35 | |||
36 | terminal ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'-'|'!'|'0'..'9')*; | ||
37 | // ('a'..'z'|'A'..'Z'|'_'/*|'+'|'-'|'/'|'*'|'='|'%'|'?'|'!'|'.'|'$'|'~'|'&'/*|'^'*/|'<'|'>'/*|'@'*/) | ||
38 | // ('a'..'z'|'A'..'Z'|'_'/*|'+'|'-'|'/'|'*'|'='|'%'|'?'|'!'|'.'|'$'|'~'|'&'/*|'^'|*/'<'|'>'/*|'@'*/|'0'..'9')* | ||
39 | SMTID: ID; | ||
40 | |||
41 | terminal PROPERTYNAME : ':' + ID; | ||
42 | terminal REAL returns ecore::EBigDecimal: INT '.' INT; | ||
43 | |||
44 | ////////////////////////////////// | ||
45 | // Options | ||
46 | ////////////////////////////////// | ||
47 | SMTOption: '(' 'set-option' name = PROPERTYNAME value = SMTAtomicTerm ')'; | ||
48 | |||
49 | ////////////////////////////////// | ||
50 | // Type declarations | ||
51 | ////////////////////////////////// | ||
52 | SMTType: SMTEnumeratedTypeDeclaration | SMTSetTypeDeclaration; | ||
53 | |||
54 | SMTEnumLiteral: name = SMTID; | ||
55 | SMTEnumeratedTypeDeclaration: '(' 'declare-datatypes' '(' ')' '(' '(' name = SMTID elements+=SMTEnumLiteral+ ')' ')' ')'; | ||
56 | SMTSetTypeDeclaration: '(' 'declare-sort' name = SMTID ')'; | ||
57 | |||
58 | SMTTypeReference: SMTComplexTypeReference | SMTPrimitiveTypeReference; | ||
59 | SMTComplexTypeReference: referred = [SMTType]; | ||
60 | SMTPrimitiveTypeReference: SMTIntTypeReference | SMTBoolTypeReference | SMTRealTypeReference; | ||
61 | |||
62 | SMTIntTypeReference: {SMTIntTypeReference} "Int"; | ||
63 | SMTBoolTypeReference: {SMTBoolTypeReference} "Bool"; | ||
64 | SMTRealTypeReference: {SMTRealTypeReference} "Real"; | ||
65 | |||
66 | ////////////////////////////////// | ||
67 | // Functions and constants | ||
68 | ////////////////////////////////// | ||
69 | |||
70 | SMTFunctionDeclaration: '(' 'declare-fun' name = SMTID '(' parameters+=SMTTypeReference* ')' range = SMTTypeReference ')'; | ||
71 | |||
72 | /*DeclaredFunctionDefinition: | ||
73 | '(' 'define-fun' declaration=[Function] '(' parameters+=SortedVariable* ')' range = TypeReference value = Term ')';*/ | ||
74 | |||
75 | SMTFunctionDefinition: | ||
76 | '(' 'define-fun' name=SMTID '(' parameters+=SMTSortedVariable* ')' range = SMTTypeReference value = SMTTerm ')'; | ||
77 | |||
78 | |||
79 | ////////////////////////////////// | ||
80 | // Expressions | ||
81 | ////////////////////////////////// | ||
82 | SMTTerm: | ||
83 | SMTSymbolicValue| | ||
84 | SMTAtomicTerm | | ||
85 | SMTBoolOperation | | ||
86 | SMTIntOperation | | ||
87 | SMTITE | | ||
88 | SMTLet | | ||
89 | SMTRelation | | ||
90 | SMTQuantifiedExpression; | ||
91 | |||
92 | SMTSymbolicDeclaration: SMTFunctionDeclaration | SMTFunctionDefinition | SMTSortedVariable | SMTEnumLiteral | SMTInlineConstantDefinition; | ||
93 | |||
94 | SMTSymbolicValue: | ||
95 | '(' symbolicReference = [SMTSymbolicDeclaration] ( parameterSubstitutions += SMTTerm )+ ')' | | ||
96 | symbolicReference = [SMTSymbolicDeclaration]; | ||
97 | |||
98 | SMTAtomicTerm: SMTIntLiteral | SMTBoolLiteral | SMTRealLiteral; | ||
99 | SMTIntLiteral: value=INT; | ||
100 | BOOLEANTERMINAL returns ecore::EBoolean: 'true' | 'false'; | ||
101 | SMTBoolLiteral: value=BOOLEANTERMINAL; | ||
102 | SMTRealLiteral: value=REAL; | ||
103 | |||
104 | // Quantified operations | ||
105 | SMTSortedVariable: '(' name = SMTID range = SMTTypeReference ')'; | ||
106 | //QuantifiedVariableValue: variable = [QuantifiedVariable]; | ||
107 | |||
108 | SMTQuantifiedExpression: SMTExists | SMTForall; | ||
109 | SMTExists: '(' 'exists' '(' (quantifiedVariables += SMTSortedVariable)+ ')' | ||
110 | (expression=SMTTerm | ('(' '!' expression = SMTTerm ':pattern' '(' pattern = SMTTerm ')' ')')) ')' | ||
111 | ; | ||
112 | SMTForall: '(' 'forall' '(' (quantifiedVariables += SMTSortedVariable)+ ')' | ||
113 | (expression=SMTTerm | ('(' '!' expression = SMTTerm ':pattern' '(' pattern = SMTTerm ')' ')')) ')' | ||
114 | ; | ||
115 | |||
116 | // Boolean operations | ||
117 | SMTBoolOperation: SMTAnd | SMTOr | SMTImpl | SMTNot | SMTIff; | ||
118 | SMTAnd: '(' 'and' operands+=SMTTerm+ ')'; | ||
119 | SMTOr: '(' 'or' operands+=SMTTerm+ ')'; | ||
120 | SMTImpl: '(' '=>' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
121 | SMTNot: '(' 'not' operand=SMTTerm ')'; | ||
122 | SMTIff: '(' 'iff' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
123 | |||
124 | // If-then-else | ||
125 | SMTITE: '(' 'ite' condition = SMTTerm if=SMTTerm else = SMTTerm ')'; | ||
126 | |||
127 | //Let | ||
128 | SMTLet: '(' 'let' '(' (inlineConstantDefinitions+=SMTInlineConstantDefinition)+ ')' term=SMTTerm ')'; | ||
129 | SMTInlineConstantDefinition: | ||
130 | '(' name=SMTID definition=SMTTerm ')' | ||
131 | ; | ||
132 | |||
133 | // Relations | ||
134 | SMTRelation: SMTEquals | SMTDistinct | SMTLT | SMTMT | SMTLEQ | SMTMEQ; | ||
135 | SMTEquals: '(' '=' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
136 | SMTDistinct: '(' 'distinct' operands+=SMTTerm+ ')'; | ||
137 | SMTLT: '(' '<' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
138 | SMTMT: '(' '>' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
139 | SMTLEQ: '(' '<=' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
140 | SMTMEQ: '(' '>=' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
141 | |||
142 | // Int operations | ||
143 | SMTIntOperation: SMTPlus | SMTMinus | SMTMultiply | SMTDivison | SMTDiv | SMTMod; | ||
144 | SMTPlus: '(' '+' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
145 | SMTMinus: '(' '-' leftOperand=SMTTerm (rightOperand=SMTTerm)? ')'; | ||
146 | SMTMultiply: '(' '*' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
147 | SMTDivison: '(' '/' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
148 | SMTDiv: '(' 'div' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
149 | SMTMod: '(' 'mod' leftOperand=SMTTerm rightOperand=SMTTerm ')'; | ||
150 | |||
151 | ////////////////////////////////// | ||
152 | // Assertion | ||
153 | ////////////////////////////////// | ||
154 | SMTAssertion: '(' 'assert' value=SMTTerm ')'; | ||
155 | SMTCardinalityConstraint: | ||
156 | '(' 'forall' '(' '(' ID type=SMTTypeReference ')' ')' | ||
157 | (('(' 'or'('(' '=' ID elements+=SMTSymbolicValue ')')* ')') | // With multiple element | ||
158 | ('(' '=' ID elements+=SMTSymbolicValue ')')) //With single element | ||
159 | ')' | ||
160 | ; | ||
161 | |||
162 | ////////////////////////////////// | ||
163 | // Goals | ||
164 | ////////////////////////////////// | ||
165 | SMTSatCommand: SMTSimpleSatCommand | SMTComplexSatCommand; | ||
166 | SMTSimpleSatCommand : '(' 'check-sat' {SMTSimpleSatCommand} ')'; | ||
167 | SMTComplexSatCommand: '(' 'check-sat-using' method = SMTReasoningTactic ')'; | ||
168 | SMTGetModelCommand: '(' 'get-model' {SMTGetModelCommand} ')'; | ||
169 | |||
170 | SMTReasoningTactic: SMTBuiltinTactic | SMTReasoningCombinator; | ||
171 | SMTBuiltinTactic: name = ID; | ||
172 | SMTReasoningCombinator: | ||
173 | SMTAndThenCombinator | SMTOrElseCombinator | SMTParOrCombinator | SMTParThenCombinator | SMTTryForCombinator | | ||
174 | SMTIfCombinator | SMTWhenCombinator | SMTFailIfCombinator | SMTUsingParamCombinator | ||
175 | ; | ||
176 | // executes the given tactics sequencially. | ||
177 | SMTAndThenCombinator: '(' 'and-then' (tactics+=SMTReasoningTactic)+ ')'; | ||
178 | // tries the given tactics in sequence until one of them succeeds. | ||
179 | SMTOrElseCombinator: '(' 'or-else' (tactics+=SMTReasoningTactic)+ ')'; | ||
180 | // executes the given tactics in parallel until one of them succeeds. | ||
181 | SMTParOrCombinator: '(' 'par-or' (tactics+=SMTReasoningTactic)+ ')'; | ||
182 | // executes tactic1 and then tactic2 to every subgoal produced by tactic1. All subgoals are processed in parallel. | ||
183 | SMTParThenCombinator: '(' 'par-then' preProcessingTactic=SMTReasoningTactic paralellyPostpricessingTactic = SMTReasoningTactic ')'; | ||
184 | // excutes the given tactic for at most <num> milliseconds, it fails if the execution takes more than <num> milliseconds. | ||
185 | SMTTryForCombinator: '(' 'try-for' tactic=SMTReasoningTactic time=INT ')'; | ||
186 | // if <probe> evaluates to true, then execute the first tactic. Otherwise execute the second. | ||
187 | SMTIfCombinator: '(' 'if' probe=ReasoningProbe ifTactic=SMTReasoningTactic elseTactic=SMTReasoningTactic ')'; | ||
188 | // shorthand for (if <probe> <tactic> skip). | ||
189 | SMTWhenCombinator: '(' 'when' probe=ReasoningProbe tactic=SMTReasoningTactic ')'; | ||
190 | // fail if <probe> evaluates to true. | ||
191 | SMTFailIfCombinator: '(' 'fail-if' probe=ReasoningProbe ')'; | ||
192 | //executes the given tactic using the given attributes, where <attribute> ::= <keyword> <value>. ! is a syntax sugar for using-params. | ||
193 | SMTUsingParamCombinator: '(' ('using-params' | '!') tactic=SMTReasoningTactic (parameters+=ReasoningTacticParameter)* ')'; | ||
194 | |||
195 | ReasoningProbe: name=ID; | ||
196 | ReasoningTacticParameter: name=PROPERTYNAME value=SMTAtomicTerm; | ||
197 | |||
198 | ////////////////////////////////// | ||
199 | // Result | ||
200 | ////////////////////////////////// | ||
201 | |||
202 | SMTResult: SMTUnsupportedResult | SMTSatResult | SMTModelResult | SMTErrorResult; | ||
203 | SMTErrorResult: '(' 'error' message = STRING ')'; | ||
204 | SMTUnsupportedResult: 'unsupported' ';' command=ID; | ||
205 | SMTSatResult: sat?='sat' | unsat?='unsat' | unknown?='unknown'; | ||
206 | SMTModelResult: {SMTModelResult} '(' 'model' | ||
207 | ( | ||
208 | newFunctionDeclarations+=SMTFunctionDeclaration | | ||
209 | typeDefinitions+=SMTCardinalityConstraint | | ||
210 | newFunctionDefinitions+=SMTFunctionDefinition | ||
211 | )* | ||
212 | ')'; | ||
213 | |||
214 | ////////////////////////////////// | ||
215 | // Statistics | ||
216 | ////////////////////////////////// | ||
217 | //IntOrReal returns ecore::EDouble: INT | REAL; | ||
218 | |||
219 | SMTStatisticValue: SMTStatisticIntValue | SMTStatisticDoubleValue; | ||
220 | SMTStatisticIntValue: name = PROPERTYNAME value=INT; | ||
221 | SMTStatisticDoubleValue: name = PROPERTYNAME value = REAL; | ||
222 | SMTStatisticsSection: '(' {SMTStatisticsSection} values += SMTStatisticValue* ')'; \ No newline at end of file | ||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageRuntimeModule.java b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageRuntimeModule.java new file mode 100644 index 00000000..dabb0c29 --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageRuntimeModule.java | |||
@@ -0,0 +1,11 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner; | ||
5 | |||
6 | /** | ||
7 | * Use this class to register components to be used at runtime / without the Equinox extension registry. | ||
8 | */ | ||
9 | public class SmtLanguageRuntimeModule extends hu.bme.mit.inf.dslreasoner.AbstractSmtLanguageRuntimeModule { | ||
10 | |||
11 | } | ||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageStandaloneSetup.java b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageStandaloneSetup.java new file mode 100644 index 00000000..ed297373 --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/SmtLanguageStandaloneSetup.java | |||
@@ -0,0 +1,16 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner; | ||
5 | |||
6 | /** | ||
7 | * Initialization support for running Xtext languages | ||
8 | * without equinox extension registry | ||
9 | */ | ||
10 | public class SmtLanguageStandaloneSetup extends SmtLanguageStandaloneSetupGenerated{ | ||
11 | |||
12 | public static void doSetup() { | ||
13 | new SmtLanguageStandaloneSetup().createInjectorAndDoEMFRegistration(); | ||
14 | } | ||
15 | } | ||
16 | |||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/formatting/SmtLanguageFormatter.xtend b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/formatting/SmtLanguageFormatter.xtend new file mode 100644 index 00000000..9e3e3943 --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/formatting/SmtLanguageFormatter.xtend | |||
@@ -0,0 +1,34 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.formatting | ||
2 | |||
3 | import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter | ||
4 | import org.eclipse.xtext.formatting.impl.FormattingConfig | ||
5 | import hu.bme.mit.inf.dslreasoner.services.SmtLanguageGrammarAccess | ||
6 | |||
7 | |||
8 | /** | ||
9 | * This class contains custom formatting description. | ||
10 | * | ||
11 | * see : http://www.eclipse.org/Xtext/documentation.html#formatting | ||
12 | * on how and when to use it | ||
13 | * | ||
14 | * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example | ||
15 | */ | ||
16 | class SmtLanguageFormatter extends AbstractDeclarativeFormatter { | ||
17 | |||
18 | // @Inject extension SmtLanguageGrammarAccess | ||
19 | |||
20 | override protected void configureFormatting(FormattingConfig c) { | ||
21 | val f = getGrammarAccess as SmtLanguageGrammarAccess | ||
22 | c.setAutoLinewrap(100000); | ||
23 | for(pair : f.findKeywordPairs("(",")")) { | ||
24 | c.setNoSpace().after(pair.getFirst()); | ||
25 | c.setNoSpace().before(pair.getSecond()); | ||
26 | } | ||
27 | c.setLinewrap.after(f.SMTAssertionRule) | ||
28 | c.setLinewrap.after(f.SMTFunctionDeclarationRule) | ||
29 | c.setLinewrap.after(f.SMTFunctionDefinitionRule) | ||
30 | c.setLinewrap.after(f.SMTEnumeratedTypeDeclarationRule) | ||
31 | c.setLinewrap.after(f.SMTSetTypeDeclarationRule) | ||
32 | c.setLinewrap.after(f.SMTOptionRule) | ||
33 | } | ||
34 | } | ||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/generator/SmtLanguageGenerator.xtend b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/generator/SmtLanguageGenerator.xtend new file mode 100644 index 00000000..e61c082e --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/generator/SmtLanguageGenerator.xtend | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.generator | ||
5 | |||
6 | import org.eclipse.emf.ecore.resource.Resource | ||
7 | import org.eclipse.xtext.generator.IGenerator | ||
8 | import org.eclipse.xtext.generator.IFileSystemAccess | ||
9 | |||
10 | /** | ||
11 | * Generates code from your model files on save. | ||
12 | * | ||
13 | * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration | ||
14 | */ | ||
15 | class SmtLanguageGenerator implements IGenerator { | ||
16 | |||
17 | override void doGenerate(Resource resource, IFileSystemAccess fsa) { | ||
18 | // fsa.generateFile('greetings.txt', 'People to greet: ' + | ||
19 | // resource.allContents | ||
20 | // .filter(typeof(Greeting)) | ||
21 | // .map[name] | ||
22 | // .join(', ')) | ||
23 | } | ||
24 | } | ||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/scoping/SmtLanguageScopeProvider.xtend b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/scoping/SmtLanguageScopeProvider.xtend new file mode 100644 index 00000000..e93e0543 --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/scoping/SmtLanguageScopeProvider.xtend | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.scoping | ||
5 | |||
6 | import java.util.Set | ||
7 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTSortedVariable | ||
8 | import org.eclipse.emf.ecore.EObject | ||
9 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTQuantifiedExpression | ||
10 | import java.util.Collections | ||
11 | import java.util.HashSet | ||
12 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTInlineConstantDefinition | ||
13 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTLet | ||
14 | import java.util.Collection | ||
15 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTFunctionDefinition | ||
16 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTSymbolicValue | ||
17 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTDocument | ||
18 | import org.eclipse.xtext.scoping.IScope | ||
19 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTSymbolicDeclaration | ||
20 | import org.eclipse.emf.ecore.EReference | ||
21 | import java.util.HashMap | ||
22 | import java.util.Map | ||
23 | import org.eclipse.xtext.scoping.Scopes | ||
24 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTModelResult | ||
25 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTComplexTypeReference | ||
26 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTEnumLiteral | ||
27 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTEnumeratedTypeDeclaration | ||
28 | import hu.bme.mit.inf.dslreasoner.smtLanguage.SMTFunctionDeclaration | ||
29 | |||
30 | /** | ||
31 | * This class contains custom scoping description. | ||
32 | * | ||
33 | * see : http://www.eclipse.org/Xtext/documentation.html#scoping | ||
34 | * on how and when to use it | ||
35 | * | ||
36 | */ | ||
37 | class SmtLanguageScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider { | ||
38 | /** | ||
39 | * Search for the first instance of containerType up in the containment hierarchy. | ||
40 | * @param containerType | ||
41 | * @param from | ||
42 | * @return | ||
43 | */ | ||
44 | @SuppressWarnings("unchecked") | ||
45 | def private <ContainerType> ContainerType getTop(Class<ContainerType> containerType, EObject from){ | ||
46 | var actualLevel = from.eContainer(); | ||
47 | while(actualLevel!=null){ | ||
48 | if(containerType.isInstance(actualLevel)) { return actualLevel as ContainerType} | ||
49 | else { actualLevel = actualLevel.eContainer() } | ||
50 | } | ||
51 | return null; | ||
52 | } | ||
53 | |||
54 | def private Set<SMTSortedVariable> getQuantifiedVariables(EObject from) { | ||
55 | //The most inner quantified variables are in this expression: | ||
56 | val quantifiedExpression = getTop(typeof(SMTQuantifiedExpression), from); | ||
57 | if(quantifiedExpression==null) return Collections.emptySet(); | ||
58 | |||
59 | //The variables can be referred by a symbolic reference | ||
60 | val Set<SMTSortedVariable> result = new HashSet(quantifiedExpression.getQuantifiedVariables()); | ||
61 | //The variables can defined in an outer quantifier | ||
62 | result.addAll(getQuantifiedVariables(quantifiedExpression)); | ||
63 | //println(result.map[name].join(",")) | ||
64 | return result; | ||
65 | } | ||
66 | |||
67 | def private Set<SMTInlineConstantDefinition> getInlineConstantDefinitions(EObject from) { | ||
68 | //The most inner quantified variables are in this expression: | ||
69 | val let = getTop(typeof(SMTLet), from); | ||
70 | if(let==null) return Collections.emptySet(); | ||
71 | |||
72 | //The variables can be referred by a symbolic reference | ||
73 | val result = new HashSet(let.getInlineConstantDefinitions()); | ||
74 | //The variables can defined in an outer quantifier | ||
75 | result.addAll(getInlineConstantDefinitions(let)); | ||
76 | return result; | ||
77 | } | ||
78 | |||
79 | def private Collection<SMTSortedVariable> getParameters(SMTSymbolicValue from) { | ||
80 | val functionDefinition = getTop(typeof(SMTFunctionDefinition), from); | ||
81 | if(functionDefinition!=null) { | ||
82 | return functionDefinition.getParameters(); | ||
83 | } | ||
84 | else return Collections.emptySet(); | ||
85 | } | ||
86 | |||
87 | def private Set<SMTEnumLiteral> getFiniteElements(SMTSymbolicValue value) { | ||
88 | val Set<SMTEnumLiteral> result = new HashSet(); | ||
89 | val document = getTop(typeof(SMTDocument),value) | ||
90 | for(type : document.input.getTypeDeclarations().filter(typeof(SMTEnumeratedTypeDeclaration))) { | ||
91 | result.addAll(type.getElements()); | ||
92 | } | ||
93 | return result; | ||
94 | } | ||
95 | |||
96 | def private Set<SMTSymbolicDeclaration> getFunctions(SMTSymbolicValue value) { | ||
97 | val document = getTop(typeof(SMTDocument),value); | ||
98 | val input = document.input | ||
99 | var SMTModelResult output = null; | ||
100 | if(document.output != null && document.output.getModelResult instanceof SMTModelResult) { | ||
101 | output = document.output.getModelResult as SMTModelResult | ||
102 | } | ||
103 | |||
104 | val Map<String, SMTFunctionDeclaration> declarations = new HashMap | ||
105 | val Set<SMTFunctionDefinition> definitions =new HashSet | ||
106 | |||
107 | input.functionDeclarations.forEach[declarations.put(it.name,it)] | ||
108 | if(output != null) { | ||
109 | output.newFunctionDeclarations.forEach[declarations.put(it.name,it)] | ||
110 | } | ||
111 | input.functionDefinition.filter[!declarations.containsKey(it.name)].forEach[definitions += it] | ||
112 | if(output != null) { | ||
113 | output.newFunctionDefinitions.filter[!declarations.containsKey(it.name)].forEach[definitions += it] | ||
114 | } | ||
115 | |||
116 | val referrables = new HashSet<SMTSymbolicDeclaration>; | ||
117 | referrables.addAll(declarations.values) | ||
118 | referrables.addAll(definitions) | ||
119 | return referrables | ||
120 | } | ||
121 | |||
122 | def public IScope scope_SMTSymbolicValue_symbolicReference(SMTSymbolicValue value, EReference ref) { | ||
123 | val Set<SMTSymbolicDeclaration> referrables = new HashSet; | ||
124 | |||
125 | referrables.addAll(value.getFiniteElements) | ||
126 | referrables.addAll(value.getParameters) | ||
127 | referrables.addAll(value.getFunctions) | ||
128 | referrables.addAll(value.getQuantifiedVariables) | ||
129 | referrables.addAll(value.getInlineConstantDefinitions) | ||
130 | |||
131 | return Scopes.scopeFor(referrables); | ||
132 | } | ||
133 | |||
134 | // Any type defined in the input section can be referred. | ||
135 | def public IScope scope_SMTComplexTypeReference_referred(SMTComplexTypeReference reference, EReference ref){ | ||
136 | return Scopes.scopeFor(getTop(typeof(SMTDocument),reference).input.typeDeclarations) | ||
137 | } | ||
138 | } | ||
diff --git a/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/validation/SmtLanguageValidator.xtend b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/validation/SmtLanguageValidator.xtend new file mode 100644 index 00000000..2ae6130f --- /dev/null +++ b/Solvers/SMT-Solver/hu.bme.mit.inf.dslreasoner.smt.language/src/hu/bme/mit/inf/dslreasoner/validation/SmtLanguageValidator.xtend | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.validation | ||
5 | //import org.eclipse.xtext.validation.Check | ||
6 | |||
7 | /** | ||
8 | * Custom validation rules. | ||
9 | * | ||
10 | * see http://www.eclipse.org/Xtext/documentation.html#validation | ||
11 | */ | ||
12 | class SmtLanguageValidator extends AbstractSmtLanguageValidator { | ||
13 | |||
14 | // public static val INVALID_NAME = 'invalidName' | ||
15 | // | ||
16 | // @Check | ||
17 | // def checkGreetingStartsWithCapital(Greeting greeting) { | ||
18 | // if (!Character.isUpperCase(greeting.name.charAt(0))) { | ||
19 | // warning('Name should start with a capital', | ||
20 | // MyDslPackage.Literals.GREETING__NAME, | ||
21 | // INVALID_NAME) | ||
22 | // } | ||
23 | // } | ||
24 | } | ||