зеркало из https://github.com/github/codeql-go.git
Add support for extracting go.mod files
This commit is contained in:
Родитель
89caafb0e1
Коммит
db4efd6124
|
@ -58,6 +58,9 @@ var DocumentableType = NewUnionType("@documentable", NodeType)
|
||||||
// ExprParentType is the type of AST nodes that can have expressions as children
|
// ExprParentType is the type of AST nodes that can have expressions as children
|
||||||
var ExprParentType = NewUnionType("@exprparent", NodeType)
|
var ExprParentType = NewUnionType("@exprparent", NodeType)
|
||||||
|
|
||||||
|
// ModExprParentType is the type of go.mod nodes that can have go.mod expressions as children
|
||||||
|
var ModExprParentType = NewUnionType("@modexprparent", NodeType)
|
||||||
|
|
||||||
// FieldParentType is the type of AST nodes that can have fields as children
|
// FieldParentType is the type of AST nodes that can have fields as children
|
||||||
var FieldParentType = NewUnionType("@fieldparent", NodeType)
|
var FieldParentType = NewUnionType("@fieldparent", NodeType)
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ var ScopeNodeType = NewUnionType("@scopenode", NodeType)
|
||||||
var LocationDefaultType = NewPrimaryKeyType("@location_default")
|
var LocationDefaultType = NewPrimaryKeyType("@location_default")
|
||||||
|
|
||||||
// FileType is the type of file AST nodes
|
// FileType is the type of file AST nodes
|
||||||
var FileType = NewPrimaryKeyType("@file", ContainerType, DocumentableType, ExprParentType, DeclParentType, ScopeNodeType)
|
var FileType = NewPrimaryKeyType("@file", ContainerType, DocumentableType, ExprParentType, ModExprParentType, DeclParentType, ScopeNodeType)
|
||||||
|
|
||||||
// FolderType is the type of folders
|
// FolderType is the type of folders
|
||||||
var FolderType = NewPrimaryKeyType("@folder", ContainerType)
|
var FolderType = NewPrimaryKeyType("@folder", ContainerType)
|
||||||
|
@ -618,6 +621,27 @@ var NamedType = TypeKind.NewBranch("@namedtype", CompositeType)
|
||||||
// PackageType is the type of packages
|
// PackageType is the type of packages
|
||||||
var PackageType = NewPrimaryKeyType("@package")
|
var PackageType = NewPrimaryKeyType("@package")
|
||||||
|
|
||||||
|
// ModExprType is the type of go.mod expression nodes
|
||||||
|
var ModExprType = NewPrimaryKeyType("@modexpr", ModExprParentType, DocumentableType)
|
||||||
|
|
||||||
|
// ModExprKind is a case type for distinguishing different kinds of go.mod expression nodes
|
||||||
|
var ModExprKind = NewCaseType(ModExprType, "kind")
|
||||||
|
|
||||||
|
// ModCommentBlockType is the type of go.mod comment block AST nodes
|
||||||
|
var ModCommentBlockType = ModExprKind.NewBranch("@modcommentblock")
|
||||||
|
|
||||||
|
// ModLineType is the type of go.mod line AST nodes
|
||||||
|
var ModLineType = ModExprKind.NewBranch("@modline")
|
||||||
|
|
||||||
|
// ModLineBlockType is the type of go.mod line block AST nodes
|
||||||
|
var ModLineBlockType = ModExprKind.NewBranch("@modlineblock")
|
||||||
|
|
||||||
|
// ModLParenType is the type of go.mod line block start AST nodes
|
||||||
|
var ModLParenType = ModExprKind.NewBranch("@modlparen")
|
||||||
|
|
||||||
|
// ModRParenType is the type of go.mod line block end AST nodes
|
||||||
|
var ModRParenType = ModExprKind.NewBranch("@modrparen")
|
||||||
|
|
||||||
// LocationsDefaultTable is the table defining location objects
|
// LocationsDefaultTable is the table defining location objects
|
||||||
var LocationsDefaultTable = NewTable("locations_default",
|
var LocationsDefaultTable = NewTable("locations_default",
|
||||||
EntityColumn(LocationDefaultType, "id").Key(),
|
EntityColumn(LocationDefaultType, "id").Key(),
|
||||||
|
@ -876,3 +900,18 @@ var PackagesTable = NewTable("packages",
|
||||||
StringColumn("path"),
|
StringColumn("path"),
|
||||||
EntityColumn(PackageScopeType, "scope"),
|
EntityColumn(PackageScopeType, "scope"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ModExprsTable is the table defining expression AST nodes for go.mod files
|
||||||
|
var ModExprsTable = NewTable("modexprs",
|
||||||
|
EntityColumn(ModExprType, "id").Key(),
|
||||||
|
IntColumn("kind"),
|
||||||
|
EntityColumn(ModExprParentType, "parent"),
|
||||||
|
IntColumn("idx"),
|
||||||
|
).KeySet("parent", "idx")
|
||||||
|
|
||||||
|
// ModTokensTable is the table associating go.mod tokens with their Line or LineBlock
|
||||||
|
var ModTokensTable = NewTable("modtokens",
|
||||||
|
StringColumn("token"),
|
||||||
|
EntityColumn(ModExprType, "parent"),
|
||||||
|
IntColumn("idx"),
|
||||||
|
).KeySet("parent", "idx")
|
||||||
|
|
|
@ -111,6 +111,39 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Warning: unable to get working directory: %s", err.Error())
|
||||||
|
log.Println("Skipping go.mod extraction")
|
||||||
|
}
|
||||||
|
rcwd, err := filepath.EvalSymlinks(cwd)
|
||||||
|
if err == nil {
|
||||||
|
cwd = rcwd
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Walking file tree from %s to discover go.mod files...", cwd)
|
||||||
|
|
||||||
|
filepath.Walk(cwd, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if filepath.Base(path) == "go.mod" && info != nil && info.Mode().IsRegular() {
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Found go.mod with path %s, but encountered error %s", path, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Extracting %s", path)
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
err := extractGoMod(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to extract go.mod: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
end := time.Since(start)
|
||||||
|
log.Printf("Done extracting %s (%dms)", path, end.Nanoseconds()/1000000)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
package extractor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"golang.org/x/mod/modfile"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/github/codeql-go/extractor/dbscheme"
|
||||||
|
"github.com/github/codeql-go/extractor/srcarchive"
|
||||||
|
"github.com/github/codeql-go/extractor/trap"
|
||||||
|
)
|
||||||
|
|
||||||
|
func extractGoMod(path string) error {
|
||||||
|
|
||||||
|
if normPath, err := filepath.EvalSymlinks(path); err == nil {
|
||||||
|
path = normPath
|
||||||
|
}
|
||||||
|
|
||||||
|
tw, err := trap.NewWriter(path, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer tw.Close()
|
||||||
|
|
||||||
|
err = srcarchive.Add(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
extractFileInfo(tw, path)
|
||||||
|
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to open go.mod file %s: %s", path, err.Error())
|
||||||
|
}
|
||||||
|
data, err := ioutil.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to read go.mod file %s: %s", path, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
modfile, err := modfile.Parse(path, data, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to parse go.mod file %s: %s", path, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
extractGoModFile(tw, modfile.Syntax)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractGoModFile(tw *trap.Writer, file *modfile.FileSyntax) {
|
||||||
|
for idx, stmt := range file.Stmt {
|
||||||
|
extractGoModExpr(tw, stmt, tw.Labeler.FileLabel(), idx)
|
||||||
|
}
|
||||||
|
|
||||||
|
extractGoModComments(tw, file, tw.Labeler.FileLabel())
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractGoModExpr(tw *trap.Writer, expr modfile.Expr, parent trap.Label, idx int) {
|
||||||
|
lbl := tw.Labeler.LocalID(expr)
|
||||||
|
|
||||||
|
var kind int
|
||||||
|
switch expr := expr.(type) {
|
||||||
|
case *modfile.CommentBlock:
|
||||||
|
kind = dbscheme.ModCommentBlockType.Index()
|
||||||
|
case *modfile.LParen:
|
||||||
|
kind = dbscheme.ModLParenType.Index()
|
||||||
|
case *modfile.RParen:
|
||||||
|
kind = dbscheme.ModRParenType.Index()
|
||||||
|
case *modfile.Line:
|
||||||
|
kind = dbscheme.ModLineType.Index()
|
||||||
|
for idx, tok := range expr.Token {
|
||||||
|
dbscheme.ModTokensTable.Emit(tw, tok, lbl, idx)
|
||||||
|
}
|
||||||
|
case *modfile.LineBlock:
|
||||||
|
kind = dbscheme.ModLineBlockType.Index()
|
||||||
|
for idx, tok := range expr.Token {
|
||||||
|
dbscheme.ModTokensTable.Emit(tw, tok, lbl, idx)
|
||||||
|
}
|
||||||
|
extractGoModExpr(tw, &expr.LParen, lbl, 0)
|
||||||
|
for idx, line := range expr.Line {
|
||||||
|
extractGoModExpr(tw, line, lbl, idx+1)
|
||||||
|
}
|
||||||
|
extractGoModExpr(tw, &expr.RParen, lbl, len(expr.Line)+1)
|
||||||
|
default:
|
||||||
|
log.Fatalf("unknown go.mod expression of type %T", expr)
|
||||||
|
}
|
||||||
|
|
||||||
|
dbscheme.ModExprsTable.Emit(tw, lbl, kind, parent, idx)
|
||||||
|
|
||||||
|
extractGoModComments(tw, expr, lbl)
|
||||||
|
|
||||||
|
start, end := expr.Span()
|
||||||
|
extractLocation(tw, lbl, start.Line, start.LineRune, end.Line, end.LineRune)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GoModExprCommentWrapper struct {
|
||||||
|
expr modfile.Expr
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractGoModComments(tw *trap.Writer, expr modfile.Expr, exprlbl trap.Label) {
|
||||||
|
// extract a pseudo `@commentgroup` for each expr that contains their associated comments
|
||||||
|
grouplbl := tw.Labeler.LocalID(GoModExprCommentWrapper{expr})
|
||||||
|
dbscheme.DocCommentsTable.Emit(tw, exprlbl, grouplbl)
|
||||||
|
|
||||||
|
comments := expr.Comment()
|
||||||
|
|
||||||
|
idx := 0
|
||||||
|
for _, comment := range comments.Before {
|
||||||
|
extractGoModComment(tw, comment, grouplbl, idx)
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
for _, comment := range comments.Suffix {
|
||||||
|
extractGoModComment(tw, comment, grouplbl, idx)
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
for _, comment := range comments.After {
|
||||||
|
extractGoModComment(tw, comment, grouplbl, idx)
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractGoModComment(tw *trap.Writer, comment modfile.Comment, grouplbl trap.Label, idx int) {
|
||||||
|
lbl := tw.Labeler.LocalID(comment)
|
||||||
|
dbscheme.CommentsTable.Emit(tw, lbl, dbscheme.SlashSlashComment.Index(), grouplbl, idx, comment.Token)
|
||||||
|
|
||||||
|
extractLocation(tw, lbl, comment.Start.Line, comment.Start.LineRune, comment.Start.Line, comment.Start.LineRune+len(comment.Token))
|
||||||
|
}
|
|
@ -118,16 +118,25 @@ type_objects(unique int tp: @type ref, int object: @object ref);
|
||||||
|
|
||||||
packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref);
|
packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
modexprs(unique int id: @modexpr, int kind: int ref, int parent: @modexprparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
modtokens(string token: string ref, int parent: @modexpr ref, int idx: int ref);
|
||||||
|
|
||||||
@container = @file | @folder;
|
@container = @file | @folder;
|
||||||
|
|
||||||
@locatable = @node | @localscope;
|
@locatable = @node | @localscope;
|
||||||
|
|
||||||
@node = @documentable | @exprparent | @fieldparent | @stmtparent | @declparent | @scopenode | @comment_group | @comment;
|
@node = @documentable | @exprparent | @modexprparent | @fieldparent | @stmtparent | @declparent | @scopenode
|
||||||
|
| @comment_group | @comment;
|
||||||
|
|
||||||
@documentable = @file | @field | @spec | @gendecl | @funcdecl;
|
@documentable = @file | @field | @spec | @gendecl | @funcdecl | @modexpr;
|
||||||
|
|
||||||
@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec;
|
@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec;
|
||||||
|
|
||||||
|
@modexprparent = @file | @modexpr;
|
||||||
|
|
||||||
@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr;
|
@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr;
|
||||||
|
|
||||||
@stmtparent = @funcdef | @stmt | @decl;
|
@stmtparent = @funcdef | @stmt | @decl;
|
||||||
|
@ -402,3 +411,10 @@ case @type.kind of
|
||||||
|
|
||||||
@chantype = @sendchantype | @recvchantype | @sendrcvchantype;
|
@chantype = @sendchantype | @recvchantype | @sendrcvchantype;
|
||||||
|
|
||||||
|
case @modexpr.kind of
|
||||||
|
0 = @modcommentblock
|
||||||
|
| 1 = @modline
|
||||||
|
| 2 = @modlineblock
|
||||||
|
| 3 = @modlparen
|
||||||
|
| 4 = @modrparen;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,420 @@
|
||||||
|
/** Auto-generated dbscheme; do not edit. */
|
||||||
|
|
||||||
|
|
||||||
|
/** Duplicate code **/
|
||||||
|
|
||||||
|
duplicateCode(
|
||||||
|
unique int id : @duplication,
|
||||||
|
varchar(900) relativePath : string ref,
|
||||||
|
int equivClass : int ref);
|
||||||
|
|
||||||
|
similarCode(
|
||||||
|
unique int id : @similarity,
|
||||||
|
varchar(900) relativePath : string ref,
|
||||||
|
int equivClass : int ref);
|
||||||
|
|
||||||
|
@duplication_or_similarity = @duplication | @similarity;
|
||||||
|
|
||||||
|
tokens(
|
||||||
|
int id : @duplication_or_similarity ref,
|
||||||
|
int offset : int ref,
|
||||||
|
int beginLine : int ref,
|
||||||
|
int beginColumn : int ref,
|
||||||
|
int endLine : int ref,
|
||||||
|
int endColumn : int ref);
|
||||||
|
|
||||||
|
/** External data **/
|
||||||
|
|
||||||
|
externalData(
|
||||||
|
int id : @externalDataElement,
|
||||||
|
varchar(900) path : string ref,
|
||||||
|
int column: int ref,
|
||||||
|
varchar(900) value : string ref
|
||||||
|
);
|
||||||
|
|
||||||
|
snapshotDate(unique date snapshotDate : date ref);
|
||||||
|
|
||||||
|
sourceLocationPrefix(varchar(900) prefix : string ref);
|
||||||
|
|
||||||
|
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
|
||||||
|
int endLine: int ref, int endColumn: int ref);
|
||||||
|
|
||||||
|
numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref);
|
||||||
|
|
||||||
|
files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref);
|
||||||
|
|
||||||
|
folders(unique int id: @folder, string name: string ref, string simple: string ref);
|
||||||
|
|
||||||
|
containerparent(int parent: @container ref, unique int child: @container ref);
|
||||||
|
|
||||||
|
has_location(unique int locatable: @locatable ref, int location: @location ref);
|
||||||
|
|
||||||
|
comment_groups(unique int id: @comment_group);
|
||||||
|
|
||||||
|
comments(unique int id: @comment, int kind: int ref, int parent: @comment_group ref, int idx: int ref, string text: string ref);
|
||||||
|
|
||||||
|
doc_comments(unique int node: @documentable ref, int comment: @comment_group ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
exprs(unique int id: @expr, int kind: int ref, int parent: @exprparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
literals(unique int expr: @expr ref, string value: string ref, string raw: string ref);
|
||||||
|
|
||||||
|
constvalues(unique int expr: @expr ref, string value: string ref, string exact: string ref);
|
||||||
|
|
||||||
|
fields(unique int id: @field, int parent: @fieldparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
stmts(unique int id: @stmt, int kind: int ref, int parent: @stmtparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
decls(unique int id: @decl, int kind: int ref, int parent: @declparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
specs(unique int id: @spec, int kind: int ref, int parent: @gendecl ref, int idx: int ref);
|
||||||
|
|
||||||
|
scopes(unique int id: @scope, int kind: int ref);
|
||||||
|
|
||||||
|
scopenesting(unique int inner: @scope ref, int outer: @scope ref);
|
||||||
|
|
||||||
|
scopenodes(unique int node: @scopenode ref, int scope: @localscope ref);
|
||||||
|
|
||||||
|
objects(unique int id: @object, int kind: int ref, string name: string ref);
|
||||||
|
|
||||||
|
objectscopes(unique int object: @object ref, int scope: @scope ref);
|
||||||
|
|
||||||
|
objecttypes(unique int object: @object ref, int tp: @type ref);
|
||||||
|
|
||||||
|
methodreceivers(unique int method: @object ref, int receiver: @object ref);
|
||||||
|
|
||||||
|
fieldstructs(unique int field: @object ref, int struct: @structtype ref);
|
||||||
|
|
||||||
|
methodhosts(int method: @object ref, int host: @namedtype ref);
|
||||||
|
|
||||||
|
defs(int ident: @ident ref, int object: @object ref);
|
||||||
|
|
||||||
|
uses(int ident: @ident ref, int object: @object ref);
|
||||||
|
|
||||||
|
types(unique int id: @type, int kind: int ref);
|
||||||
|
|
||||||
|
type_of(unique int expr: @expr ref, int tp: @type ref);
|
||||||
|
|
||||||
|
typename(unique int tp: @type ref, string name: string ref);
|
||||||
|
|
||||||
|
key_type(unique int map: @maptype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
element_type(unique int container: @containertype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
base_type(unique int ptr: @pointertype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
underlying_type(unique int named: @namedtype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
#keyset[parent, index]
|
||||||
|
component_types(int parent: @compositetype ref, int index: int ref, string name: string ref, int tp: @type ref);
|
||||||
|
|
||||||
|
array_length(unique int tp: @arraytype ref, string len: string ref);
|
||||||
|
|
||||||
|
type_objects(unique int tp: @type ref, int object: @object ref);
|
||||||
|
|
||||||
|
packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
modexprs(unique int id: @modexpr, int kind: int ref, int parent: @modexprparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
modtokens(string token: string ref, int parent: @modexpr ref, int idx: int ref);
|
||||||
|
|
||||||
|
@container = @file | @folder;
|
||||||
|
|
||||||
|
@locatable = @node | @localscope;
|
||||||
|
|
||||||
|
@node = @documentable | @exprparent | @modexprparent | @fieldparent | @stmtparent | @declparent | @scopenode
|
||||||
|
| @comment_group | @comment;
|
||||||
|
|
||||||
|
@documentable = @file | @field | @spec | @gendecl | @funcdecl | @modexpr;
|
||||||
|
|
||||||
|
@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec;
|
||||||
|
|
||||||
|
@modexprparent = @file | @modexpr;
|
||||||
|
|
||||||
|
@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr;
|
||||||
|
|
||||||
|
@stmtparent = @funcdef | @stmt | @decl;
|
||||||
|
|
||||||
|
@declparent = @file | @declstmt;
|
||||||
|
|
||||||
|
@funcdef = @funclit | @funcdecl;
|
||||||
|
|
||||||
|
@scopenode = @file | @functypeexpr | @blockstmt | @ifstmt | @caseclause | @switchstmt | @commclause | @loopstmt;
|
||||||
|
|
||||||
|
@location = @location_default;
|
||||||
|
|
||||||
|
@sourceline = @locatable;
|
||||||
|
|
||||||
|
case @comment.kind of
|
||||||
|
0 = @slashslashcomment
|
||||||
|
| 1 = @slashstarcomment;
|
||||||
|
|
||||||
|
case @expr.kind of
|
||||||
|
0 = @badexpr
|
||||||
|
| 1 = @ident
|
||||||
|
| 2 = @ellipsis
|
||||||
|
| 3 = @intlit
|
||||||
|
| 4 = @floatlit
|
||||||
|
| 5 = @imaglit
|
||||||
|
| 6 = @charlit
|
||||||
|
| 7 = @stringlit
|
||||||
|
| 8 = @funclit
|
||||||
|
| 9 = @compositelit
|
||||||
|
| 10 = @parenexpr
|
||||||
|
| 11 = @selectorexpr
|
||||||
|
| 12 = @indexexpr
|
||||||
|
| 13 = @sliceexpr
|
||||||
|
| 14 = @typeassertexpr
|
||||||
|
| 15 = @callorconversionexpr
|
||||||
|
| 16 = @starexpr
|
||||||
|
| 17 = @keyvalueexpr
|
||||||
|
| 18 = @arraytypeexpr
|
||||||
|
| 19 = @structtypeexpr
|
||||||
|
| 20 = @functypeexpr
|
||||||
|
| 21 = @interfacetypeexpr
|
||||||
|
| 22 = @maptypeexpr
|
||||||
|
| 23 = @plusexpr
|
||||||
|
| 24 = @minusexpr
|
||||||
|
| 25 = @notexpr
|
||||||
|
| 26 = @complementexpr
|
||||||
|
| 27 = @derefexpr
|
||||||
|
| 28 = @addressexpr
|
||||||
|
| 29 = @arrowexpr
|
||||||
|
| 30 = @lorexpr
|
||||||
|
| 31 = @landexpr
|
||||||
|
| 32 = @eqlexpr
|
||||||
|
| 33 = @neqexpr
|
||||||
|
| 34 = @lssexpr
|
||||||
|
| 35 = @leqexpr
|
||||||
|
| 36 = @gtrexpr
|
||||||
|
| 37 = @geqexpr
|
||||||
|
| 38 = @addexpr
|
||||||
|
| 39 = @subexpr
|
||||||
|
| 40 = @orexpr
|
||||||
|
| 41 = @xorexpr
|
||||||
|
| 42 = @mulexpr
|
||||||
|
| 43 = @quoexpr
|
||||||
|
| 44 = @remexpr
|
||||||
|
| 45 = @shlexpr
|
||||||
|
| 46 = @shrexpr
|
||||||
|
| 47 = @andexpr
|
||||||
|
| 48 = @andnotexpr
|
||||||
|
| 49 = @sendchantypeexpr
|
||||||
|
| 50 = @recvchantypeexpr
|
||||||
|
| 51 = @sendrcvchantypeexpr;
|
||||||
|
|
||||||
|
@basiclit = @intlit | @floatlit | @imaglit | @charlit | @stringlit;
|
||||||
|
|
||||||
|
@operatorexpr = @logicalexpr | @arithmeticexpr | @bitwiseexpr | @unaryexpr | @binaryexpr;
|
||||||
|
|
||||||
|
@logicalexpr = @logicalunaryexpr | @logicalbinaryexpr;
|
||||||
|
|
||||||
|
@arithmeticexpr = @arithmeticunaryexpr | @arithmeticbinaryexpr;
|
||||||
|
|
||||||
|
@bitwiseexpr = @bitwiseunaryexpr | @bitwisebinaryexpr;
|
||||||
|
|
||||||
|
@unaryexpr = @logicalunaryexpr | @bitwiseunaryexpr | @arithmeticunaryexpr | @derefexpr | @addressexpr | @arrowexpr;
|
||||||
|
|
||||||
|
@logicalunaryexpr = @notexpr;
|
||||||
|
|
||||||
|
@bitwiseunaryexpr = @complementexpr;
|
||||||
|
|
||||||
|
@arithmeticunaryexpr = @plusexpr | @minusexpr;
|
||||||
|
|
||||||
|
@binaryexpr = @logicalbinaryexpr | @bitwisebinaryexpr | @arithmeticbinaryexpr | @comparison;
|
||||||
|
|
||||||
|
@logicalbinaryexpr = @lorexpr | @landexpr;
|
||||||
|
|
||||||
|
@bitwisebinaryexpr = @shiftexpr | @orexpr | @xorexpr | @andexpr | @andnotexpr;
|
||||||
|
|
||||||
|
@arithmeticbinaryexpr = @addexpr | @subexpr | @mulexpr | @quoexpr | @remexpr;
|
||||||
|
|
||||||
|
@shiftexpr = @shlexpr | @shrexpr;
|
||||||
|
|
||||||
|
@comparison = @equalitytest | @relationalcomparison;
|
||||||
|
|
||||||
|
@equalitytest = @eqlexpr | @neqexpr;
|
||||||
|
|
||||||
|
@relationalcomparison = @lssexpr | @leqexpr | @gtrexpr | @geqexpr;
|
||||||
|
|
||||||
|
@chantypeexpr = @sendchantypeexpr | @recvchantypeexpr | @sendrcvchantypeexpr;
|
||||||
|
|
||||||
|
case @stmt.kind of
|
||||||
|
0 = @badstmt
|
||||||
|
| 1 = @declstmt
|
||||||
|
| 2 = @emptystmt
|
||||||
|
| 3 = @labeledstmt
|
||||||
|
| 4 = @exprstmt
|
||||||
|
| 5 = @sendstmt
|
||||||
|
| 6 = @incstmt
|
||||||
|
| 7 = @decstmt
|
||||||
|
| 8 = @gostmt
|
||||||
|
| 9 = @deferstmt
|
||||||
|
| 10 = @returnstmt
|
||||||
|
| 11 = @breakstmt
|
||||||
|
| 12 = @continuestmt
|
||||||
|
| 13 = @gotostmt
|
||||||
|
| 14 = @fallthroughstmt
|
||||||
|
| 15 = @blockstmt
|
||||||
|
| 16 = @ifstmt
|
||||||
|
| 17 = @caseclause
|
||||||
|
| 18 = @exprswitchstmt
|
||||||
|
| 19 = @typeswitchstmt
|
||||||
|
| 20 = @commclause
|
||||||
|
| 21 = @selectstmt
|
||||||
|
| 22 = @forstmt
|
||||||
|
| 23 = @rangestmt
|
||||||
|
| 24 = @assignstmt
|
||||||
|
| 25 = @definestmt
|
||||||
|
| 26 = @addassignstmt
|
||||||
|
| 27 = @subassignstmt
|
||||||
|
| 28 = @mulassignstmt
|
||||||
|
| 29 = @quoassignstmt
|
||||||
|
| 30 = @remassignstmt
|
||||||
|
| 31 = @andassignstmt
|
||||||
|
| 32 = @orassignstmt
|
||||||
|
| 33 = @xorassignstmt
|
||||||
|
| 34 = @shlassignstmt
|
||||||
|
| 35 = @shrassignstmt
|
||||||
|
| 36 = @andnotassignstmt;
|
||||||
|
|
||||||
|
@incdecstmt = @incstmt | @decstmt;
|
||||||
|
|
||||||
|
@assignment = @simpleassignstmt | @compoundassignstmt;
|
||||||
|
|
||||||
|
@simpleassignstmt = @assignstmt | @definestmt;
|
||||||
|
|
||||||
|
@compoundassignstmt = @addassignstmt | @subassignstmt | @mulassignstmt | @quoassignstmt | @remassignstmt
|
||||||
|
| @andassignstmt | @orassignstmt | @xorassignstmt | @shlassignstmt | @shrassignstmt | @andnotassignstmt;
|
||||||
|
|
||||||
|
@branchstmt = @breakstmt | @continuestmt | @gotostmt | @fallthroughstmt;
|
||||||
|
|
||||||
|
@switchstmt = @exprswitchstmt | @typeswitchstmt;
|
||||||
|
|
||||||
|
@loopstmt = @forstmt | @rangestmt;
|
||||||
|
|
||||||
|
case @decl.kind of
|
||||||
|
0 = @baddecl
|
||||||
|
| 1 = @importdecl
|
||||||
|
| 2 = @constdecl
|
||||||
|
| 3 = @typedecl
|
||||||
|
| 4 = @vardecl
|
||||||
|
| 5 = @funcdecl;
|
||||||
|
|
||||||
|
@gendecl = @importdecl | @constdecl | @typedecl | @vardecl;
|
||||||
|
|
||||||
|
case @spec.kind of
|
||||||
|
0 = @importspec
|
||||||
|
| 1 = @valuespec
|
||||||
|
| 2 = @typespec;
|
||||||
|
|
||||||
|
case @object.kind of
|
||||||
|
0 = @pkgobject
|
||||||
|
| 1 = @decltypeobject
|
||||||
|
| 2 = @builtintypeobject
|
||||||
|
| 3 = @declconstobject
|
||||||
|
| 4 = @builtinconstobject
|
||||||
|
| 5 = @declvarobject
|
||||||
|
| 6 = @declfunctionobject
|
||||||
|
| 7 = @builtinfunctionobject
|
||||||
|
| 8 = @labelobject;
|
||||||
|
|
||||||
|
@declobject = @decltypeobject | @declconstobject | @declvarobject | @declfunctionobject;
|
||||||
|
|
||||||
|
@builtinobject = @builtintypeobject | @builtinconstobject | @builtinfunctionobject;
|
||||||
|
|
||||||
|
@typeobject = @decltypeobject | @builtintypeobject;
|
||||||
|
|
||||||
|
@valueobject = @constobject | @varobject | @functionobject;
|
||||||
|
|
||||||
|
@constobject = @declconstobject | @builtinconstobject;
|
||||||
|
|
||||||
|
@varobject = @declvarobject;
|
||||||
|
|
||||||
|
@functionobject = @declfunctionobject | @builtinfunctionobject;
|
||||||
|
|
||||||
|
case @scope.kind of
|
||||||
|
0 = @universescope
|
||||||
|
| 1 = @packagescope
|
||||||
|
| 2 = @localscope;
|
||||||
|
|
||||||
|
case @type.kind of
|
||||||
|
0 = @invalidtype
|
||||||
|
| 1 = @boolexprtype
|
||||||
|
| 2 = @inttype
|
||||||
|
| 3 = @int8type
|
||||||
|
| 4 = @int16type
|
||||||
|
| 5 = @int32type
|
||||||
|
| 6 = @int64type
|
||||||
|
| 7 = @uinttype
|
||||||
|
| 8 = @uint8type
|
||||||
|
| 9 = @uint16type
|
||||||
|
| 10 = @uint32type
|
||||||
|
| 11 = @uint64type
|
||||||
|
| 12 = @uintptrtype
|
||||||
|
| 13 = @float32type
|
||||||
|
| 14 = @float64type
|
||||||
|
| 15 = @complex64type
|
||||||
|
| 16 = @complex128type
|
||||||
|
| 17 = @stringexprtype
|
||||||
|
| 18 = @unsafepointertype
|
||||||
|
| 19 = @boolliteraltype
|
||||||
|
| 20 = @intliteraltype
|
||||||
|
| 21 = @runeliteraltype
|
||||||
|
| 22 = @floatliteraltype
|
||||||
|
| 23 = @complexliteraltype
|
||||||
|
| 24 = @stringliteraltype
|
||||||
|
| 25 = @nilliteraltype
|
||||||
|
| 26 = @arraytype
|
||||||
|
| 27 = @slicetype
|
||||||
|
| 28 = @structtype
|
||||||
|
| 29 = @pointertype
|
||||||
|
| 30 = @interfacetype
|
||||||
|
| 31 = @tupletype
|
||||||
|
| 32 = @signaturetype
|
||||||
|
| 33 = @maptype
|
||||||
|
| 34 = @sendchantype
|
||||||
|
| 35 = @recvchantype
|
||||||
|
| 36 = @sendrcvchantype
|
||||||
|
| 37 = @namedtype;
|
||||||
|
|
||||||
|
@basictype = @booltype | @numerictype | @stringtype | @literaltype | @invalidtype | @uintptrtype | @unsafepointertype;
|
||||||
|
|
||||||
|
@booltype = @boolexprtype | @boolliteraltype;
|
||||||
|
|
||||||
|
@numerictype = @integertype | @floattype | @complextype;
|
||||||
|
|
||||||
|
@integertype = @signedintegertype | @unsignedintegertype;
|
||||||
|
|
||||||
|
@signedintegertype = @inttype | @int8type | @int16type | @int32type | @int64type | @intliteraltype | @runeliteraltype;
|
||||||
|
|
||||||
|
@unsignedintegertype = @uinttype | @uint8type | @uint16type | @uint32type | @uint64type;
|
||||||
|
|
||||||
|
@floattype = @float32type | @float64type | @floatliteraltype;
|
||||||
|
|
||||||
|
@complextype = @complex64type | @complex128type | @complexliteraltype;
|
||||||
|
|
||||||
|
@stringtype = @stringexprtype | @stringliteraltype;
|
||||||
|
|
||||||
|
@literaltype = @boolliteraltype | @intliteraltype | @runeliteraltype | @floatliteraltype | @complexliteraltype
|
||||||
|
| @stringliteraltype | @nilliteraltype;
|
||||||
|
|
||||||
|
@compositetype = @containertype | @structtype | @pointertype | @interfacetype | @tupletype | @signaturetype | @namedtype;
|
||||||
|
|
||||||
|
@containertype = @arraytype | @slicetype | @maptype | @chantype;
|
||||||
|
|
||||||
|
@chantype = @sendchantype | @recvchantype | @sendrcvchantype;
|
||||||
|
|
||||||
|
case @modexpr.kind of
|
||||||
|
0 = @modcommentblock
|
||||||
|
| 1 = @modline
|
||||||
|
| 2 = @modlineblock
|
||||||
|
| 3 = @modlparen
|
||||||
|
| 4 = @modrparen;
|
||||||
|
|
|
@ -0,0 +1,404 @@
|
||||||
|
/** Auto-generated dbscheme; do not edit. */
|
||||||
|
|
||||||
|
|
||||||
|
/** Duplicate code **/
|
||||||
|
|
||||||
|
duplicateCode(
|
||||||
|
unique int id : @duplication,
|
||||||
|
varchar(900) relativePath : string ref,
|
||||||
|
int equivClass : int ref);
|
||||||
|
|
||||||
|
similarCode(
|
||||||
|
unique int id : @similarity,
|
||||||
|
varchar(900) relativePath : string ref,
|
||||||
|
int equivClass : int ref);
|
||||||
|
|
||||||
|
@duplication_or_similarity = @duplication | @similarity;
|
||||||
|
|
||||||
|
tokens(
|
||||||
|
int id : @duplication_or_similarity ref,
|
||||||
|
int offset : int ref,
|
||||||
|
int beginLine : int ref,
|
||||||
|
int beginColumn : int ref,
|
||||||
|
int endLine : int ref,
|
||||||
|
int endColumn : int ref);
|
||||||
|
|
||||||
|
/** External data **/
|
||||||
|
|
||||||
|
externalData(
|
||||||
|
int id : @externalDataElement,
|
||||||
|
varchar(900) path : string ref,
|
||||||
|
int column: int ref,
|
||||||
|
varchar(900) value : string ref
|
||||||
|
);
|
||||||
|
|
||||||
|
snapshotDate(unique date snapshotDate : date ref);
|
||||||
|
|
||||||
|
sourceLocationPrefix(varchar(900) prefix : string ref);
|
||||||
|
|
||||||
|
locations_default(unique int id: @location_default, int file: @file ref, int beginLine: int ref, int beginColumn: int ref,
|
||||||
|
int endLine: int ref, int endColumn: int ref);
|
||||||
|
|
||||||
|
numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref);
|
||||||
|
|
||||||
|
files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref);
|
||||||
|
|
||||||
|
folders(unique int id: @folder, string name: string ref, string simple: string ref);
|
||||||
|
|
||||||
|
containerparent(int parent: @container ref, unique int child: @container ref);
|
||||||
|
|
||||||
|
has_location(unique int locatable: @locatable ref, int location: @location ref);
|
||||||
|
|
||||||
|
comment_groups(unique int id: @comment_group);
|
||||||
|
|
||||||
|
comments(unique int id: @comment, int kind: int ref, int parent: @comment_group ref, int idx: int ref, string text: string ref);
|
||||||
|
|
||||||
|
doc_comments(unique int node: @documentable ref, int comment: @comment_group ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
exprs(unique int id: @expr, int kind: int ref, int parent: @exprparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
literals(unique int expr: @expr ref, string value: string ref, string raw: string ref);
|
||||||
|
|
||||||
|
constvalues(unique int expr: @expr ref, string value: string ref, string exact: string ref);
|
||||||
|
|
||||||
|
fields(unique int id: @field, int parent: @fieldparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
stmts(unique int id: @stmt, int kind: int ref, int parent: @stmtparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
decls(unique int id: @decl, int kind: int ref, int parent: @declparent ref, int idx: int ref);
|
||||||
|
|
||||||
|
#keyset[parent, idx]
|
||||||
|
specs(unique int id: @spec, int kind: int ref, int parent: @gendecl ref, int idx: int ref);
|
||||||
|
|
||||||
|
scopes(unique int id: @scope, int kind: int ref);
|
||||||
|
|
||||||
|
scopenesting(unique int inner: @scope ref, int outer: @scope ref);
|
||||||
|
|
||||||
|
scopenodes(unique int node: @scopenode ref, int scope: @localscope ref);
|
||||||
|
|
||||||
|
objects(unique int id: @object, int kind: int ref, string name: string ref);
|
||||||
|
|
||||||
|
objectscopes(unique int object: @object ref, int scope: @scope ref);
|
||||||
|
|
||||||
|
objecttypes(unique int object: @object ref, int tp: @type ref);
|
||||||
|
|
||||||
|
methodreceivers(unique int method: @object ref, int receiver: @object ref);
|
||||||
|
|
||||||
|
fieldstructs(unique int field: @object ref, int struct: @structtype ref);
|
||||||
|
|
||||||
|
methodhosts(int method: @object ref, int host: @namedtype ref);
|
||||||
|
|
||||||
|
defs(int ident: @ident ref, int object: @object ref);
|
||||||
|
|
||||||
|
uses(int ident: @ident ref, int object: @object ref);
|
||||||
|
|
||||||
|
types(unique int id: @type, int kind: int ref);
|
||||||
|
|
||||||
|
type_of(unique int expr: @expr ref, int tp: @type ref);
|
||||||
|
|
||||||
|
typename(unique int tp: @type ref, string name: string ref);
|
||||||
|
|
||||||
|
key_type(unique int map: @maptype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
element_type(unique int container: @containertype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
base_type(unique int ptr: @pointertype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
underlying_type(unique int named: @namedtype ref, int tp: @type ref);
|
||||||
|
|
||||||
|
#keyset[parent, index]
|
||||||
|
component_types(int parent: @compositetype ref, int index: int ref, string name: string ref, int tp: @type ref);
|
||||||
|
|
||||||
|
array_length(unique int tp: @arraytype ref, string len: string ref);
|
||||||
|
|
||||||
|
type_objects(unique int tp: @type ref, int object: @object ref);
|
||||||
|
|
||||||
|
packages(unique int id: @package, string name: string ref, string path: string ref, int scope: @packagescope ref);
|
||||||
|
|
||||||
|
@container = @file | @folder;
|
||||||
|
|
||||||
|
@locatable = @node | @localscope;
|
||||||
|
|
||||||
|
@node = @documentable | @exprparent | @fieldparent | @stmtparent | @declparent | @scopenode | @comment_group | @comment;
|
||||||
|
|
||||||
|
@documentable = @file | @field | @spec | @gendecl | @funcdecl;
|
||||||
|
|
||||||
|
@exprparent = @funcdef | @file | @expr | @field | @stmt | @decl | @spec;
|
||||||
|
|
||||||
|
@fieldparent = @decl | @structtypeexpr | @functypeexpr | @interfacetypeexpr;
|
||||||
|
|
||||||
|
@stmtparent = @funcdef | @stmt | @decl;
|
||||||
|
|
||||||
|
@declparent = @file | @declstmt;
|
||||||
|
|
||||||
|
@funcdef = @funclit | @funcdecl;
|
||||||
|
|
||||||
|
@scopenode = @file | @functypeexpr | @blockstmt | @ifstmt | @caseclause | @switchstmt | @commclause | @loopstmt;
|
||||||
|
|
||||||
|
@location = @location_default;
|
||||||
|
|
||||||
|
@sourceline = @locatable;
|
||||||
|
|
||||||
|
case @comment.kind of
|
||||||
|
0 = @slashslashcomment
|
||||||
|
| 1 = @slashstarcomment;
|
||||||
|
|
||||||
|
case @expr.kind of
|
||||||
|
0 = @badexpr
|
||||||
|
| 1 = @ident
|
||||||
|
| 2 = @ellipsis
|
||||||
|
| 3 = @intlit
|
||||||
|
| 4 = @floatlit
|
||||||
|
| 5 = @imaglit
|
||||||
|
| 6 = @charlit
|
||||||
|
| 7 = @stringlit
|
||||||
|
| 8 = @funclit
|
||||||
|
| 9 = @compositelit
|
||||||
|
| 10 = @parenexpr
|
||||||
|
| 11 = @selectorexpr
|
||||||
|
| 12 = @indexexpr
|
||||||
|
| 13 = @sliceexpr
|
||||||
|
| 14 = @typeassertexpr
|
||||||
|
| 15 = @callorconversionexpr
|
||||||
|
| 16 = @starexpr
|
||||||
|
| 17 = @keyvalueexpr
|
||||||
|
| 18 = @arraytypeexpr
|
||||||
|
| 19 = @structtypeexpr
|
||||||
|
| 20 = @functypeexpr
|
||||||
|
| 21 = @interfacetypeexpr
|
||||||
|
| 22 = @maptypeexpr
|
||||||
|
| 23 = @plusexpr
|
||||||
|
| 24 = @minusexpr
|
||||||
|
| 25 = @notexpr
|
||||||
|
| 26 = @complementexpr
|
||||||
|
| 27 = @derefexpr
|
||||||
|
| 28 = @addressexpr
|
||||||
|
| 29 = @arrowexpr
|
||||||
|
| 30 = @lorexpr
|
||||||
|
| 31 = @landexpr
|
||||||
|
| 32 = @eqlexpr
|
||||||
|
| 33 = @neqexpr
|
||||||
|
| 34 = @lssexpr
|
||||||
|
| 35 = @leqexpr
|
||||||
|
| 36 = @gtrexpr
|
||||||
|
| 37 = @geqexpr
|
||||||
|
| 38 = @addexpr
|
||||||
|
| 39 = @subexpr
|
||||||
|
| 40 = @orexpr
|
||||||
|
| 41 = @xorexpr
|
||||||
|
| 42 = @mulexpr
|
||||||
|
| 43 = @quoexpr
|
||||||
|
| 44 = @remexpr
|
||||||
|
| 45 = @shlexpr
|
||||||
|
| 46 = @shrexpr
|
||||||
|
| 47 = @andexpr
|
||||||
|
| 48 = @andnotexpr
|
||||||
|
| 49 = @sendchantypeexpr
|
||||||
|
| 50 = @recvchantypeexpr
|
||||||
|
| 51 = @sendrcvchantypeexpr;
|
||||||
|
|
||||||
|
@basiclit = @intlit | @floatlit | @imaglit | @charlit | @stringlit;
|
||||||
|
|
||||||
|
@operatorexpr = @logicalexpr | @arithmeticexpr | @bitwiseexpr | @unaryexpr | @binaryexpr;
|
||||||
|
|
||||||
|
@logicalexpr = @logicalunaryexpr | @logicalbinaryexpr;
|
||||||
|
|
||||||
|
@arithmeticexpr = @arithmeticunaryexpr | @arithmeticbinaryexpr;
|
||||||
|
|
||||||
|
@bitwiseexpr = @bitwiseunaryexpr | @bitwisebinaryexpr;
|
||||||
|
|
||||||
|
@unaryexpr = @logicalunaryexpr | @bitwiseunaryexpr | @arithmeticunaryexpr | @derefexpr | @addressexpr | @arrowexpr;
|
||||||
|
|
||||||
|
@logicalunaryexpr = @notexpr;
|
||||||
|
|
||||||
|
@bitwiseunaryexpr = @complementexpr;
|
||||||
|
|
||||||
|
@arithmeticunaryexpr = @plusexpr | @minusexpr;
|
||||||
|
|
||||||
|
@binaryexpr = @logicalbinaryexpr | @bitwisebinaryexpr | @arithmeticbinaryexpr | @comparison;
|
||||||
|
|
||||||
|
@logicalbinaryexpr = @lorexpr | @landexpr;
|
||||||
|
|
||||||
|
@bitwisebinaryexpr = @shiftexpr | @orexpr | @xorexpr | @andexpr | @andnotexpr;
|
||||||
|
|
||||||
|
@arithmeticbinaryexpr = @addexpr | @subexpr | @mulexpr | @quoexpr | @remexpr;
|
||||||
|
|
||||||
|
@shiftexpr = @shlexpr | @shrexpr;
|
||||||
|
|
||||||
|
@comparison = @equalitytest | @relationalcomparison;
|
||||||
|
|
||||||
|
@equalitytest = @eqlexpr | @neqexpr;
|
||||||
|
|
||||||
|
@relationalcomparison = @lssexpr | @leqexpr | @gtrexpr | @geqexpr;
|
||||||
|
|
||||||
|
@chantypeexpr = @sendchantypeexpr | @recvchantypeexpr | @sendrcvchantypeexpr;
|
||||||
|
|
||||||
|
case @stmt.kind of
|
||||||
|
0 = @badstmt
|
||||||
|
| 1 = @declstmt
|
||||||
|
| 2 = @emptystmt
|
||||||
|
| 3 = @labeledstmt
|
||||||
|
| 4 = @exprstmt
|
||||||
|
| 5 = @sendstmt
|
||||||
|
| 6 = @incstmt
|
||||||
|
| 7 = @decstmt
|
||||||
|
| 8 = @gostmt
|
||||||
|
| 9 = @deferstmt
|
||||||
|
| 10 = @returnstmt
|
||||||
|
| 11 = @breakstmt
|
||||||
|
| 12 = @continuestmt
|
||||||
|
| 13 = @gotostmt
|
||||||
|
| 14 = @fallthroughstmt
|
||||||
|
| 15 = @blockstmt
|
||||||
|
| 16 = @ifstmt
|
||||||
|
| 17 = @caseclause
|
||||||
|
| 18 = @exprswitchstmt
|
||||||
|
| 19 = @typeswitchstmt
|
||||||
|
| 20 = @commclause
|
||||||
|
| 21 = @selectstmt
|
||||||
|
| 22 = @forstmt
|
||||||
|
| 23 = @rangestmt
|
||||||
|
| 24 = @assignstmt
|
||||||
|
| 25 = @definestmt
|
||||||
|
| 26 = @addassignstmt
|
||||||
|
| 27 = @subassignstmt
|
||||||
|
| 28 = @mulassignstmt
|
||||||
|
| 29 = @quoassignstmt
|
||||||
|
| 30 = @remassignstmt
|
||||||
|
| 31 = @andassignstmt
|
||||||
|
| 32 = @orassignstmt
|
||||||
|
| 33 = @xorassignstmt
|
||||||
|
| 34 = @shlassignstmt
|
||||||
|
| 35 = @shrassignstmt
|
||||||
|
| 36 = @andnotassignstmt;
|
||||||
|
|
||||||
|
@incdecstmt = @incstmt | @decstmt;
|
||||||
|
|
||||||
|
@assignment = @simpleassignstmt | @compoundassignstmt;
|
||||||
|
|
||||||
|
@simpleassignstmt = @assignstmt | @definestmt;
|
||||||
|
|
||||||
|
@compoundassignstmt = @addassignstmt | @subassignstmt | @mulassignstmt | @quoassignstmt | @remassignstmt
|
||||||
|
| @andassignstmt | @orassignstmt | @xorassignstmt | @shlassignstmt | @shrassignstmt | @andnotassignstmt;
|
||||||
|
|
||||||
|
@branchstmt = @breakstmt | @continuestmt | @gotostmt | @fallthroughstmt;
|
||||||
|
|
||||||
|
@switchstmt = @exprswitchstmt | @typeswitchstmt;
|
||||||
|
|
||||||
|
@loopstmt = @forstmt | @rangestmt;
|
||||||
|
|
||||||
|
case @decl.kind of
|
||||||
|
0 = @baddecl
|
||||||
|
| 1 = @importdecl
|
||||||
|
| 2 = @constdecl
|
||||||
|
| 3 = @typedecl
|
||||||
|
| 4 = @vardecl
|
||||||
|
| 5 = @funcdecl;
|
||||||
|
|
||||||
|
@gendecl = @importdecl | @constdecl | @typedecl | @vardecl;
|
||||||
|
|
||||||
|
case @spec.kind of
|
||||||
|
0 = @importspec
|
||||||
|
| 1 = @valuespec
|
||||||
|
| 2 = @typespec;
|
||||||
|
|
||||||
|
case @object.kind of
|
||||||
|
0 = @pkgobject
|
||||||
|
| 1 = @decltypeobject
|
||||||
|
| 2 = @builtintypeobject
|
||||||
|
| 3 = @declconstobject
|
||||||
|
| 4 = @builtinconstobject
|
||||||
|
| 5 = @declvarobject
|
||||||
|
| 6 = @declfunctionobject
|
||||||
|
| 7 = @builtinfunctionobject
|
||||||
|
| 8 = @labelobject;
|
||||||
|
|
||||||
|
@declobject = @decltypeobject | @declconstobject | @declvarobject | @declfunctionobject;
|
||||||
|
|
||||||
|
@builtinobject = @builtintypeobject | @builtinconstobject | @builtinfunctionobject;
|
||||||
|
|
||||||
|
@typeobject = @decltypeobject | @builtintypeobject;
|
||||||
|
|
||||||
|
@valueobject = @constobject | @varobject | @functionobject;
|
||||||
|
|
||||||
|
@constobject = @declconstobject | @builtinconstobject;
|
||||||
|
|
||||||
|
@varobject = @declvarobject;
|
||||||
|
|
||||||
|
@functionobject = @declfunctionobject | @builtinfunctionobject;
|
||||||
|
|
||||||
|
case @scope.kind of
|
||||||
|
0 = @universescope
|
||||||
|
| 1 = @packagescope
|
||||||
|
| 2 = @localscope;
|
||||||
|
|
||||||
|
case @type.kind of
|
||||||
|
0 = @invalidtype
|
||||||
|
| 1 = @boolexprtype
|
||||||
|
| 2 = @inttype
|
||||||
|
| 3 = @int8type
|
||||||
|
| 4 = @int16type
|
||||||
|
| 5 = @int32type
|
||||||
|
| 6 = @int64type
|
||||||
|
| 7 = @uinttype
|
||||||
|
| 8 = @uint8type
|
||||||
|
| 9 = @uint16type
|
||||||
|
| 10 = @uint32type
|
||||||
|
| 11 = @uint64type
|
||||||
|
| 12 = @uintptrtype
|
||||||
|
| 13 = @float32type
|
||||||
|
| 14 = @float64type
|
||||||
|
| 15 = @complex64type
|
||||||
|
| 16 = @complex128type
|
||||||
|
| 17 = @stringexprtype
|
||||||
|
| 18 = @unsafepointertype
|
||||||
|
| 19 = @boolliteraltype
|
||||||
|
| 20 = @intliteraltype
|
||||||
|
| 21 = @runeliteraltype
|
||||||
|
| 22 = @floatliteraltype
|
||||||
|
| 23 = @complexliteraltype
|
||||||
|
| 24 = @stringliteraltype
|
||||||
|
| 25 = @nilliteraltype
|
||||||
|
| 26 = @arraytype
|
||||||
|
| 27 = @slicetype
|
||||||
|
| 28 = @structtype
|
||||||
|
| 29 = @pointertype
|
||||||
|
| 30 = @interfacetype
|
||||||
|
| 31 = @tupletype
|
||||||
|
| 32 = @signaturetype
|
||||||
|
| 33 = @maptype
|
||||||
|
| 34 = @sendchantype
|
||||||
|
| 35 = @recvchantype
|
||||||
|
| 36 = @sendrcvchantype
|
||||||
|
| 37 = @namedtype;
|
||||||
|
|
||||||
|
@basictype = @booltype | @numerictype | @stringtype | @literaltype | @invalidtype | @uintptrtype | @unsafepointertype;
|
||||||
|
|
||||||
|
@booltype = @boolexprtype | @boolliteraltype;
|
||||||
|
|
||||||
|
@numerictype = @integertype | @floattype | @complextype;
|
||||||
|
|
||||||
|
@integertype = @signedintegertype | @unsignedintegertype;
|
||||||
|
|
||||||
|
@signedintegertype = @inttype | @int8type | @int16type | @int32type | @int64type | @intliteraltype | @runeliteraltype;
|
||||||
|
|
||||||
|
@unsignedintegertype = @uinttype | @uint8type | @uint16type | @uint32type | @uint64type;
|
||||||
|
|
||||||
|
@floattype = @float32type | @float64type | @floatliteraltype;
|
||||||
|
|
||||||
|
@complextype = @complex64type | @complex128type | @complexliteraltype;
|
||||||
|
|
||||||
|
@stringtype = @stringexprtype | @stringliteraltype;
|
||||||
|
|
||||||
|
@literaltype = @boolliteraltype | @intliteraltype | @runeliteraltype | @floatliteraltype | @complexliteraltype
|
||||||
|
| @stringliteraltype | @nilliteraltype;
|
||||||
|
|
||||||
|
@compositetype = @containertype | @structtype | @pointertype | @interfacetype | @tupletype | @signaturetype | @namedtype;
|
||||||
|
|
||||||
|
@containertype = @arraytype | @slicetype | @maptype | @chantype;
|
||||||
|
|
||||||
|
@chantype = @sendchantype | @recvchantype | @sendrcvchantype;
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
description: Add database tables for go.mod files
|
||||||
|
compatibility: backwards
|
Загрузка…
Ссылка в новой задаче