use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState in project xtext-core by eclipse.
the class SemanticSequencerNfaProvider method createNfa.
protected SemNfa createNfa(Grammar grammar, ISynAbsorberState synState, EClass type) {
SynAbsorberNfaAdapter synNfa = new SynAbsorberNfaAdapter(synState);
// System.out.println(new NfaFormatter().format(synNfa));
Map<ISynAbsorberState, Integer> distanceMap = util.distanceToFinalStateMap(synNfa);
SemNfa nfa = util.create(util.sort(synNfa, distanceMap), new SemStateFactory());
// util.sortInplace(nfa, distanceMap);
if (type != null)
initContentValidationNeeded(type, nfa);
initRemainingFeatures(nfa.getStop(), util.inverse(nfa), Sets.<ISemState>newHashSet());
initOrderIDs(grammar, nfa);
// System.out.println(new NfaFormatter().format(nfa));
return nfa;
}
use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState in project xtext-core by eclipse.
the class AbstractSyntacticSequencer method enterAssignedAction.
@Override
public boolean enterAssignedAction(Action action, EObject semanticChild, ICompositeNode node) {
navigateToAbsorber(action, node);
boolean shouldEnter = delegate.enterAssignedAction(action, semanticChild, node);
if (shouldEnter) {
ISerializationContext child = SerializationContext.forChild(contexts.peek().context, action, semanticChild);
ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
if (pda == null)
throw new IllegalStateException();
SyntacticalContext j = new SyntacticalContext(child, semanticChild, pda, node);
contexts.push(j);
}
return shouldEnter;
}
use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState in project xtext-core by eclipse.
the class AbstractSyntacticSequencer method navigateToEmitter.
protected ISynFollowerOwner navigateToEmitter(ISynFollowerOwner fromState, INode fromNode, AbstractElement toEle, INode toNode, RuleCallStack stack) {
if (fromState instanceof ISynAbsorberState)
return fromState;
if (fromState instanceof ISynNavigable) {
ISynNavigable fromEmitter = (ISynNavigable) fromState;
if (!fromEmitter.hasEmitters())
return fromEmitter.getTarget();
List<ISynState> pathAndElement = fromEmitter.getShortestPathTo(toEle, stack);
if (pathAndElement == null) {
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createUnexpectedEmitterDiagnostic(fromEmitter, toEle, stack));
return null;
}
List<ISynState> path = pathAndElement.subList(0, pathAndElement.size() - 1);
accept(fromNode, path, stack);
return pathAndElement.get(pathAndElement.size() - 1);
}
throw new IllegalStateException();
}
use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState in project xtext-core by eclipse.
the class AbstractSyntacticSequencer method init.
@Override
public void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
INode node = NodeModelUtils.findActualNodeFor(semanticObject);
syntacticSequencerPDAs = pdaProvider.getSyntacticSequencerPDAs(grammar.getGrammar());
ISynAbsorberState state = syntacticSequencerPDAs.get(context);
Preconditions.checkNotNull(state, "Invalid context: " + context);
SyntacticalContext acceptor = new SyntacticalContext(context, semanticObject, state, node);
contexts.push(acceptor);
delegate = sequenceAcceptor;
this.errorAcceptor = errorAcceptor;
}
use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState in project xtext-core by eclipse.
the class AbstractSyntacticSequencer method enterAssignedParserRuleCall.
@Override
public boolean enterAssignedParserRuleCall(RuleCall rc, EObject semanticChild, ICompositeNode node) {
navigateToAbsorber(rc, node);
boolean shouldEnter = delegate.enterAssignedParserRuleCall(rc, semanticChild, node);
if (shouldEnter) {
ISerializationContext child = SerializationContext.forChild(contexts.peek().context, rc, semanticChild);
ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
if (pda == null)
throw new IllegalStateException();
SyntacticalContext j = new SyntacticalContext(child, semanticChild, pda, node);
contexts.push(j);
}
return shouldEnter;
}
Aggregations