| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| |
| package org.eclipse.osbp.xtext.gridsource.serializer; |
| |
| import com.google.inject.Inject; |
| import java.util.List; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.xtext.gridsource.services.GridSourceGrammarAccess; |
| import org.eclipse.xtext.IGrammarAccess; |
| import org.eclipse.xtext.RuleCall; |
| import org.eclipse.xtext.nodemodel.INode; |
| import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; |
| import org.eclipse.xtext.serializer.analysis.GrammarAlias.GroupAlias; |
| import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias; |
| import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable; |
| import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; |
| import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; |
| |
| @SuppressWarnings("all") |
| public class GridSourceSyntacticSequencer extends AbstractSyntacticSequencer { |
| |
| protected GridSourceGrammarAccess grammarAccess; |
| protected AbstractElementAlias match_XFunctionTypeRef___LeftParenthesisKeyword_0_0_RightParenthesisKeyword_0_2__q; |
| protected AbstractElementAlias match_XImportDeclaration_SemicolonKeyword_2_q; |
| |
| @Inject |
| protected void init(IGrammarAccess access) { |
| grammarAccess = (GridSourceGrammarAccess) access; |
| match_XFunctionTypeRef___LeftParenthesisKeyword_0_0_RightParenthesisKeyword_0_2__q = new GroupAlias(false, true, new TokenAlias(false, false, grammarAccess.getXFunctionTypeRefAccess().getLeftParenthesisKeyword_0_0()), new TokenAlias(false, false, grammarAccess.getXFunctionTypeRefAccess().getRightParenthesisKeyword_0_2())); |
| match_XImportDeclaration_SemicolonKeyword_2_q = new TokenAlias(false, true, grammarAccess.getXImportDeclarationAccess().getSemicolonKeyword_2()); |
| } |
| |
| @Override |
| protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { |
| if (ruleCall.getRule() == grammarAccess.getArrayBracketsRule()) |
| return getArrayBracketsToken(semanticObject, ruleCall, node); |
| return ""; |
| } |
| |
| /** |
| * ArrayBrackets : |
| * '[' ']' |
| * ; |
| */ |
| protected String getArrayBracketsToken(EObject semanticObject, RuleCall ruleCall, INode node) { |
| if (node != null) |
| return getTokenText(node); |
| return "[]"; |
| } |
| |
| @Override |
| protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { |
| if (transition.getAmbiguousSyntaxes().isEmpty()) return; |
| List<INode> transitionNodes = collectNodes(fromNode, toNode); |
| for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { |
| List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax); |
| if (match_XFunctionTypeRef___LeftParenthesisKeyword_0_0_RightParenthesisKeyword_0_2__q.equals(syntax)) |
| emit_XFunctionTypeRef___LeftParenthesisKeyword_0_0_RightParenthesisKeyword_0_2__q(semanticObject, getLastNavigableState(), syntaxNodes); |
| else if (match_XImportDeclaration_SemicolonKeyword_2_q.equals(syntax)) |
| emit_XImportDeclaration_SemicolonKeyword_2_q(semanticObject, getLastNavigableState(), syntaxNodes); |
| else acceptNodes(getLastNavigableState(), syntaxNodes); |
| } |
| } |
| |
| /** |
| * Ambiguous syntax: |
| * ('(' ')')? |
| * |
| * This ambiguous syntax occurs at: |
| * (rule start) (ambiguity) '=>' returnType=JvmTypeReference |
| */ |
| protected void emit_XFunctionTypeRef___LeftParenthesisKeyword_0_0_RightParenthesisKeyword_0_2__q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
| acceptNodes(transition, nodes); |
| } |
| |
| /** |
| * Ambiguous syntax: |
| * ';'? |
| * |
| * This ambiguous syntax occurs at: |
| * importedNamespace=QualifiedNameWithWildcard (ambiguity) (rule end) |
| * importedType=[JvmDeclaredType|QualifiedName] (ambiguity) (rule end) |
| * memberName=ValidID (ambiguity) (rule end) |
| * wildcard?='*' (ambiguity) (rule end) |
| */ |
| protected void emit_XImportDeclaration_SemicolonKeyword_2_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { |
| acceptNodes(transition, nodes); |
| } |
| |
| } |