Commit 43e47ef7 authored by Fred Eisele's avatar Fred Eisele
Browse files

refactor and add placeholders to loader

parent 8866b755
// Generated from /home/fred/.boot/cache/tmp/home/fred/github/fql2/gen_src/catdata/aql/grammar/f04/-ru88jt/AqlLexerRules.g4 by ANTLR 4.7
// Generated from /home/fred/.boot/cache/tmp/home/fred/github/fql2/gen_src/catdata/aql/grammar/9qb/-ru88jt/AqlLexerRules.g4 by ANTLR 4.7
package catdata.aql.grammar;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,49 +9,49 @@ commandAssignment : COMMAND commandId EQUAL commandExp ;
commandExp
: EXEC_CMDLINE
(LBRACE commandCmdLineSection RBRACE)?
#Command_CmdLine
# CommandExp_CmdLine
| EXEC_JS
(LBRACE commandExecJsSection RBRACE)?
#Command_ExecJs
# CommandExp_ExecJs
| EXEC_JDBC commandJdbcClass commandJdbcUri
(LBRACE commandExecJdbcSection RBRACE)?
#Command_ExecJdbc
# CommandExp_ExecJdbc
| CHECK constraintRef instanceRef
#Command_Check
# CommandExp_Check
| ASSERT_CONSISTENT instanceRef
#Command_AssertConsistent
# CommandExp_AssertConsistent
| EXPORT_CSV_INSTANCE instanceRef commandFile
(LBRACE commandExportCsvSection RBRACE)?
#Command_ExportCsvInstance
# CommandExp_ExportCsvInstance
| EXPORT_CSV_TRANSFORM transformRef commandFile
(LBRACE commandExportCsvSection RBRACE)?
#Command_ExportCsvTransform
# CommandExp_ExportCsvTransform
| EXPORT_JDBC_INSTANCE instanceRef
(commandJdbcClass (commandJdbcUri commandPrefixDst?)?)?
(LBRACE commandExportJdbcSection RBRACE)?
#Command_ExportJdbcInstance
# CommandExp_ExportJdbcInstance
| EXPORT_JDBC_QUERY queryRef
(commandJdbcClass (commandJdbcUri (commandPrefixSrc commandPrefixDst?)?)?)?
(LBRACE commandExportJdbcSection RBRACE)?
#Command_ExportJdbcQuery
#CommandExp_ExportJdbcQuery
| EXPORT_JDBC_TRANSFORM transformRef
(commandJdbcClass (commandJdbcUri commandPrefix?)?)?
(LBRACE commandExportJdbcSection RBRACE)?
(LBRACE commandExportJdbcSection RBRACE)?
#Command_ExportJdbcTransform
#CommandExp_ExportJdbcTransform
| ADD_TO_CLASSPATH
(LBRACE commandAddClasspathSection RBRACE)?
#Command_AddToClasspath
#CommandExp_AddToClasspath
;
commandKind
......
......@@ -9,7 +9,8 @@ constraintAssignment : CONSTRAINTS constraintId EQUAL constraintExp ;
constraintExp
: LITERAL COLON schemaRef
(LBRACE constraintLiteralSection? RBRACE)? #ConstraintExp_Literal
(LBRACE constraintLiteralSection? RBRACE)?
# ConstraintExp_Literal
;
constraintKind
......
......@@ -9,7 +9,7 @@ graphAssignment : GRAPH graphId EQUAL graphExp ;
graphExp
: LITERAL
(LBRACE graphLiteralSection RBRACE)?
#Graph_Literal
#GraphExp_Literal
;
graphKind
......
......@@ -8,100 +8,100 @@ instanceAssignment : INSTANCE instanceId EQUAL instanceExp ;
instanceExp
: EMPTY COLON schemaKind
#Instance_Empty
# InstanceExp_Empty
| SRC transformKind
#Instance_Src
# InstanceExp_Src
| DST transformKind
#Instance_Dst
# InstanceExp_Dst
| DISTINCT instanceKind
#Instance_Distinct
# InstanceExp_Distinct
| EVAL queryKind instanceKind
(LBRACE instanceEvalSection RBRACE)?
#Instance_Eval
# InstanceExp_Eval
| COEVAL queryKind instanceKind
(LBRACE instanceCoevalSection RBRACE)?
#Instance_Coeval
# InstanceExp_Coeval
| DELTA mappingKind instanceKind
#Instance_Delta
# InstanceExp_Delta
| SIGMA mappingKind instanceKind
(LBRACE instanceSigmaSection RBRACE)?
#Instance_Sigma
# InstanceExp_Sigma
| COPRODUCT_SIGMA (mappingKind instanceKind)+ COLON schemaKind
(LBRACE instanceCoprodSigmaSection RBRACE)?
#Instance_CoSigma
# InstanceExp_CoSigma
| COPRODUCT instanceKind (PLUS instanceKind)* COLON schemaKind
(LBRACE instanceCoprodSection RBRACE)?
#Instance_Coprod
# InstanceExp_Coprod
| UNION instanceKind (PLUS instanceKind)* COLON schemaKind
(LBRACE instanceCoprodSection RBRACE)?
#Instance_Union
# InstanceExp_Union
| COPRODUCT_UNRESTRICTED instanceRef (PLUS instanceRef)* COLON schemaKind
(LBRACE instanceCoprodUnrestrictSection RBRACE)?
#Instance_CoprodUn
# InstanceExp_CoprodUn
| COEQUALIZE transformKind transformKind
(LBRACE instanceCoequalizeSection RBRACE)?
#Instance_CoEqual
# InstanceExp_CoEqual
| COLIMIT graphKind schemaKind
(LBRACE instanceColimitSection RBRACE)?
#Instance_CoLimit
# InstanceExp_CoLimit
| IMPORT_JDBC jdbcClass jdbcUri COLON schemaKind
(LBRACE instanceImportJdbcSection RBRACE)?
#Instance_ImportJdbc
# InstanceExp_ImportJdbc
| QUOTIENT_JDBC (jdbcClass (jdbcUri)?)? instanceKind
(LBRACE instanceQuotientJdbcSection RBRACE)?
#Instance_QuotientJdbc
# InstanceExp_QuotientJdbc
| QUOTIENT_CSV schemaExp
(LBRACE instanceQuotientCsvSection RBRACE)?
#Instance_QuotientCsv
# InstanceExp_QuotientCsv
| IMPORT_JDBC_ALL (jdbcClass (jdbcUri)?)?
(LBRACE instanceImportJdbcAllSection RBRACE)?
#Instance_ImportJdbcAll
# InstanceExp_ImportJdbcAll
| IMPORT_CSV instanceFile COLON schemaRef
(LBRACE instanceImportCsvSection RBRACE)?
#Instance_ImportCsv
| LITERAL COLON schemaKind
(LBRACE instanceLiteralSection RBRACE)?
#Instance_Literal
# InstanceExp_ImportCsv
| QUOTIENT instanceRef
(LBRACE instanceQuotientSection RBRACE)?
#Instance_Quotient
# InstanceExp_Quotient
| CHASE constraintKind+ instanceKind INTEGER?
#Instance_Chase
# InstanceExp_Chase
| RANDOM COLON schemaRef
(LBRACE instanceRandomSection RBRACE)?
#Instance_Random
# InstanceExp_Random
| ANONYMIZE instanceRef
#Instance_Anonymize
# InstanceExp_Anonymize
| FROZEN queryRef schemaRef
#Instance_Frozen
# InstanceExp_Frozen
| PI queryKind instanceKind
(LBRACE instancePiSection RBRACE)?
#Instance_Pi
# InstanceExp_Pi
| LITERAL COLON schemaKind
(LBRACE instanceLiteralSection RBRACE)?
# InstanceExp_Literal
;
instanceKind
......
......@@ -13,12 +13,12 @@ mappingExp
| LBRACK mappingRef (SEMI mappingRef)+ RBRACK
# MappingExp_Compose
| GET_MAPPING schemaColimitRef schemaRef
# MappingExp_Get
| LITERAL COLON schemaRef RARROW schemaRef
LBRACE mappingLiteralSection RBRACE
# MappingExp_Literal
| GET_MAPPING schemaColimitRef schemaRef
# MappingExp_Get
;
mappingKind
......
......@@ -12,10 +12,6 @@ queryExp
: IDENTITY schemaRef
#QueryExp_Identity
| LITERAL COLON schemaKind RARROW schemaRef
(LBRACE queryLiteralSection RBRACE)?
#QueryExp_Literal
| SIMPLE COLON schemaKind
(LBRACE querySimpleSection RBRACE)?
#QueryExp_Simple
......@@ -29,10 +25,14 @@ queryExp
| TO_COQUERY mappingKind
(LBRACE queryFromSchemaSection RBRACE)?
#QueryExp_FromMapping
#QueryExp_FromSchema
| LBRACK queryKind SEMI queryKind RBRACK
#QueryExp_Composition
| LITERAL COLON schemaKind RARROW schemaRef
(LBRACE queryLiteralSection RBRACE)?
#QueryExp_Literal
;
queryKind
......
......@@ -7,13 +7,24 @@ schemaRef : symbol ;
schemaAssignment : SCHEMA schemaId EQUAL schemaExp ;
schemaExp
: EMPTY COLON typesideRef # Schema_Empty
| SCHEMA_OF IMPORT_ALL # Schema_OfImportAll
| SCHEMA_OF instanceKind # Schema_OfInstance
| DST queryRef # Schema_Destination
| GET_SCHEMA schemaColimitRef # Schema_GetSchemaColimit
: EMPTY COLON typesideRef
# SchemaExp_Empty
| SCHEMA_OF IMPORT_ALL
# SchemaExp_OfImportAll
| SCHEMA_OF instanceKind
# SchemaExp_OfInstance
| DST queryRef
# SchemaExp_Destination
| GET_SCHEMA schemaColimitRef
# SchemaExp_GetSchemaColimit
| LITERAL COLON typesideKind
(LBRACE schemaLiteralSection RBRACE)? # Schema_Literal
(LBRACE schemaLiteralSection RBRACE)?
# SchemaExp_Literal
;
schemaKind
......
......@@ -9,17 +9,17 @@ schemaColimitAssignment: SCHEMA_COLIMIT schemaColimitId EQUAL schemaColimitExp ;
schemaColimitExp
: QUOTIENT schemaRef (PLUS schemaRef)* COLON typesideRef
(LBRACE schemaColimitQuotientSection RBRACE)?
#SchemaColimit_Quotient
# SchemaColimitExp_Quotient
| COPRODUCT schemaRef (PLUS schemaRef)* COLON typesideRef
#SchemaColimit_Coproduct
# SchemaColimitExp_Coproduct
| MODIFY schemaColimitRef
(LBRACE schemaColimitModifySection RBRACE)?
#SchemaColimit_Modify
# SchemaColimitExp_Modify
| WRAP schemaColimitRef mappingRef mappingRef
#SchemaColimit_Wrap
# SchemaColimitExp_Wrap
;
schemaColimitKind
......
......@@ -8,58 +8,58 @@ transformAssignment : TRANSFORM transformId EQUAL transformExp ;
transformExp
: IDENTITY instanceKind
#Transform_Identity
# TransformExp_Identity
| LBRACK transformRef SEMI transformRef RBRACK
#Transform_Compose
# TransformExp_Compose
| DISTINCT transformRef
#Transform_Destination
# TransformExp_Destination
| DELTA mappingKind transformRef
#Transform_Delta
# TransformExp_Delta
| SIGMA mappingKind transformRef
(LBRACE transformSigmaSection RBRACE)?
(LBRACE transformSigmaSection RBRACE)?
#Transform_Sigma
# TransformExp_Sigma
| EVAL queryKind transformRef
#Transform_Eval
# TransformExp_Eval
| COEVAL queryKind transformRef
(LBRACE transformCoevalSection RBRACE)?
(LBRACE transformCoevalSection RBRACE)?
#Transform_Coeval
# TransformExp_Coeval
| UNIT mappingKind instanceRef
(LBRACE transformUnitSection RBRACE)?
#Transform_Unit
# TransformExp_Unit
| COUNIT mappingKind instanceRef
(LBRACE transformUnitSection RBRACE)?
#Transform_Counit
# TransformExp_Counit
| UNIT_QUERY queryKind instanceRef
(LBRACE transformUnitQuerySection RBRACE)?
#Transform_UnitQuery
# TransformExp_UnitQuery
| COUNIT_QUERY queryKind instanceRef
(LBRACE transformCounitQuerySection RBRACE)?
#Transform_CounitQuery
# TransformExp_CounitQuery
| IMPORT_JDBC transformJdbcClass transformJdbcUri COLON
instanceRef RARROW instanceRef
(LBRACE transformImportJdbcSection RBRACE)?
#Transform_ImportJdbc
# TransformExp_ImportJdbc
| IMPORT_CSV transformFile COLON instanceRef RARROW instanceRef
(LBRACE transformImportCsvSection RBRACE)?
#Transform_ImportCsv
# TransformExp_ImportCsv
| LITERAL COLON instanceKind RARROW instanceRef
(LBRACE transformLiteralSection RBRACE)?
#Transform_Literal
# TransformExp_Literal
;
transformKind
......
......@@ -9,16 +9,16 @@ typesideAssignment
typesideExp
: EMPTY
#Typeside_Empty
#TypesideExp_Empty
| SQL
#Typeside_Sql
#TypesideExp_Sql
| TYPESIDE_OF schemaKind
#Typeside_Of
#TypesideExp_Of
| LITERAL (LBRACE typesideLiteralSection RBRACE)?
#Typeside_Literal
#TypesideExp_Literal
;
typesideKind
......
......@@ -26,6 +26,8 @@ import catdata.aql.exp.TyExpRaw.Sym;
import catdata.aql.exp.TyExpRaw.Ty;
import catdata.aql.grammar.AqlParser;
import catdata.aql.grammar.AqlParser.GraphLiteralSectionContext;
import catdata.aql.grammar.AqlParser.MappingExp_LiteralContext;
import catdata.aql.grammar.AqlParser.MappingLiteralSectionContext;
import catdata.aql.grammar.AqlParser.MappingRefContext;
import catdata.aql.grammar.AqlParser.SchemaEquationSigContext;
import catdata.aql.grammar.AqlParser.SchemaGenTypeContext;
......@@ -70,6 +72,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Program section
* see AqlParser.g4
*/
@Override
......@@ -79,6 +82,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Options section
* see AqlOptions.g4
*/
@Override public void exitOptionsDeclarationSection(AqlParser.OptionsDeclarationSectionContext ctx) {
......@@ -95,6 +99,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Comment section
* see AqlComment.g4
*/
@Override
......@@ -117,6 +122,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Graph section
* see AqlGraph.g4
*/
@Override public void exitGraphAssignment(AqlParser.GraphAssignmentContext ctx) {
......@@ -139,7 +145,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/** see tyExpRaw */
@Override
public void exitGraph_Literal(AqlParser.Graph_LiteralContext ctx) {
public void exitGraphExp_Literal(AqlParser.GraphExp_LiteralContext ctx) {
final GraphLiteralSectionContext
ctx_lit = ctx.graphLiteralSection();
......@@ -175,6 +181,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* TypeSide section
* see AqlTypeside.g4
*/
@Override public void exitTypesideAssignment(AqlParser.TypesideAssignmentContext ctx) {
final String name = ctx.typesideId().getText();
......@@ -189,19 +196,19 @@ public class AqlLoaderListener extends AqlParserBaseListener {
}
@Override
public void exitTypeside_Empty(AqlParser.Typeside_EmptyContext ctx) {
public void exitTypesideExp_Empty(AqlParser.TypesideExp_EmptyContext ctx) {
final Exp<?> exp = new TyExp.TyExpEmpty();
this.exps.put(ctx,exp);
};
@Override
public void exitTypeside_Sql(AqlParser.Typeside_SqlContext ctx) {
public void exitTypesideExp_Sql(AqlParser.TypesideExp_SqlContext ctx) {
final Exp<?> exp = new TyExpSql();
this.exps.put(ctx,exp);
};
@Override
public void exitTypeside_Of(AqlParser.Typeside_OfContext ctx) {
public void exitTypesideExp_Of(AqlParser.TypesideExp_OfContext ctx) {
@SuppressWarnings("unchecked")
final Exp<?> exp = new TyExp.TyExpSch<>(
(SchExp<Ty, En, Sym, Fk, Att>)
......@@ -212,7 +219,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/** see tyExpRaw */
@Override
public void exitTypeside_Literal(AqlParser.Typeside_LiteralContext ctx) {
public void exitTypesideExp_Literal(AqlParser.TypesideExp_LiteralContext ctx) {
final TypesideLiteralSectionContext
ctx_lit = ctx.typesideLiteralSection();
......@@ -305,6 +312,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Schema section
* see AqlSchema.g4
*/
@Override public void exitSchemaAssignment(AqlParser.SchemaAssignmentContext ctx) {
......@@ -325,14 +333,14 @@ public class AqlLoaderListener extends AqlParserBaseListener {
}
@Override
public void exitSchema_Empty(AqlParser.Schema_EmptyContext ctx) {
public void exitSchemaExp_Empty(AqlParser.SchemaExp_EmptyContext ctx) {
final TyExp<Ty,Sym> ty = new TyExpVar<>(ctx.typesideRef().getText());
final Exp<?> exp = new SchExpEmpty<>(ty);
this.exps.put(ctx,exp);
};
@Override
public void exitSchema_OfImportAll(AqlParser.Schema_OfImportAllContext ctx) {
public void exitSchemaExp_OfImportAll(AqlParser.SchemaExp_OfImportAllContext ctx) {
// TODO Ryan What is intended here?
//@SuppressWarnings("unchecked")
......@@ -343,7 +351,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
};
@Override
public void exitSchema_OfInstance(AqlParser.Schema_OfInstanceContext ctx) {
public void exitSchemaExp_OfInstance(AqlParser.SchemaExp_OfInstanceContext ctx) {
@SuppressWarnings("unchecked")
final Exp<?>
exp = new SchExp.SchExpInst<>(
......@@ -352,7 +360,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
this.exps.put(ctx,exp);
};
@Override public void exitSchema_Destination(AqlParser.Schema_DestinationContext ctx) {
@Override public void exitSchemaExp_Destination(AqlParser.SchemaExp_DestinationContext ctx) {
@SuppressWarnings("unchecked")
final Exp<?>
exp = new SchExp.SchExpInst<>(
......@@ -361,7 +369,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
this.exps.put(ctx,exp);
}
@Override public void exitSchema_GetSchemaColimit(AqlParser.Schema_GetSchemaColimitContext ctx) {
@Override public void exitSchemaExp_GetSchemaColimit(AqlParser.SchemaExp_GetSchemaColimitContext ctx) {
@SuppressWarnings("unchecked")
final Exp<?>
exp = new SchExp.SchExpInst<>(
......@@ -370,7 +378,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
this.exps.put(ctx,exp);
}
@Override public void exitSchema_Literal(AqlParser.Schema_LiteralContext ctx) {
@Override public void exitSchemaExp_Literal(AqlParser.SchemaExp_LiteralContext ctx) {
final SchemaLiteralSectionContext
ctx_lit = ctx.schemaLiteralSection();
......@@ -528,6 +536,7 @@ public class AqlLoaderListener extends AqlParserBaseListener {
/***************************************************
* Mapping section
* see AqlMapping.g4
*/
@Override public void exitMappingAssignment(AqlParser.MappingAssignmentContext ctx) {
......@@ -584,9 +593,95 @@ public class AqlLoaderListener extends AqlParserBaseListener {
this.exps.put(ctx,comp);
}
@Override public void exitMappingExp_Get(AqlParser.MappingExp_GetContext ctx) {
// TODO
}
@Override public void exitMappingExp_Literal(AqlParser.MappingExp_LiteralContext ctx) {
final MappingLiteralSectionContext
ctx_lit = ctx.mappingLiteralSection();
final TyExp<Ty, Sym>
typeside = new TyExp.TyExpVar<>(ctx.typesideKind().getText());
final List<LocStr>
imports = ctx_lit.typesideImport().stream()
.map(ty -> makeLocStr(ty))
.collect(Collectors.toList());
final List<LocStr>
entities = ctx_lit.mappingEntityId().stream()
.map(elt -> makeLocStr(elt))
.collect(Collectors.toList());
final List<Pair<LocStr, Pair<String, String>>>
arrows = ctx_lit.mappingForeignSig().stream()
.map(fk -> {
final Pair<String,String>
arrow = new Pair<>(
fk.MappingEntityId(0).getText(),
fk.MappingEntityId(1).getText());
return new LinkedList<>(
fk.MappingForeignId().stream()
.map(fkid -> new Pair<>(makeLocStr(fkid), arrow))
.collect(Collectors.toList()));
})
.flatMap(x -> x.stream())
.collect(Collectors.toList());
final List<Pair<Integer, Pair<List<String>, List<String>>>>
commutes = ctx_lit.mappingPathEqnSig().stream()
.map(eq ->
new Pair<>(
eq.getStart().getStartIndex(),