Exception when editing TTCN3 code
When changing line 13 from var octetstring vl_char := "";
to var octetstring vl_char := '';
then an exception is dropped:
Exception in thread "Thread-38" java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 2 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606) at java.base/java.lang.String.substring(String.java:2709) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Lexer.HSTRING_action(Ttcn3Lexer.java:687) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Lexer.action(Ttcn3Lexer.java:551) at org.antlr.v4.runtime.atn.LexerCustomAction.execute(LexerCustomAction.java:97) at org.antlr.v4.runtime.atn.LexerActionExecutor.execute(LexerActionExecutor.java:168) at org.antlr.v4.runtime.atn.LexerATNSimulator.accept(LexerATNSimulator.java:369) at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:302) at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:233) at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:117) at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141) at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169) at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152) at org.antlr.v4.runtime.BufferedTokenStream.nextTokenOnChannel(BufferedTokenStream.java:325) at org.antlr.v4.runtime.CommonTokenStream.adjustSeekIndex(CommonTokenStream.java:70) at org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:137) at org.antlr.v4.runtime.Parser.consume(Parser.java:571) at org.antlr.v4.runtime.Parser.match(Parser.java:203) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_AssignmentChar(Ttcn3Parser.java:45237) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_SingleVarInstance(Ttcn3Parser.java:22435) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_VarList(Ttcn3Parser.java:22312) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_VarInstance(Ttcn3Parser.java:22045) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_FunctionLocalInst(Ttcn3Parser.java:13684) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_FunctionStatementOrDef(Ttcn3Parser.java:13564) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_FunctionStatementOrDefList(Ttcn3Parser.java:13490) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_StatementBlock(Ttcn3Parser.java:35621) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_TestcaseDef(Ttcn3Parser.java:15668) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_ModuleDef(Ttcn3Parser.java:2111) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_ModuleDefinition(Ttcn3Parser.java:1891) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_ModuleDefinitionsList(Ttcn3Parser.java:1831) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_TTCN3Module(Ttcn3Parser.java:1285) at org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3Parser.pr_TTCN3File(Ttcn3Parser.java:1007) at org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3Analyzer.parse(TTCN3Analyzer.java:218) at org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3Analyzer.parse(TTCN3Analyzer.java:140) at org.eclipse.titan.designer.parsers.ProjectSourceSyntacticAnalyzer.fileBasedGeneralAnalysis(ProjectSourceSyntacticAnalyzer.java:910) at org.eclipse.titan.designer.parsers.ProjectSourceSyntacticAnalyzer.fileBasedTTCN3Analysis(ProjectSourceSyntacticAnalyzer.java:871) at org.eclipse.titan.designer.parsers.ProjectSourceSyntacticAnalyzer.access$000(ProjectSourceSyntacticAnalyzer.java:77) at org.eclipse.titan.designer.parsers.ProjectSourceSyntacticAnalyzer$2.run(ProjectSourceSyntacticAnalyzer.java:474) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840)
module BinaryBody {
type component MAIN_CT {}
type enumerated STATE {
OCT,
CHAR
}
testcase tc_binary() runs on MAIN_CT {
const octetstring vl_isup := '011160'O; // removed whole msg for security
var octetstring vl_oct := ''O;
var octetstring vl_char := "";
var STATE vl_state := OCT;
for(var integer i := 0; i < lengthof(vl_isup); i := i + 1) {
if(oct2int(vl_isup[i]) <= 127) {
vl_oct := vl_oct & vl_isup[i];
if(vl_state == CHAR) {
if(lengthof(vl_char) > 0) {
action("...then: ", vl_char);
vl_char := "";
}
}
vl_state := OCT;
} else {
vl_char := vl_char & vl_isup[i];
if(vl_state == OCT) {
if(lengthof(vl_oct) > 0) {
action("...then: ", oct2char(vl_oct));
vl_oct := ''O;
}
}
vl_state := CHAR;
}
}
}
control {
execute(tc_binary());
}
}