use of ast.Ast.Doc in project L42 by ElvisResearchGroup.
the class ToAst method visitClassBReuse.
@Override
public Expression visitClassBReuse(ClassBReuseContext ctx) {
Doc doc1 = Doc.empty();
if (ctx.docsOpt().size() >= 1) {
doc1 = parseDoc(ctx.docsOpt().get(0));
}
//Note: if exists ctx.docsOpt().get(1)) it is ignored.
assert ctx.getChild(0).getText().equals("{");
assert ctx.getChild(2).getText().startsWith("reuse");
String url = ctx.getChild(2).getText();
url = url.trim();
List<Member> ms = visitMembers(ctx.member());
ClassB inner = new ClassB(doc1, new Ast.TraitHeader(), Collections.emptyList(), Collections.emptyList(), ms, position(ctx));
return new Expression.ClassReuse(inner, url, null);
}
use of ast.Ast.Doc in project L42 by ElvisResearchGroup.
the class ToAst method parseType.
private Type parseType(TContext t) {
if (t.concreteT() != null) {
ConcreteTContext tt = t.concreteT();
Doc d = parseDoc(tt.docsOpt());
Ast.Type nt = new Ast.Type(Mdf.fromString((tt.Mdf() == null) ? "" : nameK(tt.Mdf())), Ast.Path.sugarParse(nameU(tt.Path())), d);
if (tt.Ph() == null) {
return nt;
}
return Functions.toPh(nt);
}
if (t.historicalT() != null) {
HistoricalTContext tt = t.historicalT();
Doc d = parseDoc(tt.docsOpt());
Path p = ast.Ast.Path.sugarParse(nameU(tt.Path()));
List<MethodSelectorX> mss = new ArrayList<MethodSelectorX>();
for (HistoricalSeqContext ms : tt.historicalSeq()) {
mss.add(parseMethSelectorX(ms));
}
//return new ast.Ast.HistoricType(p,mss,d);
throw Assertions.codeNotReachable();
}
throw Assertions.codeNotReachable();
}
use of ast.Ast.Doc in project L42 by ElvisResearchGroup.
the class ToAst method visitRoundBlockAux.
private Expression visitRoundBlockAux(ParserRuleContext ctx, DocsOptContext docsOpt, List<BbContext> bB, ETopContext eTop) {
Doc doc = parseDoc(docsOpt);
List<BlockContent> contents = new ArrayList<BlockContent>();
for (BbContext b : bB) {
List<VarDec> decs = new ArrayList<VarDec>();
for (DContext d : b.d()) {
decs.add(parseVDec(d));
}
assert b.ks() != null;
List<Catch> _catch = parseKs(b.ks());
contents.add(new BlockContent(decs, _catch));
}
Expression inner = eTop.accept(this);
return new Expression.RoundBlock(position(ctx), doc, inner, contents);
}
use of ast.Ast.Doc in project L42 by ElvisResearchGroup.
the class ToAst method visitClassB.
@Override
public Expression visitClassB(ClassBContext ctx) {
//the number 1 if present is ignored
Doc doc1 = parseDoc(ctx.docsOpt().get(0));
Header h = parseHeader(ctx.header());
List<Type> supertypes = new ArrayList<>();
ImplsContext impl = ctx.impls();
if (impl != null) {
{
int i = -1;
for (TerminalNode p : impl.Path()) {
i += 1;
supertypes.add(Path.sugarParse(nameU(p)).toImmNT().withDoc(parseDoc(impl.docsOpt().get(0))));
}
}
}
List<Member> ms = visitMembers(ctx.member());
List<Ast.FieldDec> fs = new ArrayList<>();
for (FieldDecContext f : ctx.fieldDec()) {
fs.add(parseFieldDec(f));
}
return new Expression.ClassB(doc1, h, fs, supertypes, ms, position(ctx));
}
use of ast.Ast.Doc in project L42 by ElvisResearchGroup.
the class Errors42 method errorIncoherentRedirectMapping.
/* static void checkCoherentMapping(List<PathPath> setVisited) {
// setVisited is a set of individual redirected classes,
// created by walking the sub-tree under each cascade redirect.
// getPath1() is the path in the library before redirecting.
// getPath2() is the proposed path in the redirected library.
// We will allow many paths to be redirected into a single new path,
// but not vice-versa.
for(PathPath p1:setVisited){
for(PathPath p2:setVisited){
if(p1.equals(p2)){continue;}
if(p1.getPath1().equals(p2.getPath1())){
throw errorIncoherentRedirectMapping(setVisited, p1.getPath1(),p1.getPath2(),p2.getPath2());
}
}
}
return;
}*/
static Error errorIncoherentRedirectMapping(List<PathPath> verified, List<PathSPath> ambiguities, Path incoSrc, List<Path> _incoDest) {
Doc src = Doc.empty();
Doc dest = Doc.empty();
//Doc ambig=Doc.empty();
for (PathPath v : verified) {
src = src.sum(formatPathIn(v.getPath1().getCBar()));
dest = dest.sum(formatPathOut(v.getPath2()));
}
for (PathSPath a : ambiguities) {
//if(a.getPaths().size()!=1){
// ambig=ambig.sum(formatPathIn(a.getPath().getCBar()));
// ambig=ambig.sum(Doc.factory("@"+a.getPaths().size()));
// }
Doc srci = formatPathIn(a.getPath().getCBar());
for (Path pij : a.getPathsSet()) {
src = src.sum(srci);
dest = dest.sum(formatPathOut(pij));
}
}
Doc incoDest = Doc.empty();
for (Path pi : _incoDest) {
incoDest = incoDest.sum(formatPathOut(pi));
}
return Resources.Error.multiPartStringError("IncoherentRedirectMapping", "Src", src.formatNewLinesAsList(), "Dest", dest.formatNewLinesAsList(), //"Ambiguities",ambig.formatNewLinesAsList(),
"IncoherentSrc", incoSrc == null ? Doc.empty() : formatPathIn(incoSrc.getCBar()), "IncoherentDest", incoDest.formatNewLinesAsList());
}
Aggregations