Skip to content

Commit

Permalink
sccharts: Added xtext aid in serializing method calls inside methods
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sr committed Jul 23, 2024
1 parent 2d4e206 commit c9cba71
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ import com.google.inject.Inject
import de.cau.cs.kieler.kexpressions.Expression
import de.cau.cs.kieler.kexpressions.IntValue
import de.cau.cs.kieler.kexpressions.OperatorExpression
import de.cau.cs.kieler.kexpressions.ReferenceCall
import de.cau.cs.kieler.sccharts.ControlflowRegion
import de.cau.cs.kieler.sccharts.DeferredType
import de.cau.cs.kieler.sccharts.DelayType
import de.cau.cs.kieler.sccharts.HistoryType
import de.cau.cs.kieler.sccharts.SCChartsPackage
import de.cau.cs.kieler.sccharts.State
import de.cau.cs.kieler.sccharts.Transition
import de.cau.cs.kieler.sccharts.text.parser.InternalSCTXParser
import de.cau.cs.kieler.sccharts.text.services.SCTXGrammarAccess
import de.cau.cs.kieler.scl.Assignment
import de.cau.cs.kieler.scl.MethodImplementationDeclaration
import org.eclipse.xtext.serializer.ISerializationContext

import static de.cau.cs.kieler.kexpressions.OperatorType.*
import de.cau.cs.kieler.sccharts.DeferredType

/**
* @author als
Expand Down Expand Up @@ -214,6 +216,39 @@ class SCTXSemanticSequencer extends AbstractSCTXSemanticSequencer {
feeder.finish
}


/**
* Helps backtracking to serialize method calls
*/
override protected sequence_SclAssignment_SclEffectAssignment_SclPostfixAssignment(ISerializationContext context, Assignment asm) {
if (asm.expression instanceof ReferenceCall) {
sequence_SclEffectAssignment(context, asm);
} else {
genericSequencer.createSequence(context, asm);
}
}

/**
* Helps backtracking to serialize method calls
*/
override protected sequence_SclEffectAssignment(ISerializationContext context, Assignment asm) {
if (asm.expression instanceof ReferenceCall) {
val feeder = createSequencerFeeder(asm, createNodeProvider(asm))
val nodes = nodeProvider.getNodesForSemanticObject(asm, null)
val g = sclEffectAssignmentAccess

feeder.accept(g.expressionReferenceCallParserRuleCall_1_0_0, asm.expression)
if (!asm.schedule.empty) {
feeder.accept(g.scheduleScheduleObjectReferenceParserRuleCall_2_1_0, asm.schedule)
}
if (asm.semicolon) {
feeder.accept(g.semicolonSemicolonKeyword_3_0)
}
} else {
super.sequence_SclEffectAssignment(context, asm)
}
}

private static val prefixOperators = newHashSet(NOT, PRE, VAL)

private def boolean requiresParentheses(Expression exp) {
Expand Down

0 comments on commit c9cba71

Please sign in to comment.