Search in sources :

Example 1 with ISynState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState in project xtext-core by eclipse.

the class AbstractSyntacticSequencer method acceptNodes.

protected void acceptNodes(ISynNavigable fromState, INode fromNode, INode toNode) {
    RuleCallStack stack = contexts.peek().stack.clone();
    List<INode> nodes = collectNodes(fromNode, toNode);
    if (nodes != null) {
        for (INode next : nodes) {
            List<ISynState> path = fromState.getShortestPathTo((AbstractElement) next.getGrammarElement(), stack);
            if (path != null) {
                if (path.get(path.size() - 1) instanceof ISynEmitterState)
                    fromState = (ISynEmitterState) path.get(path.size() - 1);
                else
                    return;
                acceptNode(next);
            }
        }
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) ISynState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState) ISynEmitterState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynEmitterState)

Example 2 with ISynState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState 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();
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynNavigable(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable) ISynState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState)

Example 3 with ISynState

use of org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState in project xtext-core by eclipse.

the class AbstractSyntacticSequencer method navigateToAbsorber.

protected ISynAbsorberState navigateToAbsorber(ISynFollowerOwner fromState, INode fromNode, INode toNode, RuleCallStack stack) {
    if (fromState instanceof ISynAbsorberState)
        return (ISynAbsorberState) fromState;
    if (fromState instanceof ISynNavigable) {
        ISynNavigable fromEmitter = (ISynNavigable) fromState;
        // RCStack back = stack.clone();
        if (fromEmitter.hasEmitters()) {
            List<ISynState> path = fromEmitter.getShortestStackpruningPathToAbsorber(stack);
            accept(fromNode, path, stack);
        }
        return fromEmitter.getTarget();
    }
    throw new IllegalStateException();
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISynNavigable(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable) ISynState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState)

Aggregations

ISynState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynState)3 ISynAbsorberState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState)2 ISynNavigable (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable)2 INode (org.eclipse.xtext.nodemodel.INode)1 ISynEmitterState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynEmitterState)1