Skip to content

Commit

Permalink
test: Add forward decls to repro grammar + test case
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Nov 3, 2023
1 parent 4c14791 commit c20ea0a
Show file tree
Hide file tree
Showing 10 changed files with 454 additions and 307 deletions.
3 changes: 2 additions & 1 deletion cmd/scip/tests/reprolang/bindings/go/repro/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (r *relationships) identifiers() []*identifier {
}

type referenceStatement struct {
name *identifier
name *identifier
isForwardDecl bool
}

type identifier struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/scip/tests/reprolang/bindings/go/repro/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func (s *reproSourceFile) loadStatements() {
}
case "reference_statement":
s.references = append(s.references, &referenceStatement{
name: newIdentifier(s, child.ChildByFieldName("name")),
name: newIdentifier(s, child.ChildByFieldName("name")),
isForwardDecl: child.ChildByFieldName("forward_decl") != nil,
})
}
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/scip/tests/reprolang/bindings/go/repro/scip.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func (s *reproSourceFile) occurrences() []*scip.Occurrence {
emit(rel.relations)
}
for _, ref := range s.references {
result = append(result, ref.name.occurrence(scip.SymbolRole_UnspecifiedSymbolRole))
role := scip.SymbolRole_UnspecifiedSymbolRole
if ref.isForwardDecl {
role = scip.SymbolRole_ForwardDeclaration
}
result = append(result, ref.name.occurrence(role))
}
return result
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/scip/tests/reprolang/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ module.exports = grammar({
field('name', $.identifier),
field('roles', repeat($._definition_relations))
),
reference_statement: $ => seq('reference', field('name', $.identifier)),
reference_statement: $ =>
seq(
'reference',
field('forward_decl', optional('forward_decl')),
field('name', $.identifier)
),
_definition_relations: $ =>
choice(
$.implementation_relation,
Expand Down
16 changes: 16 additions & 0 deletions cmd/scip/tests/reprolang/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions cmd/scip/tests/reprolang/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c20ea0a

Please sign in to comment.