parser

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

Cypher Parser

A CypherQL parser with openCypher EBNF grammar.

Status

Working in progress.

Usage

Install:

$ go get -u github.com/leiysky/parser

Print the ast node types with visitor:

import (
  "fmt"
  "github.com/leiysky/parser"
)

type printVisitor struct {
	ast.Visitor
}

func (v *printVisitor) Enter(node ast.Node) (ast.Node, bool) {
	fmt.Printf("%T\n", node)
	return node, false
}

func (v *printVisitor) Leave(node ast.Node) (ast.Node, bool) {
	return node, true
}

func main() {
  cypher := `
MATCH (n)-[r:Label *1..10]->()
WHERE n.name = 'leiysky'
SET n.name = 'leiysky1'
RETURN n, r
`
  p := parser.New()
  stmt := p.Parse(cypher)
  stmt.Accept(&testVisitor{})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is used for parsing cypher

func New

func New() *Parser

New will create a Parser

func (*Parser) Parse

func (p *Parser) Parse(cypher string) ast.Stmt

Parse will parse the cypher into ast.Stmt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL