Commit 6dcf8add authored by Fred Eisele's avatar Fred Eisele
Browse files

make query clause attr preblock rather than block

parent 17b5398a
Loading
Loading
Loading
Loading
+34 −13
Changes for src/catdata/aql/exp/AqlLoaderListener.java: 34 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
		this.mapped_terms = new ParseTreeProperty<>();
		this.value_option = new ParseTreeProperty<>();
		this.terms = new ParseTreeProperty<>();
		this.prexps = new ParseTreeProperty<>();
		this.quads = new ParseTreeProperty<>();
	}
	public final List<Triple<String, Integer, Exp<?>>> decls;
@@ -855,6 +856,9 @@ public class AqlLoaderListener extends AqlParserBaseListener {
		this.exps.put(ctx, comp);
	}


	private final ParseTreeProperty<PreBlock> prexps;
	
	@Override public void exitQueryExp_Simple(AqlParser.QueryExp_SimpleContext ctx) {
		final SchemaKindContext sKind = ctx.schemaKind();
		final QuerySimpleSectionContext simpleSec = ctx.querySimpleSection();
@@ -862,8 +866,11 @@ public class AqlLoaderListener extends AqlParserBaseListener {
		final SchExp<Ty, En, Sym, Fk, Att>
		src = new SchExp.SchExpVar<>(sKind.getText());
		
		final QueryExpRaw.PreBlock 
		preblock = (PreBlock) this.prexps.get(simpleSec.queryClauseExpr());
		
		final QueryExpRaw.Block 
		block = (Block) this.exps.get(simpleSec.queryClauseExpr());
		block = new Block(preblock, new LocStr(ctx.getStart().getStartIndex(), "Q"));
		
		@SuppressWarnings("rawtypes")
		final QueryExp
@@ -878,20 +885,37 @@ public class AqlLoaderListener extends AqlParserBaseListener {
	@Override public void exitQueryExp_Literal(AqlParser.QueryExp_LiteralContext ctx) {
		final SchemaKindContext skind = ctx.schemaKind();
		final SchemaRefContext sref = ctx.schemaRef();
		final QueryLiteralSectionContext lits = ctx.queryLiteralSection();
		final QueryLiteralSectionContext ctx_lit = ctx.queryLiteralSection();
		
		final List<LocStr>
		imports = ctx_lit.queryRef().stream() 
				.map(elt -> makeLocStr(elt))
				.collect(Collectors.toList());
		
		final SchExp<Ty, En, Sym, Fk, Att>
		src = new SchExp.SchExpVar<>(ctx.schemaKind().getText());
		src = new SchExp.SchExpVar<>(skind.getText());
		
		final QueryExpRaw.Block 
		block = (Block) this.exps.get(lits.queryClauseExpr());
		final SchExp<Ty, En, Sym, Fk, Att>
		tgt = new SchExp.SchExpVar<>(sref.getText());
		
		final List<Pair<LocStr, PreBlock>>
		preblocks = ctx_lit.queryEntityExpr().stream() 
			.map(x -> (Pair<LocStr,PreBlock>) 
					new Pair<>(makeLocStr(x.queryClauseExpr()), 
							this.prexps.get(x.queryClauseExpr())))
			.collect(Collectors.toList());
		
		final List<Pair<String, String>> 
		options = parseOptions(ctx_lit.allOptions().optionsDeclaration());
		
		final List<Pair<LocStr, String>> params = new LinkedList<>();
		final List<Pair<LocStr, RawTerm>> consts = new LinkedList<>();
		
		@SuppressWarnings("rawtypes")
		final QueryExp
		simple = new QueryExpRawSimple(
				src, 
				ctx.getStart().getStartIndex(), 
				block);
		simple = new QueryExpRaw(
				params, consts, src, tgt, imports,
				preblocks, options);
		
		this.exps.put(ctx, simple);
	}
@@ -933,10 +957,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
		preblock = new PreBlock(fromClause, whereClause, atts, fks, 
				parseOptions(ctx.allOptions().optionsDeclaration()));
		
		final Block 
		block = new Block(preblock, new LocStr(ctx.getStart().getStartIndex(), "Q"));
		
		this.exps.put(ctx, block);
		this.prexps.put(ctx, preblock);
	}
	
	@Override public void exitQueryPath_Literal(AqlParser.QueryPath_LiteralContext ctx) {
+3 −41
Changes for src/catdata/aql/exp/QueryExpRaw.java: 3 added lines, 41 removed lines.
Original line number Diff line number Diff line
@@ -266,11 +266,9 @@ public class QueryExpRaw extends QueryExp<Ty, En, Sym, Fk, Att, En, Fk, Att> imp
			this.en = new En(en.str);
			this.enLoc = en.loc;
			this.gens = new HashSet<>();
			this.atts = LocStr.set2(b.atts).stream()
					.map(x -> new Pair<>(new Att(new En(en.str), x.first), x.second))
			this.atts = LocStr.set2(b.atts).stream().map(x -> new Pair<>(new Att(new En(en.str), x.first), x.second))
					.collect(Collectors.toSet());
			this.fks = LocStr.set2(b.fks).stream()
					.map(x -> new Pair<>(new Fk(new En(en.str), x.first), x.second))
			this.fks = LocStr.set2(b.fks).stream().map(x -> new Pair<>(new Fk(new En(en.str), x.first), x.second))
					.collect(Collectors.toSet());

			for (Pair<LocStr, String> gen : b.gens) {
@@ -481,8 +479,7 @@ public class QueryExpRaw extends QueryExp<Ty, En, Sym, Fk, Att, En, Fk, Att> imp
		return "literal : " + src + " -> " + dst + " {\n" + toString + "}";
	}

	public QueryExpRaw(List<Pair<LocStr, String>> params, List<Pair<LocStr, RawTerm>> consts, 
			SchExp<?, ?, ?, ?, ?> c, SchExp<?, ?, ?, ?, ?> d, List<LocStr> imports,
	public QueryExpRaw(List<Pair<LocStr, String>> params, List<Pair<LocStr, RawTerm>> consts, SchExp<?, ?, ?, ?, ?> c, SchExp<?, ?, ?, ?, ?> d, List<LocStr> imports,
			List<Pair<LocStr, PreBlock>> list, List<Pair<String, String>> options) {
		this.src = (SchExp<Ty, En, Sym, Fk, Att>) c;
		this.dst = (SchExp<Ty, En, Sym, Fk, Att>) d;
@@ -517,41 +514,6 @@ public class QueryExpRaw extends QueryExp<Ty, En, Sym, Fk, Att, En, Fk, Att> imp

	}

	public QueryExpRaw(Integer mode, List<Pair<LocStr, String>> params, List<Pair<LocStr, RawTerm>> consts, 
			SchExp<?, ?, ?, ?, ?> c, SchExp<?, ?, ?, ?, ?> d, List<LocStr> imports,
			List<Block> list, List<Pair<String, String>> options) {
		this.src = (SchExp<Ty, En, Sym, Fk, Att>) c;
		this.dst = (SchExp<Ty, En, Sym, Fk, Att>) d;
		this.imports = LocStr.set1(imports);
		this.options = Util.toMapSafely(options);
		this.consts = new Ctx<>(Util.toMapSafely(LocStr.set2(consts)));
		this.params = new Ctx<>(Util.toMapSafely(LocStr.set2(params)));
		this.blocks = Util.toSetSafely(list);
		
		for (Pair<LocStr, PreBlock> x : list) {
			b1.put(new En(x.first.str), x.first.loc);

			for (Pair<LocStr, Trans> y : x.second.fks) {
				b2.put(new Fk(new En(x.first.str), y.first.str), y.first.loc);
			}

			for (Pair<LocStr, RawTerm> y : x.second.atts) {
				b3.put(new Att(new En(x.first.str), y.first.str), y.first.loc);
			}
		}

		raw.put("imports", InteriorLabel.imports("imports", imports));

		for (Pair<LocStr, PreBlock> p : list) {
			List<InteriorLabel<Object>> f = new LinkedList<>();

			f.add(new InteriorLabel<>("entities", p.second, p.first.loc, x -> p.first.str).conv());

			raw.put(p.first.str, f);
		}

	}

	private Ctx<String, List<InteriorLabel<Object>>> raw = new Ctx<>();

	@Override