Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
- docker

before_script:
- go get -v gopkg.in/bblfsh/sdk.v0/...
- go get -v gopkg.in/bblfsh/sdk.v1/...
- bblfsh-sdk prepare-build .
- go get -v -t ./...

Expand Down
303 changes: 150 additions & 153 deletions ANNOTATION.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion driver/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"gopkg.in/bblfsh/sdk.v0/protocol/driver"
"gopkg.in/bblfsh/sdk.v1/protocol/driver"

"github.com/bblfsh/python-driver/driver/normalizer"
)
Expand Down
486 changes: 230 additions & 256 deletions driver/normalizer/annotation.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion driver/normalizer/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"gopkg.in/bblfsh/sdk.v0/uast"
"gopkg.in/bblfsh/sdk.v1/uast"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions driver/normalizer/parser.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package normalizer

import (
"gopkg.in/bblfsh/sdk.v0/protocol/driver"
"gopkg.in/bblfsh/sdk.v0/protocol/native"
"gopkg.in/bblfsh/sdk.v1/protocol/driver"
"gopkg.in/bblfsh/sdk.v1/protocol/native"
)

var ToNoder = &native.ObjectToNoder{
Expand Down
293 changes: 161 additions & 132 deletions driver/normalizer/pyast/pyast.go
Original file line number Diff line number Diff line change
@@ -1,143 +1,172 @@
// Package pyast defines constants from Python 2 and 3 AST.
package pyast

// GENERATED BY python-driver/native/gogen/gogen.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer autogenerated?

Copy link
Contributor Author

@juanjux juanjux Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually it was being manually managed since some time ago, I moved the HasInternalType calls these to have a clearer annotations.go file (like you did in the Java driver) and sorted alphabetically. Also, I was getting slightly different results on gogen depending on the minor Python version used. I'll update or remove gogen.py soon.

// DO NOT EDIT
import "gopkg.in/bblfsh/sdk.v1/uast/ann"

// Python 2+3 AST node types.
// FIXME: ColumnKey? (col_offset in Python)
// This includes all classes extending from _ast.AST for both Python 2 and 3.
// See:
// https://docs.python.org/3.6/library/ast.html#abstract-grammar
// https://docs.python.org/2.7/library/ast.html#abstract-grammar

const (
Add = "Add"
Alias = "alias"
And = "And"
AnnAssign = "AnnAssign"
Annotation = "Annotation"
Arg = "arg"
Arguments = "arguments"
Assert = "Assert"
Assign = "Assign"
AsyncFor = "AsyncFor"
AsyncFunctionDef = "AsyncFunctionDef"
AsyncWith = "AsyncWith"
Attribute = "Attribute"
AugAssign = "AugAssign"
AugLoad = "AugLoad"
AugStore = "AugStore"
Await = "Await"
BinOp = "BinOp"
BitAnd = "BitAnd"
BitOr = "BitOr"
BitXor = "BitXor"
BoolLiteral = "BoolLiteral"
BoolOp = "BoolOp"
BoolopInternal = "boolop"
Break = "Break"
Bytes = "Bytes"
Call = "Call"
ClassDef = "ClassDef"
Cmpop = "cmpop"
Compare = "Compare"
Comprehension = "comprehension"
Constant = "Constant"
Continue = "Continue"
Del = "Del"
Delete = "Delete"
Dict = "Dict"
DictComp = "DictComp"
Div = "Div"
Ellipsis = "Ellipsis"
Eq = "Eq"
ExceptHandler = "ExceptHandler"
ExcepthandlerInternal = "excepthandler"
Exec = "Exec"
Expr = "Expr"
ExprInternal = "expr"
Expr_context = "expr_context"
Expression = "Expression"
ExtSlice = "ExtSlice"
FloorDiv = "FloorDiv"
For = "For"
FormattedValue = "FormattedValue"
FunctionDef = "FunctionDef"
GeneratorExp = "GeneratorExp"
Global = "Global"
Gt = "Gt"
GtE = "GtE"
If = "If"
IfExp = "IfExp"
Import = "Import"
ImportFrom = "ImportFrom"
In = "In"
Index = "Index"
Interactive = "Interactive"
Invert = "Invert"
Is = "Is"
IsNot = "IsNot"
JoinedStr = "JoinedStr"
Keyword = "keyword"
LShift = "LShift"
Lambda = "Lambda"
List = "List"
ListComp = "ListComp"
Load = "Load"
Lt = "Lt"
LtE = "LtE"
MatMult = "MatMult"
Mod = "Mod"
ModInternal = "mod"
Module = "Module"
Mult = "Mult"
Name = "Name"
NameConstant = "NameConstant"
NoneLiteral = "NoneLiteral"
Nonlocal = "Nonlocal"
NoopLine = "NoopLine"
Noop_lineInternal = "noop_line"
Not = "Not"
NotEq = "NotEq"
NotIn = "NotIn"
Num = "Num"
Operator = "operator"
Or = "Or"
Param = "Param"
Pass = "Pass"
Pow = "Pow"
PreviousNoops = "PreviousNoops"
Print = "Print"
RShift = "RShift"
Raise = "Raise"
RemainderNoops = "RemainderNoops"
Repr = "Repr"
Return = "Return"
Returns = "returns"
SameLineNoops = "SameLineNoops"
Set = "Set"
SetComp = "SetComp"
Slice = "Slice"
SliceInternal = "slice"
Starred = "Starred"
Stmt = "stmt"
Store = "Store"
Str = "Str"
Sub = "Sub"
Subscript = "Subscript"
Suite = "Suite"
Try = "Try"
TryExcept = "TryExcept"
TryFinally = "TryFinally"
Tuple = "Tuple"
UAdd = "UAdd"
USub = "USub"
UnaryOp = "UnaryOp"
UnaryopInternal = "unaryop"
While = "While"
With = "With"
Withitem = "withitem"
Yield = "Yield"
YieldFrom = "YieldFrom"
var (
Add = ann.HasInternalType("Add")
Alias = ann.HasInternalType("alias")
AliasAsName = ann.HasInternalType("alias.asname")
And = ann.HasInternalType("And")
AnnAssign = ann.HasInternalType("AnnAssign")
Annotation = ann.HasInternalType("Annotation")
Arg = ann.HasInternalType("arg")
ArgumentDefaults = ann.HasInternalType("arguments.defaults")
Arguments = ann.HasInternalType("arguments")
Assert = ann.HasInternalType("Assert")
Assign = ann.HasInternalType("Assign")
AsyncFor = ann.HasInternalType("AsyncFor")
AsyncForBody = ann.HasInternalType("AsyncFor.body")
AsyncForElse = ann.HasInternalType("AsyncFor.orelse")
AsyncFuncDecorators = ann.HasInternalType("AsyncFunctionDef.decorator_list")
AsyncFuncDefBody = ann.HasInternalType("AsyncFunctionDef.body")
AsyncFunctionDef = ann.HasInternalType("AsyncFunctionDef")
AsyncWith = ann.HasInternalType("AsyncWith")
Attribute = ann.HasInternalType("Attribute")
AugAssign = ann.HasInternalType("AugAssign")
AugLoad = ann.HasInternalType("AugLoad")
AugStore = ann.HasInternalType("AugStore")
Await = ann.HasInternalType("Await")
BinOp = ann.HasInternalType("BinOp")
BitAnd = ann.HasInternalType("BitAnd")
BitOr = ann.HasInternalType("BitOr")
BitXor = ann.HasInternalType("BitXor")
BoolLiteral = ann.HasInternalType("BoolLiteral")
BoolOp = ann.HasInternalType("BoolOp")
BoolopInternal = ann.HasInternalType("boolop")
Break = ann.HasInternalType("Break")
ByteLiteral = ann.HasInternalType("ByteLiteral")
Bytes = ann.HasInternalType("Bytes")
Call = ann.HasInternalType("Call")
ClassDef = ann.HasInternalType("ClassDef")
ClassDefDecorators = ann.HasInternalType("ClassDef.decorator_list")
ClassDefBases = ann.HasInternalType("ClassDef.bases")
ClassDefBody = ann.HasInternalType("ClassDef.body")
ClassDefKeywords = ann.HasInternalType("ClassDef.keywords")
Cmpop = ann.HasInternalType("cmpop")
Compare = ann.HasInternalType("Compare")
CompareComparators = ann.HasInternalType("Compare.comparators")
CompareOps = ann.HasInternalType("Compare.ops")
Comprehension = ann.HasInternalType("comprehension")
Constant = ann.HasInternalType("Constant")
Continue = ann.HasInternalType("Continue")
Del = ann.HasInternalType("Del")
Delete = ann.HasInternalType("Delete")
Dict = ann.HasInternalType("Dict")
DictComp = ann.HasInternalType("DictComp")
Div = ann.HasInternalType("Div")
Ellipsis = ann.HasInternalType("Ellipsis")
Eq = ann.HasInternalType("Eq")
ExceptHandler = ann.HasInternalType("ExceptHandler")
ExceptHandlerName = ann.HasInternalType("ExceptHandler.name")
ExcepthandlerInternal = ann.HasInternalType("excepthandler")
Exec = ann.HasInternalType("Exec")
Expr = ann.HasInternalType("Expr")
ExprInternal = ann.HasInternalType("expr")
ExprContext = ann.HasInternalType("expr_context")
Expression = ann.HasInternalType("Expression")
ExtSlice = ann.HasInternalType("ExtSlice")
FloorDiv = ann.HasInternalType("FloorDiv")
For = ann.HasInternalType("For")
ForBody = ann.HasInternalType("For.body")
ForElse = ann.HasInternalType("For.orelse")
FormattedValue = ann.HasInternalType("FormattedValue")
FuncDecorators = ann.HasInternalType("FunctionDef.decorator_list")
FuncDefBody = ann.HasInternalType("FunctionDef.body")
FunctionDef = ann.HasInternalType("FunctionDef")
GeneratorExp = ann.HasInternalType("GeneratorExp")
Global = ann.HasInternalType("Global")
Gt = ann.HasInternalType("Gt")
GtE = ann.HasInternalType("GtE")
If = ann.HasInternalType("If")
IfBody = ann.HasInternalType("If.body")
IfElse = ann.HasInternalType("If.orelse")
IfExp = ann.HasInternalType("IfExp")
Import = ann.HasInternalType("Import")
ImportFrom = ann.HasInternalType("ImportFrom")
ImportFromModule = ann.HasInternalType("ImportFrom.module")
In = ann.HasInternalType("In")
Index = ann.HasInternalType("Index")
Interactive = ann.HasInternalType("Interactive")
Invert = ann.HasInternalType("Invert")
Is = ann.HasInternalType("Is")
IsNot = ann.HasInternalType("IsNot")
JoinedStr = ann.HasInternalType("JoinedStr")
Keyword = ann.HasInternalType("keyword")
LShift = ann.HasInternalType("LShift")
Lambda = ann.HasInternalType("Lambda")
LambdaBody = ann.HasInternalType("Lambda.body")
List = ann.HasInternalType("List")
ListComp = ann.HasInternalType("ListComp")
Load = ann.HasInternalType("Load")
Lt = ann.HasInternalType("Lt")
LtE = ann.HasInternalType("LtE")
MatMult = ann.HasInternalType("MatMult")
Mod = ann.HasInternalType("Mod")
ModInternal = ann.HasInternalType("mod")
Module = ann.HasInternalType("Module")
Mult = ann.HasInternalType("Mult")
Name = ann.HasInternalType("Name")
NameConstant = ann.HasInternalType("NameConstant")
NoneLiteral = ann.HasInternalType("NoneLiteral")
Nonlocal = ann.HasInternalType("Nonlocal")
NoopLine = ann.HasInternalType("NoopLine")
Noop_lineInternal = ann.HasInternalType("noop_line")
Not = ann.HasInternalType("Not")
NotEq = ann.HasInternalType("NotEq")
NotIn = ann.HasInternalType("NotIn")
Num = ann.HasInternalType("Num")
Operator = ann.HasInternalType("operator")
Or = ann.HasInternalType("Or")
Param = ann.HasInternalType("Param")
Pass = ann.HasInternalType("Pass")
Pow = ann.HasInternalType("Pow")
PreviousNoops = ann.HasInternalType("PreviousNoops")
Print = ann.HasInternalType("Print")
RShift = ann.HasInternalType("RShift")
Raise = ann.HasInternalType("Raise")
RemainderNoops = ann.HasInternalType("RemainderNoops")
Repr = ann.HasInternalType("Repr")
Return = ann.HasInternalType("Return")
Returns = ann.HasInternalType("returns")
SameLineNoops = ann.HasInternalType("SameLineNoops")
Set = ann.HasInternalType("Set")
SetComp = ann.HasInternalType("SetComp")
Slice = ann.HasInternalType("Slice")
SliceInternal = ann.HasInternalType("slice")
StringLiteral = ann.HasInternalType("StringLiteral")
Starred = ann.HasInternalType("Starred")
Stmt = ann.HasInternalType("stmt")
Store = ann.HasInternalType("Store")
Str = ann.HasInternalType("Str")
Sub = ann.HasInternalType("Sub")
Subscript = ann.HasInternalType("Subscript")
Suite = ann.HasInternalType("Suite")
Try = ann.HasInternalType("Try")
TryBody = ann.HasInternalType("Try.body")
TryElse = ann.HasInternalType("Try.orelse")
TryExcept = ann.HasInternalType("TryExcept")
TryFinalBody = ann.HasInternalType("Try.finalbody")
TryFinally = ann.HasInternalType("TryFinally")
TryHandlers = ann.HasInternalType("Try.handlers")
Tuple = ann.HasInternalType("Tuple")
UAdd = ann.HasInternalType("UAdd")
USub = ann.HasInternalType("USub")
UnaryOp = ann.HasInternalType("UnaryOp")
UnaryopInternal = ann.HasInternalType("unaryop")
While = ann.HasInternalType("While")
WhileBody = ann.HasInternalType("While.body")
WhileElse = ann.HasInternalType("While.orelse")
With = ann.HasInternalType("With")
WithBody = ann.HasInternalType("With.body")
WithItems = ann.HasInternalType("With.items")
Withitem = ann.HasInternalType("withitem")
Yield = ann.HasInternalType("Yield")
YieldFrom = ann.HasInternalType("YieldFrom")
)
Loading