1 | package de.ugoe.cs.swe.bnftools.serializer; |
---|
2 | |
---|
3 | import com.google.inject.Inject; |
---|
4 | import com.google.inject.Provider; |
---|
5 | import de.ugoe.cs.swe.bnftools.ebnf.Atom; |
---|
6 | import de.ugoe.cs.swe.bnftools.ebnf.BnfEntry; |
---|
7 | import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList; |
---|
8 | import de.ugoe.cs.swe.bnftools.ebnf.DeltaEntry; |
---|
9 | import de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage; |
---|
10 | import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf; |
---|
11 | import de.ugoe.cs.swe.bnftools.ebnf.ExtRule; |
---|
12 | import de.ugoe.cs.swe.bnftools.ebnf.GlobalCombinator; |
---|
13 | import de.ugoe.cs.swe.bnftools.ebnf.GroupedSequence; |
---|
14 | import de.ugoe.cs.swe.bnftools.ebnf.HookCombinator; |
---|
15 | import de.ugoe.cs.swe.bnftools.ebnf.Import; |
---|
16 | import de.ugoe.cs.swe.bnftools.ebnf.ImportSection; |
---|
17 | import de.ugoe.cs.swe.bnftools.ebnf.MergeEntry; |
---|
18 | import de.ugoe.cs.swe.bnftools.ebnf.OptionalSequence; |
---|
19 | import de.ugoe.cs.swe.bnftools.ebnf.RepeatedSequence; |
---|
20 | import de.ugoe.cs.swe.bnftools.ebnf.Rule; |
---|
21 | import de.ugoe.cs.swe.bnftools.ebnf.RuleCombinator; |
---|
22 | import de.ugoe.cs.swe.bnftools.ebnf.RuleReference; |
---|
23 | import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading; |
---|
24 | import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition; |
---|
25 | import de.ugoe.cs.swe.bnftools.ebnf.StringRule; |
---|
26 | import de.ugoe.cs.swe.bnftools.ebnf.Term; |
---|
27 | import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess; |
---|
28 | import org.eclipse.emf.ecore.EObject; |
---|
29 | import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor; |
---|
30 | import org.eclipse.xtext.serializer.acceptor.SequenceFeeder; |
---|
31 | import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider; |
---|
32 | import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor; |
---|
33 | import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer; |
---|
34 | import org.eclipse.xtext.serializer.sequencer.GenericSequencer; |
---|
35 | import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider; |
---|
36 | import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer; |
---|
37 | import org.eclipse.xtext.serializer.sequencer.ITransientValueService; |
---|
38 | import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient; |
---|
39 | |
---|
40 | @SuppressWarnings("all") |
---|
41 | public class EbnfSemanticSequencer extends AbstractDelegatingSemanticSequencer { |
---|
42 | |
---|
43 | @Inject |
---|
44 | private EbnfGrammarAccess grammarAccess; |
---|
45 | |
---|
46 | public void createSequence(EObject context, EObject semanticObject) { |
---|
47 | if(semanticObject.eClass().getEPackage() == EbnfPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) { |
---|
48 | case EbnfPackage.ATOM: |
---|
49 | if(context == grammarAccess.getAtomRule()) { |
---|
50 | sequence_Atom(context, (Atom) semanticObject); |
---|
51 | return; |
---|
52 | } |
---|
53 | else break; |
---|
54 | case EbnfPackage.BNF_ENTRY: |
---|
55 | if(context == grammarAccess.getBnfEntryRule()) { |
---|
56 | sequence_BnfEntry(context, (BnfEntry) semanticObject); |
---|
57 | return; |
---|
58 | } |
---|
59 | else break; |
---|
60 | case EbnfPackage.DEFINITION_LIST: |
---|
61 | if(context == grammarAccess.getDefinitionListRule()) { |
---|
62 | sequence_DefinitionList(context, (DefinitionList) semanticObject); |
---|
63 | return; |
---|
64 | } |
---|
65 | else break; |
---|
66 | case EbnfPackage.DELTA_ENTRY: |
---|
67 | if(context == grammarAccess.getDeltaEntryRule()) { |
---|
68 | sequence_DeltaEntry(context, (DeltaEntry) semanticObject); |
---|
69 | return; |
---|
70 | } |
---|
71 | else break; |
---|
72 | case EbnfPackage.ETSI_BNF: |
---|
73 | if(context == grammarAccess.getEtsiBnfRule()) { |
---|
74 | sequence_EtsiBnf(context, (EtsiBnf) semanticObject); |
---|
75 | return; |
---|
76 | } |
---|
77 | else break; |
---|
78 | case EbnfPackage.EXT_RULE: |
---|
79 | if(context == grammarAccess.getExtRuleRule()) { |
---|
80 | sequence_ExtRule(context, (ExtRule) semanticObject); |
---|
81 | return; |
---|
82 | } |
---|
83 | else break; |
---|
84 | case EbnfPackage.GLOBAL_COMBINATOR: |
---|
85 | if(context == grammarAccess.getGlobalCombinatorRule() || |
---|
86 | context == grammarAccess.getMergeRuleRule()) { |
---|
87 | sequence_GlobalCombinator(context, (GlobalCombinator) semanticObject); |
---|
88 | return; |
---|
89 | } |
---|
90 | else break; |
---|
91 | case EbnfPackage.GROUPED_SEQUENCE: |
---|
92 | if(context == grammarAccess.getGroupedSequenceRule()) { |
---|
93 | sequence_GroupedSequence(context, (GroupedSequence) semanticObject); |
---|
94 | return; |
---|
95 | } |
---|
96 | else break; |
---|
97 | case EbnfPackage.HOOK_COMBINATOR: |
---|
98 | if(context == grammarAccess.getHookCombinatorRule() || |
---|
99 | context == grammarAccess.getMergeRuleRule()) { |
---|
100 | sequence_HookCombinator(context, (HookCombinator) semanticObject); |
---|
101 | return; |
---|
102 | } |
---|
103 | else break; |
---|
104 | case EbnfPackage.IMPORT: |
---|
105 | if(context == grammarAccess.getImportRule()) { |
---|
106 | sequence_Import(context, (Import) semanticObject); |
---|
107 | return; |
---|
108 | } |
---|
109 | else break; |
---|
110 | case EbnfPackage.IMPORT_SECTION: |
---|
111 | if(context == grammarAccess.getImportSectionRule()) { |
---|
112 | sequence_ImportSection(context, (ImportSection) semanticObject); |
---|
113 | return; |
---|
114 | } |
---|
115 | else break; |
---|
116 | case EbnfPackage.MERGE_ENTRY: |
---|
117 | if(context == grammarAccess.getMergeEntryRule()) { |
---|
118 | sequence_MergeEntry(context, (MergeEntry) semanticObject); |
---|
119 | return; |
---|
120 | } |
---|
121 | else break; |
---|
122 | case EbnfPackage.OPTIONAL_SEQUENCE: |
---|
123 | if(context == grammarAccess.getOptionalSequenceRule()) { |
---|
124 | sequence_OptionalSequence(context, (OptionalSequence) semanticObject); |
---|
125 | return; |
---|
126 | } |
---|
127 | else break; |
---|
128 | case EbnfPackage.REPEATED_SEQUENCE: |
---|
129 | if(context == grammarAccess.getRepeatedSequenceRule()) { |
---|
130 | sequence_RepeatedSequence(context, (RepeatedSequence) semanticObject); |
---|
131 | return; |
---|
132 | } |
---|
133 | else break; |
---|
134 | case EbnfPackage.RULE: |
---|
135 | if(context == grammarAccess.getRuleRule()) { |
---|
136 | sequence_Rule(context, (Rule) semanticObject); |
---|
137 | return; |
---|
138 | } |
---|
139 | else break; |
---|
140 | case EbnfPackage.RULE_COMBINATOR: |
---|
141 | if(context == grammarAccess.getMergeRuleRule() || |
---|
142 | context == grammarAccess.getRuleCombinatorRule()) { |
---|
143 | sequence_RuleCombinator(context, (RuleCombinator) semanticObject); |
---|
144 | return; |
---|
145 | } |
---|
146 | else break; |
---|
147 | case EbnfPackage.RULE_REFERENCE: |
---|
148 | if(context == grammarAccess.getRuleReferenceRule()) { |
---|
149 | sequence_RuleReference(context, (RuleReference) semanticObject); |
---|
150 | return; |
---|
151 | } |
---|
152 | else break; |
---|
153 | case EbnfPackage.SECTION_HEADING: |
---|
154 | if(context == grammarAccess.getSectionHeadingRule()) { |
---|
155 | sequence_SectionHeading(context, (SectionHeading) semanticObject); |
---|
156 | return; |
---|
157 | } |
---|
158 | else break; |
---|
159 | case EbnfPackage.SINGLE_DEFINITION: |
---|
160 | if(context == grammarAccess.getSingleDefinitionRule()) { |
---|
161 | sequence_SingleDefinition(context, (SingleDefinition) semanticObject); |
---|
162 | return; |
---|
163 | } |
---|
164 | else break; |
---|
165 | case EbnfPackage.STRING_RULE: |
---|
166 | if(context == grammarAccess.getStringRuleRule()) { |
---|
167 | sequence_StringRule(context, (StringRule) semanticObject); |
---|
168 | return; |
---|
169 | } |
---|
170 | else break; |
---|
171 | case EbnfPackage.TERM: |
---|
172 | if(context == grammarAccess.getTermRule()) { |
---|
173 | sequence_Term(context, (Term) semanticObject); |
---|
174 | return; |
---|
175 | } |
---|
176 | else break; |
---|
177 | } |
---|
178 | if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); |
---|
179 | } |
---|
180 | |
---|
181 | /** |
---|
182 | * Constraint: |
---|
183 | * (atomStringRule=StringRule | atomRuleReference=RuleReference) |
---|
184 | */ |
---|
185 | protected void sequence_Atom(EObject context, Atom semanticObject) { |
---|
186 | genericSequencer.createSequence(context, semanticObject); |
---|
187 | } |
---|
188 | |
---|
189 | |
---|
190 | /** |
---|
191 | * Constraint: |
---|
192 | * (sectionheader=SectionHeading | rule=Rule) |
---|
193 | */ |
---|
194 | protected void sequence_BnfEntry(EObject context, BnfEntry semanticObject) { |
---|
195 | genericSequencer.createSequence(context, semanticObject); |
---|
196 | } |
---|
197 | |
---|
198 | |
---|
199 | /** |
---|
200 | * Constraint: |
---|
201 | * (singleDefinition+=SingleDefinition singleDefinition+=SingleDefinition*) |
---|
202 | */ |
---|
203 | protected void sequence_DefinitionList(EObject context, DefinitionList semanticObject) { |
---|
204 | genericSequencer.createSequence(context, semanticObject); |
---|
205 | } |
---|
206 | |
---|
207 | |
---|
208 | /** |
---|
209 | * Constraint: |
---|
210 | * (rule=Rule | sectionheader=SectionHeading | extRule=ExtRule) |
---|
211 | */ |
---|
212 | protected void sequence_DeltaEntry(EObject context, DeltaEntry semanticObject) { |
---|
213 | genericSequencer.createSequence(context, semanticObject); |
---|
214 | } |
---|
215 | |
---|
216 | |
---|
217 | /** |
---|
218 | * Constraint: |
---|
219 | * ( |
---|
220 | * (name=ID type='/bnf'? importSection=ImportSection? bnfEntry+=BnfEntry+) | |
---|
221 | * (type='/delta' importSection=ImportSection? deltaEntry+=DeltaEntry*) | |
---|
222 | * (type='/merge' importSection=ImportSection? mergeEntry+=MergeEntry*) |
---|
223 | * ) |
---|
224 | */ |
---|
225 | protected void sequence_EtsiBnf(EObject context, EtsiBnf semanticObject) { |
---|
226 | genericSequencer.createSequence(context, semanticObject); |
---|
227 | } |
---|
228 | |
---|
229 | |
---|
230 | /** |
---|
231 | * Constraint: |
---|
232 | * ((rulenumber=INT rulevariant=ID?)? name=ID ruleext=INT elements+=Atom*) |
---|
233 | */ |
---|
234 | protected void sequence_ExtRule(EObject context, ExtRule semanticObject) { |
---|
235 | genericSequencer.createSequence(context, semanticObject); |
---|
236 | } |
---|
237 | |
---|
238 | |
---|
239 | /** |
---|
240 | * Constraint: |
---|
241 | * logic=LOGIC |
---|
242 | */ |
---|
243 | protected void sequence_GlobalCombinator(EObject context, GlobalCombinator semanticObject) { |
---|
244 | if(errorAcceptor != null) { |
---|
245 | if(transientValues.isValueTransient(semanticObject, EbnfPackage.Literals.MERGE_RULE__LOGIC) == ValueTransient.YES) |
---|
246 | errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EbnfPackage.Literals.MERGE_RULE__LOGIC)); |
---|
247 | } |
---|
248 | INodesForEObjectProvider nodes = createNodeProvider(semanticObject); |
---|
249 | SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes); |
---|
250 | feeder.accept(grammarAccess.getGlobalCombinatorAccess().getLogicLOGICTerminalRuleCall_1_0(), semanticObject.getLogic()); |
---|
251 | feeder.finish(); |
---|
252 | } |
---|
253 | |
---|
254 | |
---|
255 | /** |
---|
256 | * Constraint: |
---|
257 | * definitionList+=DefinitionList |
---|
258 | */ |
---|
259 | protected void sequence_GroupedSequence(EObject context, GroupedSequence semanticObject) { |
---|
260 | genericSequencer.createSequence(context, semanticObject); |
---|
261 | } |
---|
262 | |
---|
263 | |
---|
264 | /** |
---|
265 | * Constraint: |
---|
266 | * (name=ID ruleext=INT logic=LOGIC? LABEL+=STRING+) |
---|
267 | */ |
---|
268 | protected void sequence_HookCombinator(EObject context, HookCombinator semanticObject) { |
---|
269 | genericSequencer.createSequence(context, semanticObject); |
---|
270 | } |
---|
271 | |
---|
272 | |
---|
273 | /** |
---|
274 | * Constraint: |
---|
275 | * imports+=Import+ |
---|
276 | */ |
---|
277 | protected void sequence_ImportSection(EObject context, ImportSection semanticObject) { |
---|
278 | genericSequencer.createSequence(context, semanticObject); |
---|
279 | } |
---|
280 | |
---|
281 | |
---|
282 | /** |
---|
283 | * Constraint: |
---|
284 | * (importURI=STRING (grammarType='core' | grammarType='package' | grammarType='update')? label=ID?) |
---|
285 | */ |
---|
286 | protected void sequence_Import(EObject context, Import semanticObject) { |
---|
287 | genericSequencer.createSequence(context, semanticObject); |
---|
288 | } |
---|
289 | |
---|
290 | |
---|
291 | /** |
---|
292 | * Constraint: |
---|
293 | * (sectionheader=SectionHeading | mergeRule=MergeRule) |
---|
294 | */ |
---|
295 | protected void sequence_MergeEntry(EObject context, MergeEntry semanticObject) { |
---|
296 | genericSequencer.createSequence(context, semanticObject); |
---|
297 | } |
---|
298 | |
---|
299 | |
---|
300 | /** |
---|
301 | * Constraint: |
---|
302 | * definitionList+=DefinitionList |
---|
303 | */ |
---|
304 | protected void sequence_OptionalSequence(EObject context, OptionalSequence semanticObject) { |
---|
305 | genericSequencer.createSequence(context, semanticObject); |
---|
306 | } |
---|
307 | |
---|
308 | |
---|
309 | /** |
---|
310 | * Constraint: |
---|
311 | * (definitions+=DefinitionList morethanonce?='+'?) |
---|
312 | */ |
---|
313 | protected void sequence_RepeatedSequence(EObject context, RepeatedSequence semanticObject) { |
---|
314 | genericSequencer.createSequence(context, semanticObject); |
---|
315 | } |
---|
316 | |
---|
317 | |
---|
318 | /** |
---|
319 | * Constraint: |
---|
320 | * (name=ID logic=LOGIC LABEL+=STRING*) |
---|
321 | */ |
---|
322 | protected void sequence_RuleCombinator(EObject context, RuleCombinator semanticObject) { |
---|
323 | genericSequencer.createSequence(context, semanticObject); |
---|
324 | } |
---|
325 | |
---|
326 | |
---|
327 | /** |
---|
328 | * Constraint: |
---|
329 | * ruleref=[Rule|ID] |
---|
330 | */ |
---|
331 | protected void sequence_RuleReference(EObject context, RuleReference semanticObject) { |
---|
332 | if(errorAcceptor != null) { |
---|
333 | if(transientValues.isValueTransient(semanticObject, EbnfPackage.Literals.RULE_REFERENCE__RULEREF) == ValueTransient.YES) |
---|
334 | errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EbnfPackage.Literals.RULE_REFERENCE__RULEREF)); |
---|
335 | } |
---|
336 | INodesForEObjectProvider nodes = createNodeProvider(semanticObject); |
---|
337 | SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes); |
---|
338 | feeder.accept(grammarAccess.getRuleReferenceAccess().getRulerefRuleIDTerminalRuleCall_0_1(), semanticObject.getRuleref()); |
---|
339 | feeder.finish(); |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | /** |
---|
344 | * Constraint: |
---|
345 | * ((rulenumber=INT rulevariant=ID?)? name=ID definitionList=DefinitionList?) |
---|
346 | */ |
---|
347 | protected void sequence_Rule(EObject context, Rule semanticObject) { |
---|
348 | genericSequencer.createSequence(context, semanticObject); |
---|
349 | } |
---|
350 | |
---|
351 | |
---|
352 | /** |
---|
353 | * Constraint: |
---|
354 | * sectionHeader=SECTIONHEADER |
---|
355 | */ |
---|
356 | protected void sequence_SectionHeading(EObject context, SectionHeading semanticObject) { |
---|
357 | if(errorAcceptor != null) { |
---|
358 | if(transientValues.isValueTransient(semanticObject, EbnfPackage.Literals.SECTION_HEADING__SECTION_HEADER) == ValueTransient.YES) |
---|
359 | errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, EbnfPackage.Literals.SECTION_HEADING__SECTION_HEADER)); |
---|
360 | } |
---|
361 | INodesForEObjectProvider nodes = createNodeProvider(semanticObject); |
---|
362 | SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes); |
---|
363 | feeder.accept(grammarAccess.getSectionHeadingAccess().getSectionHeaderSECTIONHEADERTerminalRuleCall_1_0(), semanticObject.getSectionHeader()); |
---|
364 | feeder.finish(); |
---|
365 | } |
---|
366 | |
---|
367 | |
---|
368 | /** |
---|
369 | * Constraint: |
---|
370 | * terms+=Term+ |
---|
371 | */ |
---|
372 | protected void sequence_SingleDefinition(EObject context, SingleDefinition semanticObject) { |
---|
373 | genericSequencer.createSequence(context, semanticObject); |
---|
374 | } |
---|
375 | |
---|
376 | |
---|
377 | /** |
---|
378 | * Constraint: |
---|
379 | * (literal=STRING | colon=COLON) |
---|
380 | */ |
---|
381 | protected void sequence_StringRule(EObject context, StringRule semanticObject) { |
---|
382 | genericSequencer.createSequence(context, semanticObject); |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | /** |
---|
387 | * Constraint: |
---|
388 | * (termAtom=Atom | termGroupedSequence=GroupedSequence | termOptionalSequence=OptionalSequence | termRepeatedSequence=RepeatedSequence) |
---|
389 | */ |
---|
390 | protected void sequence_Term(EObject context, Term semanticObject) { |
---|
391 | genericSequencer.createSequence(context, semanticObject); |
---|
392 | } |
---|
393 | } |
---|