Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit ef8076d

Browse files
committed
📝 the syntactic categories.
1 parent f3ed662 commit ef8076d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

languages/tree-sitter-stack-graphs-java/src/stack-graphs.tsg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ attribute node_symbol = node => symbol = (source-text node), source_n
195195
;; Member Declarations
196196
;; =====================
197197

198+
; Member declarations can occur as members of classes, enums, etc. They propagate lexical scope and usually define one or more names, available in `defs`.
199+
198200
[
199201
(class_declaration)
200202
(enum_declaration)
@@ -207,6 +209,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n
207209
(record_declaration)
208210
] @decl
209211
{
212+
; FIXME: can we get away with defining one and only one thing for each of these, and therefore having a `.def` node instead of `.defs`?
210213
node @decl.defs
211214
node @decl.lexical_scope
212215
}
@@ -433,6 +436,8 @@ attribute node_symbol = node => symbol = (source-text node), source_n
433436
;; Statements
434437
;; ============
435438

439+
; Statements are sequenced one after the next, and some (local variable declarations) bring names into scope/shadow existing names for subsequent statements. Thus, instead of having a lexical scope, they have before and after scopes; the before scope points to the previous statement, or the parent scope for the first statement in a sequence, while the after scope points either at the before scope (if no variable is bound) or at a node referencing any variables the statement binds.
440+
436441
[
437442
(assert_statement)
438443
(block)
@@ -921,6 +926,8 @@ attribute node_symbol = node => symbol = (source-text node), source_n
921926
;; Expressions
922927
;; =============
923928

929+
; Expressions have a lexical scope (propagated to child expressions) and a type. The lexical scope is used for lexical name lookup, while types enable type-based name lookup (for field accesses, method lookup, and so forth).
930+
924931
[
925932
(array_access)
926933
(array_initializer)
@@ -1088,6 +1095,8 @@ attribute node_symbol = node => symbol = (source-text node), source_n
10881095
;; Types
10891096
;; ==========
10901097

1098+
; Types have a lexical scope for type name lookup.
1099+
10911100
[
10921101
(annotated_type)
10931102
(array_type)

0 commit comments

Comments
 (0)