Skip to content
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
564 changes: 564 additions & 0 deletions go/downgrades/b4012cfa6fa7de1878c247155b7dfcd76df2604d/go.dbscheme

Large diffs are not rendered by default.

565 changes: 565 additions & 0 deletions go/downgrades/b4012cfa6fa7de1878c247155b7dfcd76df2604d/old.dbscheme

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: Remove table recording the number of parentheses around expressions
compatibility: full
isParenthesized.rel: delete
10 changes: 6 additions & 4 deletions go/extractor/dbscheme/dbscheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,19 @@ func AddDefaultSnippet(snippet string) bool {

// PrintDbScheme prints the schema of this database to the writer `w`
func PrintDbScheme(w io.Writer) {
fmt.Fprintf(w, "/** Auto-generated dbscheme; do not edit. Run `make gen` in directory `go/` to regenerate. */\n\n")
var b strings.Builder
fmt.Fprintf(&b, "/** Auto-generated dbscheme; do not edit. Run `make gen` in directory `go/` to regenerate. */\n\n")
for _, snippet := range defaultSnippets {
fmt.Fprintf(w, "%s\n", snippet)
fmt.Fprintf(&b, "%s\n", snippet)
}
for _, table := range tables {
fmt.Fprintf(w, "%s\n\n", table.String())
fmt.Fprintf(&b, "%s\n\n", table.String())
}
for _, tp := range types {
def := tp.def()
if def != "" {
fmt.Fprintf(w, "%s\n\n", def)
fmt.Fprintf(&b, "%s\n\n", def)
}
}
fmt.Fprintln(w, strings.TrimRight(b.String(), "\n"))
}
6 changes: 6 additions & 0 deletions go/extractor/dbscheme/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,12 @@ var ExprsTable = NewTable("exprs",
IntColumn("idx"),
).KeySet("parent", "idx")

// IsParenthesizedTable is the table associating expressions with how many parentheses they originally had
var IsParenthesizedTable = NewTable("isParenthesized",
EntityColumn(ExprType, "id").Unique(),
IntColumn("parentheses"),
)

// LiteralsTable is the table associating literal expression AST nodes with their values
var LiteralsTable = NewTable("literals",
EntityColumn(ExprType, "expr").Unique(),
Expand Down
16 changes: 13 additions & 3 deletions go/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,12 +1026,22 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int, ski
}

// Skip parenthesised expressions and extract their child directly in their place
if paren, ok := expr.(*ast.ParenExpr); ok {
extractExpr(tw, paren.X, parent, idx, skipExtractingValue)
return
nParens := 0
for {
paren, ok := expr.(*ast.ParenExpr)
if !ok {
break
}
nParens++
expr = paren.X
}

lbl := tw.Labeler.LocalID(expr)

if nParens > 0 {
dbscheme.IsParenthesizedTable.Emit(tw, lbl, nParens)
}

extractTypeOf(tw, expr, lbl)

var kind int
Expand Down
3 changes: 2 additions & 1 deletion go/ql/lib/go.dbscheme
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ 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);

isParenthesized(unique int id: @expr ref, int parentheses: 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);
Expand Down Expand Up @@ -561,4 +563,3 @@ case @error.kind of
| 1 = @listerror
| 2 = @parseerror
| 3 = @typeerror;

Loading
Loading