1 | package de.ugoe.cs.swe.bnftools.serializer; |
---|
2 | |
---|
3 | import com.google.inject.Inject; |
---|
4 | import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess; |
---|
5 | import java.util.List; |
---|
6 | import org.eclipse.emf.ecore.EObject; |
---|
7 | import org.eclipse.xtext.IGrammarAccess; |
---|
8 | import org.eclipse.xtext.RuleCall; |
---|
9 | import org.eclipse.xtext.nodemodel.INode; |
---|
10 | import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; |
---|
11 | import org.eclipse.xtext.serializer.analysis.GrammarAlias.AlternativeAlias; |
---|
12 | import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias; |
---|
13 | import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable; |
---|
14 | import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; |
---|
15 | import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; |
---|
16 | |
---|
17 | @SuppressWarnings("all") |
---|
18 | public class EbnfSyntacticSequencer extends AbstractSyntacticSequencer { |
---|
19 | |
---|
20 | protected EbnfGrammarAccess grammarAccess; |
---|
21 | protected AbstractElementAlias match_ExtRule_SemicolonKeyword_5_q; |
---|
22 | protected AbstractElementAlias match_ExtRule___AsteriskKeyword_4_8_or_LeftCurlyBracketKeyword_4_7_or_LeftParenthesisKeyword_4_5_or_LeftSquareBracketKeyword_4_6_or_PlusSignKeyword_4_9_or_RightCurlyBracketKeyword_4_3_or_RightParenthesisKeyword_4_1_or_RightSquareBracketKeyword_4_2_or_VerticalLineKeyword_4_4__a; |
---|
23 | protected AbstractElementAlias match_GlobalCombinator_SemicolonKeyword_2_q; |
---|
24 | protected AbstractElementAlias match_HookCombinator_SemicolonKeyword_8_q; |
---|
25 | protected AbstractElementAlias match_RuleCombinator_SemicolonKeyword_3_q; |
---|
26 | protected AbstractElementAlias match_Rule_SemicolonKeyword_4_q; |
---|
27 | |
---|
28 | @Inject |
---|
29 | protected void init(IGrammarAccess access) { |
---|
30 | grammarAccess = (EbnfGrammarAccess) access; |
---|
31 | match_ExtRule_SemicolonKeyword_5_q = new TokenAlias(false, true, grammarAccess.getExtRuleAccess().getSemicolonKeyword_5()); |
---|
32 | match_ExtRule___AsteriskKeyword_4_8_or_LeftCurlyBracketKeyword_4_7_or_LeftParenthesisKeyword_4_5_or_LeftSquareBracketKeyword_4_6_or_PlusSignKeyword_4_9_or_RightCurlyBracketKeyword_4_3_or_RightParenthesisKeyword_4_1_or_RightSquareBracketKeyword_4_2_or_VerticalLineKeyword_4_4__a = new AlternativeAlias(true, true, new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getAsteriskKeyword_4_8()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getLeftCurlyBracketKeyword_4_7()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getLeftParenthesisKeyword_4_5()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getLeftSquareBracketKeyword_4_6()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getPlusSignKeyword_4_9()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getRightCurlyBracketKeyword_4_3()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getRightParenthesisKeyword_4_1()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getRightSquareBracketKeyword_4_2()), new TokenAlias(false, false, grammarAccess.getExtRuleAccess().getVerticalLineKeyword_4_4())); |
---|
33 | match_GlobalCombinator_SemicolonKeyword_2_q = new TokenAlias(false, true, grammarAccess.getGlobalCombinatorAccess().getSemicolonKeyword_2()); |
---|
34 | match_HookCombinator_SemicolonKeyword_8_q = new TokenAlias(false, true, grammarAccess.getHookCombinatorAccess().getSemicolonKeyword_8()); |
---|
35 | match_RuleCombinator_SemicolonKeyword_3_q = new TokenAlias(false, true, grammarAccess.getRuleCombinatorAccess().getSemicolonKeyword_3()); |
---|
36 | match_Rule_SemicolonKeyword_4_q = new TokenAlias(false, true, grammarAccess.getRuleAccess().getSemicolonKeyword_4()); |
---|
37 | } |
---|
38 | |
---|
39 | @Override |
---|
40 | protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { |
---|
41 | return ""; |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | @Override |
---|
46 | protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { |
---|
47 | if (transition.getAmbiguousSyntaxes().isEmpty()) return; |
---|
48 | List<INode> transitionNodes = collectNodes(fromNode, toNode); |
---|
49 | for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { |
---|
50 | List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax); |
---|
51 | if(match_ExtRule_SemicolonKeyword_5_q.equals(syntax)) |
---|
52 | emit_ExtRule_SemicolonKeyword_5_q(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
53 | else if(match_ExtRule___AsteriskKeyword_4_8_or_LeftCurlyBracketKeyword_4_7_or_LeftParenthesisKeyword_4_5_or_LeftSquareBracketKeyword_4_6_or_PlusSignKeyword_4_9_or_RightCurlyBracketKeyword_4_3_or_RightParenthesisKeyword_4_1_or_RightSquareBracketKeyword_4_2_or_VerticalLineKeyword_4_4__a.equals(syntax)) |
---|
54 | emit_ExtRule___AsteriskKeyword_4_8_or_LeftCurlyBracketKeyword_4_7_or_LeftParenthesisKeyword_4_5_or_LeftSquareBracketKeyword_4_6_or_PlusSignKeyword_4_9_or_RightCurlyBracketKeyword_4_3_or_RightParenthesisKeyword_4_1_or_RightSquareBracketKeyword_4_2_or_VerticalLineKeyword_4_4__a(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
55 | else if(match_GlobalCombinator_SemicolonKeyword_2_q.equals(syntax)) |
---|
56 | emit_GlobalCombinator_SemicolonKeyword_2_q(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
57 | else if(match_HookCombinator_SemicolonKeyword_8_q.equals(syntax)) |
---|
58 | emit_HookCombinator_SemicolonKeyword_8_q(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
59 | else if(match_RuleCombinator_SemicolonKeyword_3_q.equals(syntax)) |
---|
60 | emit_RuleCombinator_SemicolonKeyword_3_q(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
61 | else if(match_Rule_SemicolonKeyword_4_q.equals(syntax)) |
---|
62 | emit_Rule_SemicolonKeyword_4_q(semanticObject, getLastNavigableState(), syntaxNodes); |
---|
63 | else acceptNodes(getLastNavigableState(), syntaxNodes); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * Syntax: |
---|
69 | * ';'? |
---|
70 | */ |
---|
71 | protected void emit_ExtRule_SemicolonKeyword_5_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
72 | acceptNodes(transition, nodes); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Syntax: |
---|
77 | * ( |
---|
78 | ']' | |
---|
79 | '(' | |
---|
80 | '|' | |
---|
81 | '}' | |
---|
82 | '*' | |
---|
83 | '+' | |
---|
84 | '{' | |
---|
85 | ')' | |
---|
86 | '[' |
---|
87 | )* |
---|
88 | */ |
---|
89 | protected void emit_ExtRule___AsteriskKeyword_4_8_or_LeftCurlyBracketKeyword_4_7_or_LeftParenthesisKeyword_4_5_or_LeftSquareBracketKeyword_4_6_or_PlusSignKeyword_4_9_or_RightCurlyBracketKeyword_4_3_or_RightParenthesisKeyword_4_1_or_RightSquareBracketKeyword_4_2_or_VerticalLineKeyword_4_4__a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
90 | acceptNodes(transition, nodes); |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * Syntax: |
---|
95 | * ';'? |
---|
96 | */ |
---|
97 | protected void emit_GlobalCombinator_SemicolonKeyword_2_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
98 | acceptNodes(transition, nodes); |
---|
99 | } |
---|
100 | |
---|
101 | /** |
---|
102 | * Syntax: |
---|
103 | * ';'? |
---|
104 | */ |
---|
105 | protected void emit_HookCombinator_SemicolonKeyword_8_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
106 | acceptNodes(transition, nodes); |
---|
107 | } |
---|
108 | |
---|
109 | /** |
---|
110 | * Syntax: |
---|
111 | * ';'? |
---|
112 | */ |
---|
113 | protected void emit_RuleCombinator_SemicolonKeyword_3_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
114 | acceptNodes(transition, nodes); |
---|
115 | } |
---|
116 | |
---|
117 | /** |
---|
118 | * Syntax: |
---|
119 | * ';'? |
---|
120 | */ |
---|
121 | protected void emit_Rule_SemicolonKeyword_4_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
---|
122 | acceptNodes(transition, nodes); |
---|
123 | } |
---|
124 | |
---|
125 | } |
---|