From cbca5750f521c140c42eb0df9ac109be9ae646f2 Mon Sep 17 00:00:00 2001 From: Arunabh Das Date: Wed, 19 Apr 2023 20:02:51 +0800 Subject: [PATCH] ADD: Generation of Parser & Lexer AND installer --- .github/workflows/go-driver.yml | 10 + drivers/golang/README.md | 6 + drivers/golang/age/builder.go | 2 +- drivers/golang/age/mapper.go | 2 +- drivers/golang/go.mod | 5 +- drivers/golang/go.sum | 14 +- drivers/golang/install.bat | 85 ++ drivers/golang/install.sh | 141 ++ drivers/golang/parser/README.md | 13 - drivers/golang/parser/age_base_listener.go | 88 -- drivers/golang/parser/age_base_visitor.go | 59 - drivers/golang/parser/age_lexer.go | 212 --- drivers/golang/parser/age_listener.go | 76 -- drivers/golang/parser/age_parser.go | 1375 -------------------- drivers/golang/parser/age_visitor.go | 52 - drivers/golang/parser/generate.go | 3 + drivers/golang/parser/generate.sh | 12 + 17 files changed, 272 insertions(+), 1883 deletions(-) create mode 100644 drivers/golang/install.bat create mode 100755 drivers/golang/install.sh delete mode 100644 drivers/golang/parser/README.md delete mode 100644 drivers/golang/parser/age_base_listener.go delete mode 100644 drivers/golang/parser/age_base_visitor.go delete mode 100644 drivers/golang/parser/age_lexer.go delete mode 100644 drivers/golang/parser/age_listener.go delete mode 100644 drivers/golang/parser/age_parser.go delete mode 100644 drivers/golang/parser/age_visitor.go create mode 100644 drivers/golang/parser/generate.go create mode 100755 drivers/golang/parser/generate.sh diff --git a/.github/workflows/go-driver.yml b/.github/workflows/go-driver.yml index fbf2cec99..7fbdbfd2b 100644 --- a/.github/workflows/go-driver.yml +++ b/.github/workflows/go-driver.yml @@ -13,6 +13,7 @@ jobs: strategy: matrix: go-version: [ '1.18', '1.19' ] + distributions: ['zulu', 'temurin', 'microsoft'] defaults: run: working-directory: drivers/golang/age/ @@ -27,6 +28,15 @@ jobs: uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: ${{ matrix.distributions }} + java-version: '17' + + - name: Generate + run: go generate ./../... - name: Build run: go build -v ./... diff --git a/drivers/golang/README.md b/drivers/golang/README.md index 367031000..89bd899f3 100644 --- a/drivers/golang/README.md +++ b/drivers/golang/README.md @@ -10,6 +10,12 @@ AGType parser and driver support for [Apache AGE](https://age.apache.org/), grap * over Go 1.18 / 1.19 * This module runs on golang standard api [database/sql](https://golang.org/pkg/database/sql/) and [antlr4-python3](https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr) +### Installation (From source) +Run (Windows): install.bat +Run (Linux & OSX): +``` +sh install.sh +``` ### Go get ``` diff --git a/drivers/golang/age/builder.go b/drivers/golang/age/builder.go index be1c4bbb1..73bae7018 100644 --- a/drivers/golang/age/builder.go +++ b/drivers/golang/age/builder.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr/antlr4/runtime/Go/antlr/v4" "github.com/apache/age/drivers/golang/parser" ) diff --git a/drivers/golang/age/mapper.go b/drivers/golang/age/mapper.go index 5857b1331..987d3c94d 100644 --- a/drivers/golang/age/mapper.go +++ b/drivers/golang/age/mapper.go @@ -23,7 +23,7 @@ import ( "reflect" "strings" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr/antlr4/runtime/Go/antlr/v4" "github.com/apache/age/drivers/golang/parser" ) diff --git a/drivers/golang/go.mod b/drivers/golang/go.mod index a6bd74bd6..a0774e756 100644 --- a/drivers/golang/go.mod +++ b/drivers/golang/go.mod @@ -22,13 +22,14 @@ module github.com/apache/age/drivers/golang go 1.19 require ( - github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec - github.com/lib/pq v1.10.2 + github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 + github.com/lib/pq v1.10.7 github.com/stretchr/testify v1.7.0 ) 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-20230321023759-10a507213a29 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/drivers/golang/go.sum b/drivers/golang/go.sum index 89d1775ed..79dc4cecd 100644 --- a/drivers/golang/go.sum +++ b/drivers/golang/go.sum @@ -1,14 +1,20 @@ -github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec h1:EEyRvzmpEUZ+I8WmD5cw/vY8EqhambkOqy5iFr0908A= -github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc h1:ikxgKfnYm4kXCOohe1uCkVFwZcABDZbVsqginko+GY8= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= +github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/exp v0.0.0-20230223210539-50820d90acfd h1:wtFuj4DoOcAdb82Zh2PI90xiaqgp7maYA7KxjQXVtkY= +golang.org/x/exp v0.0.0-20230223210539-50820d90acfd/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= 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 h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/drivers/golang/install.bat b/drivers/golang/install.bat new file mode 100644 index 000000000..fc2baddbf --- /dev/null +++ b/drivers/golang/install.bat @@ -0,0 +1,85 @@ +@echo off + +rem Install Java Development Kit (JDK) +echo Installing JDK... +if not exist "%ProgramFiles%\Java\jdk-19\" ( + mkdir C:\temp + cd C:\temp + powershell Invoke-WebRequest -Uri "https://download.oracle.com/java/19/archive/jdk-19.0.2_windows-x64_bin.exe" -OutFile jdk-19.0.2_windows-x64_bin.exe + start /wait jdk-19.0.2_windows-x64_bin.exe /s ADDLOCAL="ToolsFeature" /s + del /f jdk-19.0.2_windows-x64_bin.exe + setx /M JAVA_HOME "C:\Program Files\Java\jdk-19.0.2" + setx /M PATH "%PATH%;%JAVA_HOME%\bin" +) else ( + echo JDK already installed. +) + +rem Install Apache Maven +echo Installing Apache Maven... +if not exist "%ProgramFiles%\Apache Maven\apache-maven-3.9.0\" ( + mkdir C:\temp + cd C:\temp + powershell Invoke-WebRequest -Uri "https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.zip" -OutFile apache-maven-3.9.0-bin.zip + powershell Expand-Archive apache-maven-3.9.0-bin.zip -DestinationPath \"%ProgramFiles%\Apache Maven\" + del /f apache-maven-3.9.0-bin.zip + setx /M PATH "%PATH%;%ProgramFiles%\Apache Maven\apache-maven-3.9.0-bin\bin" +) else ( + echo Apache Maven already installed. +) + +rem Download and install ANTLR +echo Downloading ANTLR... +if not exist "%ProgramFiles%\ANTLR" ( + mkdir "%ProgramFiles%\ANTLR" + cd "%ProgramFiles%\ANTLR" + powershell Invoke-WebRequest -Uri "https://www.antlr.org/download/antlr-4.11.1-complete.jar" -OutFile "antlr-4.11.1-complete.jar" + setx /M PATH "%PATH%;%ProgramFiles%\ANTLR\" + setx /M CLASSPATH ".;%ProgramFiles%\ANTLR\antlr-4.11.1-complete.jar;%CLASSPATH%" +) + +echo ANTLR installation complete. + +rem Checking Compatablity for Golang +echo Checking if current version of Golang >= Go 1.18..... +set "minimum_version=1.18" +set "installed_version=" +set "download_url=https://go.dev/dl/go1.19.7.windows-amd64.msi" + +:: Check if Go is installed and get its version +set "go_path=" +for %%i in (go.exe) do set "go_path=%%~$PATH:i" +if defined go_path ( + for /f "tokens=3" %%v in ('go version 2^>^&1') do set "installed_version=%%v" +) + +:: If Go is not installed or the version is less than 1.18, prompt the user to install a new version +if not defined installed_version ( + echo installing Go + :: Download and install the latest version of Go + powershell -Command "& {Invoke-WebRequest -Uri "%download_url%" -OutFile '%TEMP%\go-minimum-version.msi'}" + start /wait msiexec /i "%TEMP%\go-minimum-version.msi" + for /f "tokens=3" %%v in ('go version 2^>^&1') do set "installed_version=%%v" +) else if "%installed_version%" lss "%minimum_version%" ( + set /p "install_new_version=Go version %minimum_version% or higher is required. Would you like to install the latest version? (y/n)" + if /i "%install_new_version%"=="y" ( + :: Download and install the latest version of Go + powershell -Command "& {Invoke-WebRequest -Uri "%download_url%" -OutFile '%TEMP%\go-minimum-version.msi'}" + start /wait msiexec /i "%TEMP%\go-minimum_version.msi" + for /f "tokens=3" %%v in ('go version 2^>^&1') do set "installed_version=%%v" + ) else ( + echo Please update Go version before installing driver. + goto skip + ) +) + +rem Installing Driver +echo --^> Generating ANTLR parser ^& lexer ^for Golang% +java org.antlr.v4.Tool -Dlanguage=Go -visitor Age.g4 -o parser/ +echo --^> Installing Driver +go get -u ./... +goto end +:skip +echo Aborted +:end +pause +endlocal \ No newline at end of file diff --git a/drivers/golang/install.sh b/drivers/golang/install.sh new file mode 100755 index 000000000..5fbc377f2 --- /dev/null +++ b/drivers/golang/install.sh @@ -0,0 +1,141 @@ +#!/bin/sh + +os=$(uname) +arch=$(uname -m) + +java=$(java -version 2>&1 | head -n 1 | cut -d ' ' -f 3 | cut -d '.' -f 1 | cut -d '"' -f 2) +# Check JDK version +echo "Checking for JDK..." +if ! java -version >/dev/null 2>&1 || [ $java -lt 11 ]; then + echo "JDK not found or less than version 11, would you like to install? ()" + echo "Y/N ->" + read answer + if [ "$answer" = y ] || [ "$answer" = Y ]; then + echo "Installing..." + if [[ "$os" == "Darwin" ]]; then + cd /tmp + if [[ "$arch" == "x86_64" ]]; then + curl "https://download.oracle.com/java/20/latest/jdk-20_macos-x64_bin.dmg" -o jdk-20_bin.dmg + elif [[ "$arch" == "arm64" ]]; then + curl "https://download.oracle.com/java/20/latest/jdk-20_macos-aarch64_bin.dmg" -o jdk-20_bin.dmg + fi + hdiutil mount jdk-20_bin.dmg + # sudo installer -pkg "/Volumes/JDK 20/JDK 20.pkg" -target "/" + sudo open -w "/Volumes/JDK 20/JDK 20.pkg" + hdiutil unmount "/Volumes/JDK 20" + rm jdk-20_bin.dmg + + elif [[ "$os" == "Linux" ]]; then + mkdir -p ~/tmp/jdk20 + cd ~/tmp/jdk20 + if [[ "$arch" == "x86_64" ]]; then + curl "https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz" -o jdk-20_bin.tar.gz + elif [[ "$arch" == "arm64" ]]; then + curl "https://download.oracle.com/java/20/latest/jdk-20_linux-aarch64_bin.tar.gz" -o jdk-20_bin.tar.gz + fi + sudo tar zxvf jdk-20_bin.tar.gz -C /usr/local/ + cd ~/ + rm -rf ~/tmp/jdk20/ + fi + echo "JDK installation complete." + else + echo "Please install JDK >= 11.0.16" + exit 0 + fi +else + echo "JDK already installed." +fi + +antlr=$(/usr/local/jdk-20/bin/jar xf /usr/local/antlr/antlr-*-complete.jar META-INF/MANIFEST.MF >/dev/null 2>&1 && grep 'Implementation-Version' META-INF/MANIFEST.MF | cut -d ' ' -f 2 && rm -rf META-INF) +# Check ANTLR installation and version +echo "Checking for ANTLR..." +check_antlr () { + if [ ! -z $antlr ]; then + if ([ "$(echo $antlr | cut -d '.' -f 1)" -lt 4 ] && [ "$(echo $antlr | cut -d '.' -f 2)" -lt 11 ] && [ "$(echo $antlr | cut -d '.' -f 3)" -lt 1 ]); then + return 0 + else + return 1 + fi + else + return 0 + fi +} + +if check_antlr; then + echo "ANTLR not found in Default Location or less than version 4.11.1, would you like to Install?" + echo "(If installed in other location, please edit the location inside the shell script before running)" + echo "Y/N ->" + read answer + if [ "$answer" = y ] || [ "$answer" = Y ]; then + mkdir -p ~/tmp/antlr4.11.1 + cd ~/tmp/antlr4.11.1 + curl -LO "https://www.antlr.org/download/antlr-4.11.1-complete.jar" + sudo mkdir -p /usr/local/antlr + sudo mv ~/tmp/antlr4.11.1/antlr-4.11.1-complete.jar /usr/local/antlr/antlr-4.11.1-complete.jar + + echo 'export CLASSPATH=".:/usr/local/antlr/antlr-4.11.1-complete.jar"' >>~/.bashrc + . ~/.bashrc + echo "ANTLR installation complete." + else + echo "Please install ANTLR >= 4.11.1" + exit 0 + fi + # +else + echo "ANTLR already installed." +fi + +# Check Go installation and version +echo "Checking for Go..." +if ! command -v go >/dev/null 2>&1 || { [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 1) -lt 1 ] && [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 2) -lt 19 ]; }; then + echo "Go not installed or version is less than 1.19, would you like to install?" + echo "Y/N ->" + read answer + if [ "$answer" = y ] || [ "$answer" = Y ]; then + if [[ "$os" == "Darwin" ]]; then + cd /tmp + if [[ "$arch" == "x86_64" ]]; then + curl "https://go.dev/dl/go1.20.2.darwin-amd64.pkg" -o go1.20.2.pkg + elif [[ "$arch" == "arm64" ]]; then + curl "https://go.dev/dl/go1.20.2.darwin-arm64.pkg" -o go1.20.2.pkg + fi + + #sudo installer -pkg "go1.20.2.pkg" -target "/" + sudo open -w golang.pkg + + elif [[ "$os" == "Linux" ]]; then + mdkir -p ~/tmp/go1.20.2 + cd ~/tmp/go1.20.2 + if [[ "$arch" == "x86_64" ]]; then + curl "https://go.dev/dl/go1.20.2.linux-amd64.tar.gz" -o go1.20.2.tar.gz + elif [[ "$arch" == "arm64" ]]; then + curl "https://go.dev/dl/go1.20.2.linux-arm64.tar.gz" -o go1.20.2.tar.gz + fi + + if command -v go >/dev/null 2>&1; then + rm -rf /usr/local/go + fi + sudo tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz + + if ! [[ ":$PATH:" == *":/usr/local/go/bin:"* ]]; then + export PATH=$PATH:/usr/local/go/bin + fi + fi + echo "Go installation complete" + else + echo "Please install Go >= 1.19" + exit 0 + fi +else + echo "Go already installed." +fi + + + +echo "Generating Parser & Lexer..." +java -Xmx500M -cp "/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Go -visitor Age.g4 + +echo "Installing Driver..." +go get -u ./... +echo "Successfully Installed Driver!" +exit 0 diff --git a/drivers/golang/parser/README.md b/drivers/golang/parser/README.md deleted file mode 100644 index a70eede38..000000000 --- a/drivers/golang/parser/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# ANTLR4 Go Query Result data parser generation rules for apache-age-go -Go driver for Apache AGE, graph extension for PostgreSQL. - - -### Build -#### 1) Generate query result data parser with ANTLR4 -``` -# prerequisites : -# - java over 8 -# - download ANTLR4 from https://www.antlr.org/download/antlr-4.9.2-complete.jar -# - java -cp antlr-4.9.2-complete.jar org.antlr.v4.Tool -Dlanguage=Go -visitor Age.g4 -``` - diff --git a/drivers/golang/parser/age_base_listener.go b/drivers/golang/parser/age_base_listener.go deleted file mode 100644 index 009707d6d..000000000 --- a/drivers/golang/parser/age_base_listener.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser // Age - -import "github.com/antlr/antlr4/runtime/Go/antlr" - -// 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 deleted file mode 100644 index 42d59464a..000000000 --- a/drivers/golang/parser/age_base_visitor.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser // Age - -import "github.com/antlr/antlr4/runtime/Go/antlr" - -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 deleted file mode 100644 index fface8327..000000000 --- a/drivers/golang/parser/age_lexer.go +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser - -import ( - "fmt" - "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr" -) - -// Suppress unused import error -var _ = fmt.Printf -var _ = unicode.IsLetter - -var serializedLexerAtn = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 19, 212, - 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, - 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, - 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, - 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, - 9, 23, 4, 24, 9, 24, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, - 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, - 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, - 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, - 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 7, 12, 98, 10, 12, 12, 12, 14, 12, - 101, 11, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, - 13, 3, 13, 3, 13, 5, 13, 114, 10, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, - 3, 15, 3, 15, 3, 15, 5, 15, 124, 10, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, - 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 5, 19, 137, 10, 19, 3, 19, - 3, 19, 3, 19, 6, 19, 142, 10, 19, 13, 19, 14, 19, 143, 5, 19, 146, 10, - 19, 3, 19, 5, 19, 149, 10, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, - 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, - 20, 3, 20, 3, 20, 3, 20, 5, 20, 171, 10, 20, 3, 21, 5, 21, 174, 10, 21, - 3, 21, 3, 21, 3, 21, 6, 21, 179, 10, 21, 13, 21, 14, 21, 180, 5, 21, 183, - 10, 21, 3, 21, 5, 21, 186, 10, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 7, - 22, 193, 10, 22, 12, 22, 14, 22, 196, 11, 22, 5, 22, 198, 10, 22, 3, 23, - 3, 23, 5, 23, 202, 10, 23, 3, 23, 3, 23, 3, 24, 6, 24, 207, 10, 24, 13, - 24, 14, 24, 208, 3, 24, 3, 24, 2, 2, 25, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, - 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 2, 31, - 2, 33, 2, 35, 2, 37, 16, 39, 17, 41, 18, 43, 2, 45, 2, 47, 19, 3, 2, 10, - 10, 2, 36, 36, 49, 49, 94, 94, 100, 100, 104, 104, 112, 112, 116, 116, - 118, 118, 5, 2, 50, 59, 67, 72, 99, 104, 5, 2, 2, 33, 36, 36, 94, 94, 3, - 2, 50, 59, 3, 2, 51, 59, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, - 5, 2, 11, 12, 15, 15, 34, 34, 2, 223, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, - 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, - 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, - 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 37, - 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 3, - 49, 3, 2, 2, 2, 5, 51, 3, 2, 2, 2, 7, 53, 3, 2, 2, 2, 9, 55, 3, 2, 2, 2, - 11, 57, 3, 2, 2, 2, 13, 59, 3, 2, 2, 2, 15, 61, 3, 2, 2, 2, 17, 70, 3, - 2, 2, 2, 19, 77, 3, 2, 2, 2, 21, 84, 3, 2, 2, 2, 23, 94, 3, 2, 2, 2, 25, - 113, 3, 2, 2, 2, 27, 115, 3, 2, 2, 2, 29, 120, 3, 2, 2, 2, 31, 125, 3, - 2, 2, 2, 33, 131, 3, 2, 2, 2, 35, 133, 3, 2, 2, 2, 37, 136, 3, 2, 2, 2, - 39, 170, 3, 2, 2, 2, 41, 173, 3, 2, 2, 2, 43, 197, 3, 2, 2, 2, 45, 199, - 3, 2, 2, 2, 47, 206, 3, 2, 2, 2, 49, 50, 7, 93, 2, 2, 50, 4, 3, 2, 2, 2, - 51, 52, 7, 46, 2, 2, 52, 6, 3, 2, 2, 2, 53, 54, 7, 95, 2, 2, 54, 8, 3, - 2, 2, 2, 55, 56, 7, 125, 2, 2, 56, 10, 3, 2, 2, 2, 57, 58, 7, 127, 2, 2, - 58, 12, 3, 2, 2, 2, 59, 60, 7, 60, 2, 2, 60, 14, 3, 2, 2, 2, 61, 62, 7, - 60, 2, 2, 62, 63, 7, 60, 2, 2, 63, 64, 7, 120, 2, 2, 64, 65, 7, 103, 2, - 2, 65, 66, 7, 116, 2, 2, 66, 67, 7, 118, 2, 2, 67, 68, 7, 103, 2, 2, 68, - 69, 7, 122, 2, 2, 69, 16, 3, 2, 2, 2, 70, 71, 7, 60, 2, 2, 71, 72, 7, 60, - 2, 2, 72, 73, 7, 103, 2, 2, 73, 74, 7, 102, 2, 2, 74, 75, 7, 105, 2, 2, - 75, 76, 7, 103, 2, 2, 76, 18, 3, 2, 2, 2, 77, 78, 7, 60, 2, 2, 78, 79, - 7, 60, 2, 2, 79, 80, 7, 114, 2, 2, 80, 81, 7, 99, 2, 2, 81, 82, 7, 118, - 2, 2, 82, 83, 7, 106, 2, 2, 83, 20, 3, 2, 2, 2, 84, 85, 7, 60, 2, 2, 85, - 86, 7, 60, 2, 2, 86, 87, 7, 112, 2, 2, 87, 88, 7, 119, 2, 2, 88, 89, 7, - 111, 2, 2, 89, 90, 7, 103, 2, 2, 90, 91, 7, 116, 2, 2, 91, 92, 7, 107, - 2, 2, 92, 93, 7, 101, 2, 2, 93, 22, 3, 2, 2, 2, 94, 99, 7, 36, 2, 2, 95, - 98, 5, 29, 15, 2, 96, 98, 5, 35, 18, 2, 97, 95, 3, 2, 2, 2, 97, 96, 3, - 2, 2, 2, 98, 101, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, - 100, 102, 3, 2, 2, 2, 101, 99, 3, 2, 2, 2, 102, 103, 7, 36, 2, 2, 103, - 24, 3, 2, 2, 2, 104, 105, 7, 118, 2, 2, 105, 106, 7, 116, 2, 2, 106, 107, - 7, 119, 2, 2, 107, 114, 7, 103, 2, 2, 108, 109, 7, 104, 2, 2, 109, 110, - 7, 99, 2, 2, 110, 111, 7, 110, 2, 2, 111, 112, 7, 117, 2, 2, 112, 114, - 7, 103, 2, 2, 113, 104, 3, 2, 2, 2, 113, 108, 3, 2, 2, 2, 114, 26, 3, 2, - 2, 2, 115, 116, 7, 112, 2, 2, 116, 117, 7, 119, 2, 2, 117, 118, 7, 110, - 2, 2, 118, 119, 7, 110, 2, 2, 119, 28, 3, 2, 2, 2, 120, 123, 7, 94, 2, - 2, 121, 124, 9, 2, 2, 2, 122, 124, 5, 31, 16, 2, 123, 121, 3, 2, 2, 2, - 123, 122, 3, 2, 2, 2, 124, 30, 3, 2, 2, 2, 125, 126, 7, 119, 2, 2, 126, - 127, 5, 33, 17, 2, 127, 128, 5, 33, 17, 2, 128, 129, 5, 33, 17, 2, 129, - 130, 5, 33, 17, 2, 130, 32, 3, 2, 2, 2, 131, 132, 9, 3, 2, 2, 132, 34, - 3, 2, 2, 2, 133, 134, 10, 4, 2, 2, 134, 36, 3, 2, 2, 2, 135, 137, 7, 47, - 2, 2, 136, 135, 3, 2, 2, 2, 136, 137, 3, 2, 2, 2, 137, 138, 3, 2, 2, 2, - 138, 145, 5, 43, 22, 2, 139, 141, 7, 48, 2, 2, 140, 142, 9, 5, 2, 2, 141, - 140, 3, 2, 2, 2, 142, 143, 3, 2, 2, 2, 143, 141, 3, 2, 2, 2, 143, 144, - 3, 2, 2, 2, 144, 146, 3, 2, 2, 2, 145, 139, 3, 2, 2, 2, 145, 146, 3, 2, - 2, 2, 146, 148, 3, 2, 2, 2, 147, 149, 5, 45, 23, 2, 148, 147, 3, 2, 2, - 2, 148, 149, 3, 2, 2, 2, 149, 38, 3, 2, 2, 2, 150, 151, 7, 80, 2, 2, 151, - 152, 7, 99, 2, 2, 152, 171, 7, 80, 2, 2, 153, 154, 7, 47, 2, 2, 154, 155, - 7, 75, 2, 2, 155, 156, 7, 112, 2, 2, 156, 157, 7, 104, 2, 2, 157, 158, - 7, 107, 2, 2, 158, 159, 7, 112, 2, 2, 159, 160, 7, 107, 2, 2, 160, 161, - 7, 118, 2, 2, 161, 171, 7, 123, 2, 2, 162, 163, 7, 75, 2, 2, 163, 164, - 7, 112, 2, 2, 164, 165, 7, 104, 2, 2, 165, 166, 7, 107, 2, 2, 166, 167, - 7, 112, 2, 2, 167, 168, 7, 107, 2, 2, 168, 169, 7, 118, 2, 2, 169, 171, - 7, 123, 2, 2, 170, 150, 3, 2, 2, 2, 170, 153, 3, 2, 2, 2, 170, 162, 3, - 2, 2, 2, 171, 40, 3, 2, 2, 2, 172, 174, 7, 47, 2, 2, 173, 172, 3, 2, 2, - 2, 173, 174, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 182, 5, 43, 22, 2, - 176, 178, 7, 48, 2, 2, 177, 179, 9, 5, 2, 2, 178, 177, 3, 2, 2, 2, 179, - 180, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 180, 181, 3, 2, 2, 2, 181, 183, - 3, 2, 2, 2, 182, 176, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 185, 3, 2, - 2, 2, 184, 186, 5, 45, 23, 2, 185, 184, 3, 2, 2, 2, 185, 186, 3, 2, 2, - 2, 186, 187, 3, 2, 2, 2, 187, 188, 5, 21, 11, 2, 188, 42, 3, 2, 2, 2, 189, - 198, 7, 50, 2, 2, 190, 194, 9, 6, 2, 2, 191, 193, 9, 5, 2, 2, 192, 191, - 3, 2, 2, 2, 193, 196, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 194, 195, 3, 2, - 2, 2, 195, 198, 3, 2, 2, 2, 196, 194, 3, 2, 2, 2, 197, 189, 3, 2, 2, 2, - 197, 190, 3, 2, 2, 2, 198, 44, 3, 2, 2, 2, 199, 201, 9, 7, 2, 2, 200, 202, - 9, 8, 2, 2, 201, 200, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 203, 3, 2, - 2, 2, 203, 204, 5, 43, 22, 2, 204, 46, 3, 2, 2, 2, 205, 207, 9, 9, 2, 2, - 206, 205, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 206, 3, 2, 2, 2, 208, - 209, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 211, 8, 24, 2, 2, 211, 48, - 3, 2, 2, 2, 20, 2, 97, 99, 113, 123, 136, 143, 145, 148, 170, 173, 180, - 182, 185, 194, 197, 201, 208, 3, 8, 2, 2, -} - -var lexerChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", -} - -var lexerModeNames = []string{ - "DEFAULT_MODE", -} - -var lexerLiteralNames = []string{ - "", "'['", "','", "']'", "'{'", "'}'", "':'", "'::vertex'", "'::edge'", - "'::path'", "'::numeric'", "", "", "'null'", -} - -var lexerSymbolicNames = []string{ - "", "", "", "", "", "", "", "KW_VERTEX", "KW_EDGE", "KW_PATH", "KW_NUMERIC", - "STRING", "BOOL", "NULL", "NUMBER", "FLOAT_EXPR", "NUMERIC", "WS", -} - -var lexerRuleNames = []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", -} - -type AgeLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -// NewAgeLexer produces a new lexer instance for the optional input antlr.CharStream. -// -// The *AgeLexer instance produced may be reused by calling the SetInputStream method. -// The initial lexer configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. -func NewAgeLexer(input antlr.CharStream) *AgeLexer { - l := new(AgeLexer) - lexerDeserializer := antlr.NewATNDeserializer(nil) - lexerAtn := lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) - lexerDecisionToDFA := make([]*antlr.DFA, len(lexerAtn.DecisionToState)) - for index, ds := range lexerAtn.DecisionToState { - lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) - } - l.BaseLexer = antlr.NewBaseLexer(input) - l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) - - l.channelNames = lexerChannelNames - l.modeNames = lexerModeNames - l.RuleNames = lexerRuleNames - l.LiteralNames = lexerLiteralNames - l.SymbolicNames = lexerSymbolicNames - 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 deleted file mode 100644 index fdb06ce60..000000000 --- a/drivers/golang/parser/age_listener.go +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser // Age - -import "github.com/antlr/antlr4/runtime/Go/antlr" - -// 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 deleted file mode 100644 index 4b8a91f3c..000000000 --- a/drivers/golang/parser/age_parser.go +++ /dev/null @@ -1,1375 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser // Age - -import ( - "fmt" - "reflect" - "strconv" - - "github.com/antlr/antlr4/runtime/Go/antlr" -) - -// Suppress unused import errors -var _ = fmt.Printf -var _ = reflect.Copy -var _ = strconv.Itoa - -var parserATN = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 19, 90, 4, - 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, - 8, 9, 8, 4, 9, 9, 9, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 23, 10, 2, 3, 3, 3, - 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 7, - 5, 38, 10, 5, 12, 5, 14, 5, 41, 11, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, - 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 54, 10, 6, 3, 7, 3, 7, 3, 7, 3, - 7, 7, 7, 60, 10, 7, 12, 7, 14, 7, 63, 11, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, - 7, 69, 10, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 79, - 10, 9, 12, 9, 14, 9, 82, 11, 9, 3, 9, 3, 9, 3, 9, 3, 9, 5, 9, 88, 10, 9, - 3, 9, 2, 2, 10, 2, 4, 6, 8, 10, 12, 14, 16, 2, 2, 2, 96, 2, 22, 3, 2, 2, - 2, 4, 24, 3, 2, 2, 2, 6, 27, 3, 2, 2, 2, 8, 30, 3, 2, 2, 2, 10, 53, 3, - 2, 2, 2, 12, 68, 3, 2, 2, 2, 14, 70, 3, 2, 2, 2, 16, 87, 3, 2, 2, 2, 18, - 23, 5, 10, 6, 2, 19, 23, 5, 4, 3, 2, 20, 23, 5, 6, 4, 2, 21, 23, 5, 8, - 5, 2, 22, 18, 3, 2, 2, 2, 22, 19, 3, 2, 2, 2, 22, 20, 3, 2, 2, 2, 22, 21, - 3, 2, 2, 2, 23, 3, 3, 2, 2, 2, 24, 25, 5, 12, 7, 2, 25, 26, 7, 9, 2, 2, - 26, 5, 3, 2, 2, 2, 27, 28, 5, 12, 7, 2, 28, 29, 7, 10, 2, 2, 29, 7, 3, - 2, 2, 2, 30, 31, 7, 3, 2, 2, 31, 39, 5, 4, 3, 2, 32, 33, 7, 4, 2, 2, 33, - 34, 5, 6, 4, 2, 34, 35, 7, 4, 2, 2, 35, 36, 5, 4, 3, 2, 36, 38, 3, 2, 2, - 2, 37, 32, 3, 2, 2, 2, 38, 41, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 39, 40, - 3, 2, 2, 2, 40, 42, 3, 2, 2, 2, 41, 39, 3, 2, 2, 2, 42, 43, 7, 5, 2, 2, - 43, 44, 7, 11, 2, 2, 44, 9, 3, 2, 2, 2, 45, 54, 7, 13, 2, 2, 46, 54, 7, - 16, 2, 2, 47, 54, 7, 18, 2, 2, 48, 54, 7, 17, 2, 2, 49, 54, 7, 14, 2, 2, - 50, 54, 7, 15, 2, 2, 51, 54, 5, 12, 7, 2, 52, 54, 5, 16, 9, 2, 53, 45, - 3, 2, 2, 2, 53, 46, 3, 2, 2, 2, 53, 47, 3, 2, 2, 2, 53, 48, 3, 2, 2, 2, - 53, 49, 3, 2, 2, 2, 53, 50, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 52, 3, - 2, 2, 2, 54, 11, 3, 2, 2, 2, 55, 56, 7, 6, 2, 2, 56, 61, 5, 14, 8, 2, 57, - 58, 7, 4, 2, 2, 58, 60, 5, 14, 8, 2, 59, 57, 3, 2, 2, 2, 60, 63, 3, 2, - 2, 2, 61, 59, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 64, 3, 2, 2, 2, 63, 61, - 3, 2, 2, 2, 64, 65, 7, 7, 2, 2, 65, 69, 3, 2, 2, 2, 66, 67, 7, 6, 2, 2, - 67, 69, 7, 7, 2, 2, 68, 55, 3, 2, 2, 2, 68, 66, 3, 2, 2, 2, 69, 13, 3, - 2, 2, 2, 70, 71, 7, 13, 2, 2, 71, 72, 7, 8, 2, 2, 72, 73, 5, 10, 6, 2, - 73, 15, 3, 2, 2, 2, 74, 75, 7, 3, 2, 2, 75, 80, 5, 10, 6, 2, 76, 77, 7, - 4, 2, 2, 77, 79, 5, 10, 6, 2, 78, 76, 3, 2, 2, 2, 79, 82, 3, 2, 2, 2, 80, - 78, 3, 2, 2, 2, 80, 81, 3, 2, 2, 2, 81, 83, 3, 2, 2, 2, 82, 80, 3, 2, 2, - 2, 83, 84, 7, 5, 2, 2, 84, 88, 3, 2, 2, 2, 85, 86, 7, 3, 2, 2, 86, 88, - 7, 5, 2, 2, 87, 74, 3, 2, 2, 2, 87, 85, 3, 2, 2, 2, 88, 17, 3, 2, 2, 2, - 9, 22, 39, 53, 61, 68, 80, 87, -} -var literalNames = []string{ - "", "'['", "','", "']'", "'{'", "'}'", "':'", "'::vertex'", "'::edge'", - "'::path'", "'::numeric'", "", "", "'null'", -} -var symbolicNames = []string{ - "", "", "", "", "", "", "", "KW_VERTEX", "KW_EDGE", "KW_PATH", "KW_NUMERIC", - "STRING", "BOOL", "NULL", "NUMBER", "FLOAT_EXPR", "NUMERIC", "WS", -} - -var ruleNames = []string{ - "ageout", "vertex", "edge", "path", "value", "properties", "pair", "arr", -} - -type AgeParser struct { - *antlr.BaseParser -} - -// NewAgeParser produces a new parser instance for the optional input antlr.TokenStream. -// -// The *AgeParser instance produced may be reused by calling the SetInputStream method. -// The initial parser configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. -func NewAgeParser(input antlr.TokenStream) *AgeParser { - this := new(AgeParser) - deserializer := antlr.NewATNDeserializer(nil) - deserializedATN := deserializer.DeserializeFromUInt16(parserATN) - decisionToDFA := make([]*antlr.DFA, len(deserializedATN.DecisionToState)) - for index, ds := range deserializedATN.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(ds, index) - } - this.BaseParser = antlr.NewBaseParser(input) - - this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) - this.RuleNames = ruleNames - this.LiteralNames = literalNames - this.SymbolicNames = symbolicNames - this.GrammarFileName = "Age.g4" - - 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 = s.GetTypedRuleContext(reflect.TypeOf((*IValueContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IValueContext) -} - -func (s *AgeoutContext) Vertex() IVertexContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IVertexContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IVertexContext) -} - -func (s *AgeoutContext) Edge() IEdgeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IEdgeContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IEdgeContext) -} - -func (s *AgeoutContext) Path() IPathContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0) - - 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) { - 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 = s.GetTypedRuleContext(reflect.TypeOf((*IPropertiesContext)(nil)).Elem(), 0) - - 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) { - 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 = s.GetTypedRuleContext(reflect.TypeOf((*IPropertiesContext)(nil)).Elem(), 0) - - 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) { - 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 { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IVertexContext)(nil)).Elem()) - var tst = make([]IVertexContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IVertexContext) - } - } - - return tst -} - -func (s *PathContext) Vertex(i int) IVertexContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IVertexContext)(nil)).Elem(), i) - - 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 { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IEdgeContext)(nil)).Elem()) - var tst = make([]IEdgeContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IEdgeContext) - } - } - - return tst -} - -func (s *PathContext) Edge(i int) IEdgeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IEdgeContext)(nil)).Elem(), i) - - 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) { - 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 = s.GetTypedRuleContext(reflect.TypeOf((*IPropertiesContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IPropertiesContext) -} - -func (s *ValueContext) Arr() IArrContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IArrContext)(nil)).Elem(), 0) - - 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) { - 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 { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IPairContext)(nil)).Elem()) - var tst = make([]IPairContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IPairContext) - } - } - - return tst -} - -func (s *PropertiesContext) Pair(i int) IPairContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IPairContext)(nil)).Elem(), i) - - 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) { - 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 = s.GetTypedRuleContext(reflect.TypeOf((*IValueContext)(nil)).Elem(), 0) - - 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) { - 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 { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IValueContext)(nil)).Elem()) - var tst = make([]IValueContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IValueContext) - } - } - - return tst -} - -func (s *ArrContext) Value(i int) IValueContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IValueContext)(nil)).Elem(), i) - - 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) { - 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 deleted file mode 100644 index 06bdc25ac..000000000 --- a/drivers/golang/parser/age_visitor.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// Code generated from Age.g4 by ANTLR 4.9.2. DO NOT EDIT. - -package parser // Age - -import "github.com/antlr/antlr4/runtime/Go/antlr" - -// 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{} -} diff --git a/drivers/golang/parser/generate.go b/drivers/golang/parser/generate.go new file mode 100644 index 000000000..9da7fbc6a --- /dev/null +++ b/drivers/golang/parser/generate.go @@ -0,0 +1,3 @@ +package parser + +//go:generate ./generate.sh diff --git a/drivers/golang/parser/generate.sh b/drivers/golang/parser/generate.sh new file mode 100755 index 000000000..e45501b4e --- /dev/null +++ b/drivers/golang/parser/generate.sh @@ -0,0 +1,12 @@ +#!/bin/sh +GRAMMAR_LOC="$(dirname $(pwd))/parser" + +mkdir -p ~/tmp/antlr +cd ~/tmp/antlr +curl -LO "https://www.antlr.org/download/antlr-4.11.1-complete.jar" +echo "ANTLR installation complete." + +echo "Generating Parser & Lexer..." +java -Xmx500M -cp "$HOME/tmp/antlr/antlr-4.11.1-complete.jar:$HOME/tmp/antlr/antlr-4.11.1-complete.jar" org.antlr.v4.Tool -Dlanguage=Go -visitor $GRAMMAR_LOC/Age.g4 +exit 0 +