package de.ugoe.cs.swe.bnftools.serializer;

import com.google.inject.Inject;
import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
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.AlternativeAlias;
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 EbnfSyntacticSequencer extends AbstractSyntacticSequencer {

	protected EbnfGrammarAccess grammarAccess;
	protected AbstractElementAlias match_ExtRule_SemicolonKeyword_5_q;
	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;
	protected AbstractElementAlias match_GlobalCombinator_SemicolonKeyword_2_q;
	protected AbstractElementAlias match_HookCombinator_SemicolonKeyword_8_q;
	protected AbstractElementAlias match_RuleCombinator_SemicolonKeyword_3_q;
	protected AbstractElementAlias match_Rule_SemicolonKeyword_4_q;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (EbnfGrammarAccess) access;
		match_ExtRule_SemicolonKeyword_5_q = new TokenAlias(false, true, grammarAccess.getExtRuleAccess().getSemicolonKeyword_5());
		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()));
		match_GlobalCombinator_SemicolonKeyword_2_q = new TokenAlias(false, true, grammarAccess.getGlobalCombinatorAccess().getSemicolonKeyword_2());
		match_HookCombinator_SemicolonKeyword_8_q = new TokenAlias(false, true, grammarAccess.getHookCombinatorAccess().getSemicolonKeyword_8());
		match_RuleCombinator_SemicolonKeyword_3_q = new TokenAlias(false, true, grammarAccess.getRuleCombinatorAccess().getSemicolonKeyword_3());
		match_Rule_SemicolonKeyword_4_q = new TokenAlias(false, true, grammarAccess.getRuleAccess().getSemicolonKeyword_4());
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode 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_ExtRule_SemicolonKeyword_5_q.equals(syntax))
				emit_ExtRule_SemicolonKeyword_5_q(semanticObject, getLastNavigableState(), syntaxNodes);
			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))
				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);
			else if(match_GlobalCombinator_SemicolonKeyword_2_q.equals(syntax))
				emit_GlobalCombinator_SemicolonKeyword_2_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_HookCombinator_SemicolonKeyword_8_q.equals(syntax))
				emit_HookCombinator_SemicolonKeyword_8_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_RuleCombinator_SemicolonKeyword_3_q.equals(syntax))
				emit_RuleCombinator_SemicolonKeyword_3_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Rule_SemicolonKeyword_4_q.equals(syntax))
				emit_Rule_SemicolonKeyword_4_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_ExtRule_SemicolonKeyword_5_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     (
	     '{' | 
	     '}' | 
	     '|' | 
	     '+' | 
	     '*' | 
	     '[' | 
	     ']' | 
	     '(' | 
	     ')'
	 )*
	 */
	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) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_GlobalCombinator_SemicolonKeyword_2_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_HookCombinator_SemicolonKeyword_8_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_RuleCombinator_SemicolonKeyword_3_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ';'?
	 */
	protected void emit_Rule_SemicolonKeyword_4_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
