diff --git a/drivers/golang/go.mod b/drivers/golang/go.mod index c97454247..95628d9f2 100644 --- a/drivers/golang/go.mod +++ b/drivers/golang/go.mod @@ -30,6 +30,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect + golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect ) diff --git a/drivers/golang/go.sum b/drivers/golang/go.sum index 957ce775f..26bb0f3b4 100644 --- a/drivers/golang/go.sum +++ b/drivers/golang/go.sum @@ -15,6 +15,8 @@ golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAb golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo= +golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/golang/parser/age_base_listener.go b/drivers/golang/parser/age_base_listener.go new file mode 100644 index 000000000..4a6578953 --- /dev/null +++ b/drivers/golang/parser/age_base_listener.go @@ -0,0 +1,70 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser // Age + +import "github.com/antlr/antlr4/runtime/Go/antlr/v4" + +// BaseAgeListener is a complete listener for a parse tree produced by AgeParser. +type BaseAgeListener struct{} + +var _ AgeListener = &BaseAgeListener{} + +// VisitTerminal is called when a terminal node is visited. +func (s *BaseAgeListener) VisitTerminal(node antlr.TerminalNode) {} + +// VisitErrorNode is called when an error node is visited. +func (s *BaseAgeListener) VisitErrorNode(node antlr.ErrorNode) {} + +// EnterEveryRule is called when any rule is entered. +func (s *BaseAgeListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} + +// ExitEveryRule is called when any rule is exited. +func (s *BaseAgeListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} + +// EnterAgeout is called when production ageout is entered. +func (s *BaseAgeListener) EnterAgeout(ctx *AgeoutContext) {} + +// ExitAgeout is called when production ageout is exited. +func (s *BaseAgeListener) ExitAgeout(ctx *AgeoutContext) {} + +// EnterVertex is called when production vertex is entered. +func (s *BaseAgeListener) EnterVertex(ctx *VertexContext) {} + +// ExitVertex is called when production vertex is exited. +func (s *BaseAgeListener) ExitVertex(ctx *VertexContext) {} + +// EnterEdge is called when production edge is entered. +func (s *BaseAgeListener) EnterEdge(ctx *EdgeContext) {} + +// ExitEdge is called when production edge is exited. +func (s *BaseAgeListener) ExitEdge(ctx *EdgeContext) {} + +// EnterPath is called when production path is entered. +func (s *BaseAgeListener) EnterPath(ctx *PathContext) {} + +// ExitPath is called when production path is exited. +func (s *BaseAgeListener) ExitPath(ctx *PathContext) {} + +// EnterValue is called when production value is entered. +func (s *BaseAgeListener) EnterValue(ctx *ValueContext) {} + +// ExitValue is called when production value is exited. +func (s *BaseAgeListener) ExitValue(ctx *ValueContext) {} + +// EnterProperties is called when production properties is entered. +func (s *BaseAgeListener) EnterProperties(ctx *PropertiesContext) {} + +// ExitProperties is called when production properties is exited. +func (s *BaseAgeListener) ExitProperties(ctx *PropertiesContext) {} + +// EnterPair is called when production pair is entered. +func (s *BaseAgeListener) EnterPair(ctx *PairContext) {} + +// ExitPair is called when production pair is exited. +func (s *BaseAgeListener) ExitPair(ctx *PairContext) {} + +// EnterArr is called when production arr is entered. +func (s *BaseAgeListener) EnterArr(ctx *ArrContext) {} + +// ExitArr is called when production arr is exited. +func (s *BaseAgeListener) ExitArr(ctx *ArrContext) {} diff --git a/drivers/golang/parser/age_base_visitor.go b/drivers/golang/parser/age_base_visitor.go new file mode 100644 index 000000000..d33dc2cee --- /dev/null +++ b/drivers/golang/parser/age_base_visitor.go @@ -0,0 +1,41 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser // Age + +import "github.com/antlr/antlr4/runtime/Go/antlr/v4" + +type BaseAgeVisitor struct { + *antlr.BaseParseTreeVisitor +} + +func (v *BaseAgeVisitor) VisitAgeout(ctx *AgeoutContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitVertex(ctx *VertexContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitEdge(ctx *EdgeContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitPath(ctx *PathContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitValue(ctx *ValueContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitProperties(ctx *PropertiesContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitPair(ctx *PairContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseAgeVisitor) VisitArr(ctx *ArrContext) interface{} { + return v.VisitChildren(ctx) +} diff --git a/drivers/golang/parser/age_lexer.go b/drivers/golang/parser/age_lexer.go new file mode 100644 index 000000000..df8a34fae --- /dev/null +++ b/drivers/golang/parser/age_lexer.go @@ -0,0 +1,214 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser + +import ( + "fmt" + "sync" + "unicode" + + "github.com/antlr/antlr4/runtime/Go/antlr/v4" +) + +// Suppress unused import error +var _ = fmt.Printf +var _ = sync.Once{} +var _ = unicode.IsLetter + +type AgeLexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string +} + +var agelexerLexerStaticData struct { + once sync.Once + serializedATN []int32 + channelNames []string + modeNames []string + literalNames []string + symbolicNames []string + ruleNames []string + predictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func agelexerLexerInit() { + staticData := &agelexerLexerStaticData + staticData.channelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", + } + staticData.modeNames = []string{ + "DEFAULT_MODE", + } + staticData.literalNames = []string{ + "", "'['", "','", "']'", "'{'", "'}'", "':'", "'::vertex'", "'::edge'", + "'::path'", "'::numeric'", "", "", "'null'", + } + staticData.symbolicNames = []string{ + "", "", "", "", "", "", "", "KW_VERTEX", "KW_EDGE", "KW_PATH", "KW_NUMERIC", + "STRING", "BOOL", "NULL", "NUMBER", "FLOAT_EXPR", "NUMERIC", "WS", + } + staticData.ruleNames = []string{ + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "KW_VERTEX", "KW_EDGE", + "KW_PATH", "KW_NUMERIC", "STRING", "BOOL", "NULL", "ESC", "UNICODE", + "HEX", "SAFECODEPOINT", "NUMBER", "FLOAT_EXPR", "NUMERIC", "INT", "EXP", + "WS", + } + staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 0, 17, 210, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, + 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, + 20, 2, 21, 7, 21, 2, 22, 7, 22, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, + 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, + 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, + 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, + 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 5, 10, 96, 8, 10, 10, 10, 12, 10, 99, + 9, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, + 11, 1, 11, 3, 11, 112, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, + 1, 13, 1, 13, 3, 13, 122, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, + 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 3, 17, 135, 8, 17, 1, 17, 1, 17, + 1, 17, 4, 17, 140, 8, 17, 11, 17, 12, 17, 141, 3, 17, 144, 8, 17, 1, 17, + 3, 17, 147, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, + 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, + 1, 18, 1, 18, 3, 18, 169, 8, 18, 1, 19, 3, 19, 172, 8, 19, 1, 19, 1, 19, + 1, 19, 4, 19, 177, 8, 19, 11, 19, 12, 19, 178, 3, 19, 181, 8, 19, 1, 19, + 3, 19, 184, 8, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 5, 20, 191, 8, 20, + 10, 20, 12, 20, 194, 9, 20, 3, 20, 196, 8, 20, 1, 21, 1, 21, 3, 21, 200, + 8, 21, 1, 21, 1, 21, 1, 22, 4, 22, 205, 8, 22, 11, 22, 12, 22, 206, 1, + 22, 1, 22, 0, 0, 23, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, + 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 0, 29, 0, 31, 0, 33, 0, 35, + 14, 37, 15, 39, 16, 41, 0, 43, 0, 45, 17, 1, 0, 8, 8, 0, 34, 34, 47, 47, + 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, + 70, 97, 102, 3, 0, 0, 31, 34, 34, 92, 92, 1, 0, 48, 57, 1, 0, 49, 57, 2, + 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 3, 0, 9, 10, 13, 13, 32, 32, + 221, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, + 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, + 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, + 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, + 39, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 1, 47, 1, 0, 0, 0, 3, 49, 1, 0, 0, 0, + 5, 51, 1, 0, 0, 0, 7, 53, 1, 0, 0, 0, 9, 55, 1, 0, 0, 0, 11, 57, 1, 0, + 0, 0, 13, 59, 1, 0, 0, 0, 15, 68, 1, 0, 0, 0, 17, 75, 1, 0, 0, 0, 19, 82, + 1, 0, 0, 0, 21, 92, 1, 0, 0, 0, 23, 111, 1, 0, 0, 0, 25, 113, 1, 0, 0, + 0, 27, 118, 1, 0, 0, 0, 29, 123, 1, 0, 0, 0, 31, 129, 1, 0, 0, 0, 33, 131, + 1, 0, 0, 0, 35, 134, 1, 0, 0, 0, 37, 168, 1, 0, 0, 0, 39, 171, 1, 0, 0, + 0, 41, 195, 1, 0, 0, 0, 43, 197, 1, 0, 0, 0, 45, 204, 1, 0, 0, 0, 47, 48, + 5, 91, 0, 0, 48, 2, 1, 0, 0, 0, 49, 50, 5, 44, 0, 0, 50, 4, 1, 0, 0, 0, + 51, 52, 5, 93, 0, 0, 52, 6, 1, 0, 0, 0, 53, 54, 5, 123, 0, 0, 54, 8, 1, + 0, 0, 0, 55, 56, 5, 125, 0, 0, 56, 10, 1, 0, 0, 0, 57, 58, 5, 58, 0, 0, + 58, 12, 1, 0, 0, 0, 59, 60, 5, 58, 0, 0, 60, 61, 5, 58, 0, 0, 61, 62, 5, + 118, 0, 0, 62, 63, 5, 101, 0, 0, 63, 64, 5, 114, 0, 0, 64, 65, 5, 116, + 0, 0, 65, 66, 5, 101, 0, 0, 66, 67, 5, 120, 0, 0, 67, 14, 1, 0, 0, 0, 68, + 69, 5, 58, 0, 0, 69, 70, 5, 58, 0, 0, 70, 71, 5, 101, 0, 0, 71, 72, 5, + 100, 0, 0, 72, 73, 5, 103, 0, 0, 73, 74, 5, 101, 0, 0, 74, 16, 1, 0, 0, + 0, 75, 76, 5, 58, 0, 0, 76, 77, 5, 58, 0, 0, 77, 78, 5, 112, 0, 0, 78, + 79, 5, 97, 0, 0, 79, 80, 5, 116, 0, 0, 80, 81, 5, 104, 0, 0, 81, 18, 1, + 0, 0, 0, 82, 83, 5, 58, 0, 0, 83, 84, 5, 58, 0, 0, 84, 85, 5, 110, 0, 0, + 85, 86, 5, 117, 0, 0, 86, 87, 5, 109, 0, 0, 87, 88, 5, 101, 0, 0, 88, 89, + 5, 114, 0, 0, 89, 90, 5, 105, 0, 0, 90, 91, 5, 99, 0, 0, 91, 20, 1, 0, + 0, 0, 92, 97, 5, 34, 0, 0, 93, 96, 3, 27, 13, 0, 94, 96, 3, 33, 16, 0, + 95, 93, 1, 0, 0, 0, 95, 94, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 95, 1, + 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 100, 1, 0, 0, 0, 99, 97, 1, 0, 0, 0, 100, + 101, 5, 34, 0, 0, 101, 22, 1, 0, 0, 0, 102, 103, 5, 116, 0, 0, 103, 104, + 5, 114, 0, 0, 104, 105, 5, 117, 0, 0, 105, 112, 5, 101, 0, 0, 106, 107, + 5, 102, 0, 0, 107, 108, 5, 97, 0, 0, 108, 109, 5, 108, 0, 0, 109, 110, + 5, 115, 0, 0, 110, 112, 5, 101, 0, 0, 111, 102, 1, 0, 0, 0, 111, 106, 1, + 0, 0, 0, 112, 24, 1, 0, 0, 0, 113, 114, 5, 110, 0, 0, 114, 115, 5, 117, + 0, 0, 115, 116, 5, 108, 0, 0, 116, 117, 5, 108, 0, 0, 117, 26, 1, 0, 0, + 0, 118, 121, 5, 92, 0, 0, 119, 122, 7, 0, 0, 0, 120, 122, 3, 29, 14, 0, + 121, 119, 1, 0, 0, 0, 121, 120, 1, 0, 0, 0, 122, 28, 1, 0, 0, 0, 123, 124, + 5, 117, 0, 0, 124, 125, 3, 31, 15, 0, 125, 126, 3, 31, 15, 0, 126, 127, + 3, 31, 15, 0, 127, 128, 3, 31, 15, 0, 128, 30, 1, 0, 0, 0, 129, 130, 7, + 1, 0, 0, 130, 32, 1, 0, 0, 0, 131, 132, 8, 2, 0, 0, 132, 34, 1, 0, 0, 0, + 133, 135, 5, 45, 0, 0, 134, 133, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, + 136, 1, 0, 0, 0, 136, 143, 3, 41, 20, 0, 137, 139, 5, 46, 0, 0, 138, 140, + 7, 3, 0, 0, 139, 138, 1, 0, 0, 0, 140, 141, 1, 0, 0, 0, 141, 139, 1, 0, + 0, 0, 141, 142, 1, 0, 0, 0, 142, 144, 1, 0, 0, 0, 143, 137, 1, 0, 0, 0, + 143, 144, 1, 0, 0, 0, 144, 146, 1, 0, 0, 0, 145, 147, 3, 43, 21, 0, 146, + 145, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 36, 1, 0, 0, 0, 148, 149, 5, + 78, 0, 0, 149, 150, 5, 97, 0, 0, 150, 169, 5, 78, 0, 0, 151, 152, 5, 45, + 0, 0, 152, 153, 5, 73, 0, 0, 153, 154, 5, 110, 0, 0, 154, 155, 5, 102, + 0, 0, 155, 156, 5, 105, 0, 0, 156, 157, 5, 110, 0, 0, 157, 158, 5, 105, + 0, 0, 158, 159, 5, 116, 0, 0, 159, 169, 5, 121, 0, 0, 160, 161, 5, 73, + 0, 0, 161, 162, 5, 110, 0, 0, 162, 163, 5, 102, 0, 0, 163, 164, 5, 105, + 0, 0, 164, 165, 5, 110, 0, 0, 165, 166, 5, 105, 0, 0, 166, 167, 5, 116, + 0, 0, 167, 169, 5, 121, 0, 0, 168, 148, 1, 0, 0, 0, 168, 151, 1, 0, 0, + 0, 168, 160, 1, 0, 0, 0, 169, 38, 1, 0, 0, 0, 170, 172, 5, 45, 0, 0, 171, + 170, 1, 0, 0, 0, 171, 172, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 180, + 3, 41, 20, 0, 174, 176, 5, 46, 0, 0, 175, 177, 7, 3, 0, 0, 176, 175, 1, + 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 178, 179, 1, 0, 0, + 0, 179, 181, 1, 0, 0, 0, 180, 174, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, + 183, 1, 0, 0, 0, 182, 184, 3, 43, 21, 0, 183, 182, 1, 0, 0, 0, 183, 184, + 1, 0, 0, 0, 184, 185, 1, 0, 0, 0, 185, 186, 3, 19, 9, 0, 186, 40, 1, 0, + 0, 0, 187, 196, 5, 48, 0, 0, 188, 192, 7, 4, 0, 0, 189, 191, 7, 3, 0, 0, + 190, 189, 1, 0, 0, 0, 191, 194, 1, 0, 0, 0, 192, 190, 1, 0, 0, 0, 192, + 193, 1, 0, 0, 0, 193, 196, 1, 0, 0, 0, 194, 192, 1, 0, 0, 0, 195, 187, + 1, 0, 0, 0, 195, 188, 1, 0, 0, 0, 196, 42, 1, 0, 0, 0, 197, 199, 7, 5, + 0, 0, 198, 200, 7, 6, 0, 0, 199, 198, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, + 200, 201, 1, 0, 0, 0, 201, 202, 3, 41, 20, 0, 202, 44, 1, 0, 0, 0, 203, + 205, 7, 7, 0, 0, 204, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 204, + 1, 0, 0, 0, 206, 207, 1, 0, 0, 0, 207, 208, 1, 0, 0, 0, 208, 209, 6, 22, + 0, 0, 209, 46, 1, 0, 0, 0, 18, 0, 95, 97, 111, 121, 134, 141, 143, 146, + 168, 171, 178, 180, 183, 192, 195, 199, 206, 1, 6, 0, 0, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// AgeLexerInit initializes any static state used to implement AgeLexer. By default the +// static state used to implement the lexer is lazily initialized during the first call to +// NewAgeLexer(). You can call this function if you wish to initialize the static state ahead +// of time. +func AgeLexerInit() { + staticData := &agelexerLexerStaticData + staticData.once.Do(agelexerLexerInit) +} + +// NewAgeLexer produces a new lexer instance for the optional input antlr.CharStream. +func NewAgeLexer(input antlr.CharStream) *AgeLexer { + AgeLexerInit() + l := new(AgeLexer) + l.BaseLexer = antlr.NewBaseLexer(input) + staticData := &agelexerLexerStaticData + l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) + l.channelNames = staticData.channelNames + l.modeNames = staticData.modeNames + l.RuleNames = staticData.ruleNames + l.LiteralNames = staticData.literalNames + l.SymbolicNames = staticData.symbolicNames + l.GrammarFileName = "Age.g4" + // TODO: l.EOF = antlr.TokenEOF + + return l +} + +// AgeLexer tokens. +const ( + AgeLexerT__0 = 1 + AgeLexerT__1 = 2 + AgeLexerT__2 = 3 + AgeLexerT__3 = 4 + AgeLexerT__4 = 5 + AgeLexerT__5 = 6 + AgeLexerKW_VERTEX = 7 + AgeLexerKW_EDGE = 8 + AgeLexerKW_PATH = 9 + AgeLexerKW_NUMERIC = 10 + AgeLexerSTRING = 11 + AgeLexerBOOL = 12 + AgeLexerNULL = 13 + AgeLexerNUMBER = 14 + AgeLexerFLOAT_EXPR = 15 + AgeLexerNUMERIC = 16 + AgeLexerWS = 17 +) diff --git a/drivers/golang/parser/age_listener.go b/drivers/golang/parser/age_listener.go new file mode 100644 index 000000000..5c8b67ec3 --- /dev/null +++ b/drivers/golang/parser/age_listener.go @@ -0,0 +1,58 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser // Age + +import "github.com/antlr/antlr4/runtime/Go/antlr/v4" + +// AgeListener is a complete listener for a parse tree produced by AgeParser. +type AgeListener interface { + antlr.ParseTreeListener + + // EnterAgeout is called when entering the ageout production. + EnterAgeout(c *AgeoutContext) + + // EnterVertex is called when entering the vertex production. + EnterVertex(c *VertexContext) + + // EnterEdge is called when entering the edge production. + EnterEdge(c *EdgeContext) + + // EnterPath is called when entering the path production. + EnterPath(c *PathContext) + + // EnterValue is called when entering the value production. + EnterValue(c *ValueContext) + + // EnterProperties is called when entering the properties production. + EnterProperties(c *PropertiesContext) + + // EnterPair is called when entering the pair production. + EnterPair(c *PairContext) + + // EnterArr is called when entering the arr production. + EnterArr(c *ArrContext) + + // ExitAgeout is called when exiting the ageout production. + ExitAgeout(c *AgeoutContext) + + // ExitVertex is called when exiting the vertex production. + ExitVertex(c *VertexContext) + + // ExitEdge is called when exiting the edge production. + ExitEdge(c *EdgeContext) + + // ExitPath is called when exiting the path production. + ExitPath(c *PathContext) + + // ExitValue is called when exiting the value production. + ExitValue(c *ValueContext) + + // ExitProperties is called when exiting the properties production. + ExitProperties(c *PropertiesContext) + + // ExitPair is called when exiting the pair production. + ExitPair(c *PairContext) + + // ExitArr is called when exiting the arr production. + ExitArr(c *ArrContext) +} diff --git a/drivers/golang/parser/age_parser.go b/drivers/golang/parser/age_parser.go new file mode 100644 index 000000000..cc25e5d90 --- /dev/null +++ b/drivers/golang/parser/age_parser.go @@ -0,0 +1,1527 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser // Age + +import ( + "fmt" + "strconv" + "sync" + + "github.com/antlr/antlr4/runtime/Go/antlr/v4" +) + +// Suppress unused import errors +var _ = fmt.Printf +var _ = strconv.Itoa +var _ = sync.Once{} + +type AgeParser struct { + *antlr.BaseParser +} + +var ageParserStaticData struct { + once sync.Once + serializedATN []int32 + literalNames []string + symbolicNames []string + ruleNames []string + predictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func ageParserInit() { + staticData := &ageParserStaticData + staticData.literalNames = []string{ + "", "'['", "','", "']'", "'{'", "'}'", "':'", "'::vertex'", "'::edge'", + "'::path'", "'::numeric'", "", "", "'null'", + } + staticData.symbolicNames = []string{ + "", "", "", "", "", "", "", "KW_VERTEX", "KW_EDGE", "KW_PATH", "KW_NUMERIC", + "STRING", "BOOL", "NULL", "NUMBER", "FLOAT_EXPR", "NUMERIC", "WS", + } + staticData.ruleNames = []string{ + "ageout", "vertex", "edge", "path", "value", "properties", "pair", "arr", + } + staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 1, 17, 88, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 21, + 8, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 5, 3, 36, 8, 3, 10, 3, 12, 3, 39, 9, 3, 1, 3, 1, 3, 1, 3, 1, + 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 52, 8, 4, 1, 5, 1, 5, + 1, 5, 1, 5, 5, 5, 58, 8, 5, 10, 5, 12, 5, 61, 9, 5, 1, 5, 1, 5, 1, 5, 1, + 5, 3, 5, 67, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, + 77, 8, 7, 10, 7, 12, 7, 80, 9, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 86, 8, + 7, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 0, 94, 0, 20, 1, 0, 0, + 0, 2, 22, 1, 0, 0, 0, 4, 25, 1, 0, 0, 0, 6, 28, 1, 0, 0, 0, 8, 51, 1, 0, + 0, 0, 10, 66, 1, 0, 0, 0, 12, 68, 1, 0, 0, 0, 14, 85, 1, 0, 0, 0, 16, 21, + 3, 8, 4, 0, 17, 21, 3, 2, 1, 0, 18, 21, 3, 4, 2, 0, 19, 21, 3, 6, 3, 0, + 20, 16, 1, 0, 0, 0, 20, 17, 1, 0, 0, 0, 20, 18, 1, 0, 0, 0, 20, 19, 1, + 0, 0, 0, 21, 1, 1, 0, 0, 0, 22, 23, 3, 10, 5, 0, 23, 24, 5, 7, 0, 0, 24, + 3, 1, 0, 0, 0, 25, 26, 3, 10, 5, 0, 26, 27, 5, 8, 0, 0, 27, 5, 1, 0, 0, + 0, 28, 29, 5, 1, 0, 0, 29, 37, 3, 2, 1, 0, 30, 31, 5, 2, 0, 0, 31, 32, + 3, 4, 2, 0, 32, 33, 5, 2, 0, 0, 33, 34, 3, 2, 1, 0, 34, 36, 1, 0, 0, 0, + 35, 30, 1, 0, 0, 0, 36, 39, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 37, 38, 1, + 0, 0, 0, 38, 40, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 40, 41, 5, 3, 0, 0, 41, + 42, 5, 9, 0, 0, 42, 7, 1, 0, 0, 0, 43, 52, 5, 11, 0, 0, 44, 52, 5, 14, + 0, 0, 45, 52, 5, 16, 0, 0, 46, 52, 5, 15, 0, 0, 47, 52, 5, 12, 0, 0, 48, + 52, 5, 13, 0, 0, 49, 52, 3, 10, 5, 0, 50, 52, 3, 14, 7, 0, 51, 43, 1, 0, + 0, 0, 51, 44, 1, 0, 0, 0, 51, 45, 1, 0, 0, 0, 51, 46, 1, 0, 0, 0, 51, 47, + 1, 0, 0, 0, 51, 48, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, + 52, 9, 1, 0, 0, 0, 53, 54, 5, 4, 0, 0, 54, 59, 3, 12, 6, 0, 55, 56, 5, + 2, 0, 0, 56, 58, 3, 12, 6, 0, 57, 55, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, + 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 62, 1, 0, 0, 0, 61, 59, 1, 0, 0, + 0, 62, 63, 5, 5, 0, 0, 63, 67, 1, 0, 0, 0, 64, 65, 5, 4, 0, 0, 65, 67, + 5, 5, 0, 0, 66, 53, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 67, 11, 1, 0, 0, 0, + 68, 69, 5, 11, 0, 0, 69, 70, 5, 6, 0, 0, 70, 71, 3, 8, 4, 0, 71, 13, 1, + 0, 0, 0, 72, 73, 5, 1, 0, 0, 73, 78, 3, 8, 4, 0, 74, 75, 5, 2, 0, 0, 75, + 77, 3, 8, 4, 0, 76, 74, 1, 0, 0, 0, 77, 80, 1, 0, 0, 0, 78, 76, 1, 0, 0, + 0, 78, 79, 1, 0, 0, 0, 79, 81, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 81, 82, + 5, 3, 0, 0, 82, 86, 1, 0, 0, 0, 83, 84, 5, 1, 0, 0, 84, 86, 5, 3, 0, 0, + 85, 72, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 15, 1, 0, 0, 0, 7, 20, 37, + 51, 59, 66, 78, 85, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// AgeParserInit initializes any static state used to implement AgeParser. By default the +// static state used to implement the parser is lazily initialized during the first call to +// NewAgeParser(). You can call this function if you wish to initialize the static state ahead +// of time. +func AgeParserInit() { + staticData := &ageParserStaticData + staticData.once.Do(ageParserInit) +} + +// NewAgeParser produces a new parser instance for the optional input antlr.TokenStream. +func NewAgeParser(input antlr.TokenStream) *AgeParser { + AgeParserInit() + this := new(AgeParser) + this.BaseParser = antlr.NewBaseParser(input) + staticData := &ageParserStaticData + this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) + this.RuleNames = staticData.ruleNames + this.LiteralNames = staticData.literalNames + this.SymbolicNames = staticData.symbolicNames + this.GrammarFileName = "java-escape" + + return this +} + +// AgeParser tokens. +const ( + AgeParserEOF = antlr.TokenEOF + AgeParserT__0 = 1 + AgeParserT__1 = 2 + AgeParserT__2 = 3 + AgeParserT__3 = 4 + AgeParserT__4 = 5 + AgeParserT__5 = 6 + AgeParserKW_VERTEX = 7 + AgeParserKW_EDGE = 8 + AgeParserKW_PATH = 9 + AgeParserKW_NUMERIC = 10 + AgeParserSTRING = 11 + AgeParserBOOL = 12 + AgeParserNULL = 13 + AgeParserNUMBER = 14 + AgeParserFLOAT_EXPR = 15 + AgeParserNUMERIC = 16 + AgeParserWS = 17 +) + +// AgeParser rules. +const ( + AgeParserRULE_ageout = 0 + AgeParserRULE_vertex = 1 + AgeParserRULE_edge = 2 + AgeParserRULE_path = 3 + AgeParserRULE_value = 4 + AgeParserRULE_properties = 5 + AgeParserRULE_pair = 6 + AgeParserRULE_arr = 7 +) + +// IAgeoutContext is an interface to support dynamic dispatch. +type IAgeoutContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsAgeoutContext differentiates from other interfaces. + IsAgeoutContext() +} + +type AgeoutContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyAgeoutContext() *AgeoutContext { + var p = new(AgeoutContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_ageout + return p +} + +func (*AgeoutContext) IsAgeoutContext() {} + +func NewAgeoutContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AgeoutContext { + var p = new(AgeoutContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_ageout + + return p +} + +func (s *AgeoutContext) GetParser() antlr.Parser { return s.parser } + +func (s *AgeoutContext) Value() IValueContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IValueContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IValueContext) +} + +func (s *AgeoutContext) Vertex() IVertexContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IVertexContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IVertexContext) +} + +func (s *AgeoutContext) Edge() IEdgeContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IEdgeContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IEdgeContext) +} + +func (s *AgeoutContext) Path() IPathContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPathContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPathContext) +} + +func (s *AgeoutContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AgeoutContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *AgeoutContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterAgeout(s) + } +} + +func (s *AgeoutContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitAgeout(s) + } +} + +func (s *AgeoutContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitAgeout(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Ageout() (localctx IAgeoutContext) { + this := p + _ = this + + localctx = NewAgeoutContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 0, AgeParserRULE_ageout) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.SetState(20) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 0, p.GetParserRuleContext()) { + case 1: + p.EnterOuterAlt(localctx, 1) + { + p.SetState(16) + p.Value() + } + + case 2: + p.EnterOuterAlt(localctx, 2) + { + p.SetState(17) + p.Vertex() + } + + case 3: + p.EnterOuterAlt(localctx, 3) + { + p.SetState(18) + p.Edge() + } + + case 4: + p.EnterOuterAlt(localctx, 4) + { + p.SetState(19) + p.Path() + } + + } + + return localctx +} + +// IVertexContext is an interface to support dynamic dispatch. +type IVertexContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsVertexContext differentiates from other interfaces. + IsVertexContext() +} + +type VertexContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyVertexContext() *VertexContext { + var p = new(VertexContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_vertex + return p +} + +func (*VertexContext) IsVertexContext() {} + +func NewVertexContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *VertexContext { + var p = new(VertexContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_vertex + + return p +} + +func (s *VertexContext) GetParser() antlr.Parser { return s.parser } + +func (s *VertexContext) Properties() IPropertiesContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPropertiesContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPropertiesContext) +} + +func (s *VertexContext) KW_VERTEX() antlr.TerminalNode { + return s.GetToken(AgeParserKW_VERTEX, 0) +} + +func (s *VertexContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *VertexContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *VertexContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterVertex(s) + } +} + +func (s *VertexContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitVertex(s) + } +} + +func (s *VertexContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitVertex(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Vertex() (localctx IVertexContext) { + this := p + _ = this + + localctx = NewVertexContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, AgeParserRULE_vertex) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(22) + p.Properties() + } + { + p.SetState(23) + p.Match(AgeParserKW_VERTEX) + } + + return localctx +} + +// IEdgeContext is an interface to support dynamic dispatch. +type IEdgeContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsEdgeContext differentiates from other interfaces. + IsEdgeContext() +} + +type EdgeContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyEdgeContext() *EdgeContext { + var p = new(EdgeContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_edge + return p +} + +func (*EdgeContext) IsEdgeContext() {} + +func NewEdgeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *EdgeContext { + var p = new(EdgeContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_edge + + return p +} + +func (s *EdgeContext) GetParser() antlr.Parser { return s.parser } + +func (s *EdgeContext) Properties() IPropertiesContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPropertiesContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPropertiesContext) +} + +func (s *EdgeContext) KW_EDGE() antlr.TerminalNode { + return s.GetToken(AgeParserKW_EDGE, 0) +} + +func (s *EdgeContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *EdgeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *EdgeContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterEdge(s) + } +} + +func (s *EdgeContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitEdge(s) + } +} + +func (s *EdgeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitEdge(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Edge() (localctx IEdgeContext) { + this := p + _ = this + + localctx = NewEdgeContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, AgeParserRULE_edge) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(25) + p.Properties() + } + { + p.SetState(26) + p.Match(AgeParserKW_EDGE) + } + + return localctx +} + +// IPathContext is an interface to support dynamic dispatch. +type IPathContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsPathContext differentiates from other interfaces. + IsPathContext() +} + +type PathContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPathContext() *PathContext { + var p = new(PathContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_path + return p +} + +func (*PathContext) IsPathContext() {} + +func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext { + var p = new(PathContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_path + + return p +} + +func (s *PathContext) GetParser() antlr.Parser { return s.parser } + +func (s *PathContext) AllVertex() []IVertexContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IVertexContext); ok { + len++ + } + } + + tst := make([]IVertexContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IVertexContext); ok { + tst[i] = t.(IVertexContext) + i++ + } + } + + return tst +} + +func (s *PathContext) Vertex(i int) IVertexContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IVertexContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IVertexContext) +} + +func (s *PathContext) KW_PATH() antlr.TerminalNode { + return s.GetToken(AgeParserKW_PATH, 0) +} + +func (s *PathContext) AllEdge() []IEdgeContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IEdgeContext); ok { + len++ + } + } + + tst := make([]IEdgeContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IEdgeContext); ok { + tst[i] = t.(IEdgeContext) + i++ + } + } + + return tst +} + +func (s *PathContext) Edge(i int) IEdgeContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IEdgeContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IEdgeContext) +} + +func (s *PathContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *PathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *PathContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterPath(s) + } +} + +func (s *PathContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitPath(s) + } +} + +func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitPath(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Path() (localctx IPathContext) { + this := p + _ = this + + localctx = NewPathContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 6, AgeParserRULE_path) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(28) + p.Match(AgeParserT__0) + } + { + p.SetState(29) + p.Vertex() + } + p.SetState(37) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == AgeParserT__1 { + { + p.SetState(30) + p.Match(AgeParserT__1) + } + { + p.SetState(31) + p.Edge() + } + { + p.SetState(32) + p.Match(AgeParserT__1) + } + { + p.SetState(33) + p.Vertex() + } + + p.SetState(39) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(40) + p.Match(AgeParserT__2) + } + { + p.SetState(41) + p.Match(AgeParserKW_PATH) + } + + return localctx +} + +// IValueContext is an interface to support dynamic dispatch. +type IValueContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsValueContext differentiates from other interfaces. + IsValueContext() +} + +type ValueContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyValueContext() *ValueContext { + var p = new(ValueContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_value + return p +} + +func (*ValueContext) IsValueContext() {} + +func NewValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValueContext { + var p = new(ValueContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_value + + return p +} + +func (s *ValueContext) GetParser() antlr.Parser { return s.parser } + +func (s *ValueContext) STRING() antlr.TerminalNode { + return s.GetToken(AgeParserSTRING, 0) +} + +func (s *ValueContext) NUMBER() antlr.TerminalNode { + return s.GetToken(AgeParserNUMBER, 0) +} + +func (s *ValueContext) NUMERIC() antlr.TerminalNode { + return s.GetToken(AgeParserNUMERIC, 0) +} + +func (s *ValueContext) FLOAT_EXPR() antlr.TerminalNode { + return s.GetToken(AgeParserFLOAT_EXPR, 0) +} + +func (s *ValueContext) BOOL() antlr.TerminalNode { + return s.GetToken(AgeParserBOOL, 0) +} + +func (s *ValueContext) NULL() antlr.TerminalNode { + return s.GetToken(AgeParserNULL, 0) +} + +func (s *ValueContext) Properties() IPropertiesContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPropertiesContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPropertiesContext) +} + +func (s *ValueContext) Arr() IArrContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IArrContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IArrContext) +} + +func (s *ValueContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *ValueContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterValue(s) + } +} + +func (s *ValueContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitValue(s) + } +} + +func (s *ValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitValue(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Value() (localctx IValueContext) { + this := p + _ = this + + localctx = NewValueContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 8, AgeParserRULE_value) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.SetState(51) + p.GetErrorHandler().Sync(p) + + switch p.GetTokenStream().LA(1) { + case AgeParserSTRING: + p.EnterOuterAlt(localctx, 1) + { + p.SetState(43) + p.Match(AgeParserSTRING) + } + + case AgeParserNUMBER: + p.EnterOuterAlt(localctx, 2) + { + p.SetState(44) + p.Match(AgeParserNUMBER) + } + + case AgeParserNUMERIC: + p.EnterOuterAlt(localctx, 3) + { + p.SetState(45) + p.Match(AgeParserNUMERIC) + } + + case AgeParserFLOAT_EXPR: + p.EnterOuterAlt(localctx, 4) + { + p.SetState(46) + p.Match(AgeParserFLOAT_EXPR) + } + + case AgeParserBOOL: + p.EnterOuterAlt(localctx, 5) + { + p.SetState(47) + p.Match(AgeParserBOOL) + } + + case AgeParserNULL: + p.EnterOuterAlt(localctx, 6) + { + p.SetState(48) + p.Match(AgeParserNULL) + } + + case AgeParserT__3: + p.EnterOuterAlt(localctx, 7) + { + p.SetState(49) + p.Properties() + } + + case AgeParserT__0: + p.EnterOuterAlt(localctx, 8) + { + p.SetState(50) + p.Arr() + } + + default: + panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + } + + return localctx +} + +// IPropertiesContext is an interface to support dynamic dispatch. +type IPropertiesContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsPropertiesContext differentiates from other interfaces. + IsPropertiesContext() +} + +type PropertiesContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPropertiesContext() *PropertiesContext { + var p = new(PropertiesContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_properties + return p +} + +func (*PropertiesContext) IsPropertiesContext() {} + +func NewPropertiesContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PropertiesContext { + var p = new(PropertiesContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_properties + + return p +} + +func (s *PropertiesContext) GetParser() antlr.Parser { return s.parser } + +func (s *PropertiesContext) AllPair() []IPairContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IPairContext); ok { + len++ + } + } + + tst := make([]IPairContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IPairContext); ok { + tst[i] = t.(IPairContext) + i++ + } + } + + return tst +} + +func (s *PropertiesContext) Pair(i int) IPairContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPairContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IPairContext) +} + +func (s *PropertiesContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *PropertiesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *PropertiesContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterProperties(s) + } +} + +func (s *PropertiesContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitProperties(s) + } +} + +func (s *PropertiesContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitProperties(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Properties() (localctx IPropertiesContext) { + this := p + _ = this + + localctx = NewPropertiesContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 10, AgeParserRULE_properties) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.SetState(66) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 4, p.GetParserRuleContext()) { + case 1: + p.EnterOuterAlt(localctx, 1) + { + p.SetState(53) + p.Match(AgeParserT__3) + } + { + p.SetState(54) + p.Pair() + } + p.SetState(59) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == AgeParserT__1 { + { + p.SetState(55) + p.Match(AgeParserT__1) + } + { + p.SetState(56) + p.Pair() + } + + p.SetState(61) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(62) + p.Match(AgeParserT__4) + } + + case 2: + p.EnterOuterAlt(localctx, 2) + { + p.SetState(64) + p.Match(AgeParserT__3) + } + { + p.SetState(65) + p.Match(AgeParserT__4) + } + + } + + return localctx +} + +// IPairContext is an interface to support dynamic dispatch. +type IPairContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsPairContext differentiates from other interfaces. + IsPairContext() +} + +type PairContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPairContext() *PairContext { + var p = new(PairContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_pair + return p +} + +func (*PairContext) IsPairContext() {} + +func NewPairContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PairContext { + var p = new(PairContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_pair + + return p +} + +func (s *PairContext) GetParser() antlr.Parser { return s.parser } + +func (s *PairContext) STRING() antlr.TerminalNode { + return s.GetToken(AgeParserSTRING, 0) +} + +func (s *PairContext) Value() IValueContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IValueContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IValueContext) +} + +func (s *PairContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *PairContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *PairContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterPair(s) + } +} + +func (s *PairContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitPair(s) + } +} + +func (s *PairContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitPair(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Pair() (localctx IPairContext) { + this := p + _ = this + + localctx = NewPairContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 12, AgeParserRULE_pair) + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(68) + p.Match(AgeParserSTRING) + } + { + p.SetState(69) + p.Match(AgeParserT__5) + } + { + p.SetState(70) + p.Value() + } + + return localctx +} + +// IArrContext is an interface to support dynamic dispatch. +type IArrContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsArrContext differentiates from other interfaces. + IsArrContext() +} + +type ArrContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyArrContext() *ArrContext { + var p = new(ArrContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = AgeParserRULE_arr + return p +} + +func (*ArrContext) IsArrContext() {} + +func NewArrContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrContext { + var p = new(ArrContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = AgeParserRULE_arr + + return p +} + +func (s *ArrContext) GetParser() antlr.Parser { return s.parser } + +func (s *ArrContext) AllValue() []IValueContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IValueContext); ok { + len++ + } + } + + tst := make([]IValueContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IValueContext); ok { + tst[i] = t.(IValueContext) + i++ + } + } + + return tst +} + +func (s *ArrContext) Value(i int) IValueContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IValueContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IValueContext) +} + +func (s *ArrContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ArrContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *ArrContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.EnterArr(s) + } +} + +func (s *ArrContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(AgeListener); ok { + listenerT.ExitArr(s) + } +} + +func (s *ArrContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case AgeVisitor: + return t.VisitArr(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *AgeParser) Arr() (localctx IArrContext) { + this := p + _ = this + + localctx = NewArrContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 14, AgeParserRULE_arr) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.SetState(85) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 6, p.GetParserRuleContext()) { + case 1: + p.EnterOuterAlt(localctx, 1) + { + p.SetState(72) + p.Match(AgeParserT__0) + } + { + p.SetState(73) + p.Value() + } + p.SetState(78) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == AgeParserT__1 { + { + p.SetState(74) + p.Match(AgeParserT__1) + } + { + p.SetState(75) + p.Value() + } + + p.SetState(80) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(81) + p.Match(AgeParserT__2) + } + + case 2: + p.EnterOuterAlt(localctx, 2) + { + p.SetState(83) + p.Match(AgeParserT__0) + } + { + p.SetState(84) + p.Match(AgeParserT__2) + } + + } + + return localctx +} diff --git a/drivers/golang/parser/age_visitor.go b/drivers/golang/parser/age_visitor.go new file mode 100644 index 000000000..8561750a1 --- /dev/null +++ b/drivers/golang/parser/age_visitor.go @@ -0,0 +1,34 @@ +// Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT. + +package parser // Age + +import "github.com/antlr/antlr4/runtime/Go/antlr/v4" + +// A complete Visitor for a parse tree produced by AgeParser. +type AgeVisitor interface { + antlr.ParseTreeVisitor + + // Visit a parse tree produced by AgeParser#ageout. + VisitAgeout(ctx *AgeoutContext) interface{} + + // Visit a parse tree produced by AgeParser#vertex. + VisitVertex(ctx *VertexContext) interface{} + + // Visit a parse tree produced by AgeParser#edge. + VisitEdge(ctx *EdgeContext) interface{} + + // Visit a parse tree produced by AgeParser#path. + VisitPath(ctx *PathContext) interface{} + + // Visit a parse tree produced by AgeParser#value. + VisitValue(ctx *ValueContext) interface{} + + // Visit a parse tree produced by AgeParser#properties. + VisitProperties(ctx *PropertiesContext) interface{} + + // Visit a parse tree produced by AgeParser#pair. + VisitPair(ctx *PairContext) interface{} + + // Visit a parse tree produced by AgeParser#arr. + VisitArr(ctx *ArrContext) interface{} +}