OTLDListener extends otldBaseListener { public Type getArrType(String ctxType) { switch (ctxType) { case "boolean": return Type.BOOLARR; case "int": return Type.INTARR; case "char": return Type.CHARARR; default: return null; } } OTLDListener(); static OTLDListener parseFile(InputStream reader); List<Error> getErrors(); Program getProgram(); Type getType(String ctxType); Type getArrType(String ctxType); Variable getVariable(String id); @Override void enterCity(otldParser.CityContext ctx); @Override void enterCompany(otldParser.CompanyContext ctx); @Override void exitCompany(otldParser.CompanyContext ctx); @Override void enterDeftrain(otldParser.DeftrainContext ctx); @Override void enterDefwagon(otldParser.DefwagonContext ctx); @Override void enterFactory(otldParser.FactoryContext ctx); @Override void enterDeffactory(otldParser.DeffactoryContext ctx); @Override void exitDeffactory(otldParser.DeffactoryContext ctx); @Override void enterDefsignal(otldParser.DefsignalContext ctx); @Override void enterDefwaypoint(otldParser.DefwaypointContext ctx); @Override void exitDefwaypoint(otldParser.DefwaypointContext ctx); @Override void enterDefcircle(otldParser.DefcircleContext ctx); @Override void exitDefcircle(otldParser.DefcircleContext ctx); @Override void enterIfcond(otldParser.IfcondContext ctx); @Override void enterIfcondcase(otldParser.IfcondcaseContext ctx); @Override void exitIfcondcase(otldParser.IfcondcaseContext ctx); @Override void enterStop(otldParser.StopContext ctx); @Override void enterLoad(otldParser.LoadContext ctx); @Override void enterTransfer(otldParser.TransferContext ctx); @Override void enterTransport(otldParser.TransportContext ctx); @Override void enterInvert(otldParser.InvertContext ctx); @Override void enterUnarymin(otldParser.UnaryminContext ctx); @Override void enterWrite(otldParser.WriteContext ctx); @Override void enterInput(otldParser.InputContext ctx);  }
@Test public void testGetArrType() throws Exception { OTLDListener rail = new OTLDListener(); String bool = "boolean"; String integer = "int"; String character = "char"; String err1 = "Boolean"; String err2 = "bool"; String err3 = "integer"; String err4 = "booleaN"; String err5 = "character"; assertEquals(Type.BOOLARR, rail.getArrType(bool)); assertEquals(Type.CHARARR, rail.getArrType(character)); assertEquals(Type.INTARR, rail.getArrType(integer)); assertNull(rail.getArrType(err1)); assertNull(rail.getArrType(err2)); assertNull(rail.getArrType(err3)); assertNull(rail.getArrType(err4)); assertNull(rail.getArrType(err5)); }