You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ObjectScript UDL grammar lexes Language = python (and other
non-ObjectScript) method bodies as one opaque external_method_body_content
token using a plain brace counter. The counter is not string- or comment-aware,
so a { or } inside a Python string literal or # comment desynchronizes
it. The body then runs past its own closing brace and swallows the remainder of
the class.
Every method after the offending one disappears from the graph along with all
their edges. The only signal is a soft parse_partial warning naming a single
line range.
A stray balanced } inside a string (s = "close } brace") fails
symmetrically: the body truncates early and ERROR nodes appear.
Root cause
internal/cbm/vendored/grammars/objectscript_udl/scanner.c:17-34. lex_fenced_text tracks only nesting depth on { / }. Dispatched at :60-66.
The grammar's language-based production switch works correctly. parser.c:1585 defines sym_method_keyword_language; Language = python and tsql yield external_method_keywords plus an opaque external_method_body_content, while Language = cache and objectscript
yield parsed statement nodes. Only the fenced-text lexer is at fault.
Suggested fix
Make lex_fenced_text skip string literals and line comments while counting.
For Python bodies that means ', ", ''', """, string prefixes (f, r, b, u and combinations), backslash escapes, and # to end-of-line.
Question before I write code
scanner.c is vendored from intersystems/tree-sitter-objectscript,
which you audited and vendored yourself in #590. Patching it in-tree diverges
from the upstream grammar and will conflict on the next re-vendor.
How would you prefer this handled?
PR to intersystems/tree-sitter-objectscript, then you re-vendor. Clean,
but gated on that repo's review latency.
In-tree patch to the vendored scanner.c with a comment marking the local
delta, and an upstream PR filed in parallel.
Happy to do the work either way. I'd rather not touch a vendored file without
your direction.
Related
The embedded-Python graph-representation issue (filed separately) depends on this being
fixed. Re-parsing the Python body is only meaningful once the body's byte range
is correct.
Summary
The ObjectScript UDL grammar lexes
Language = python(and othernon-ObjectScript) method bodies as one opaque
external_method_body_contenttoken using a plain brace counter. The counter is not string- or comment-aware,
so a
{or}inside a Python string literal or#comment desynchronizesit. The body then runs past its own closing brace and swallows the remainder of
the class.
Every method after the offending one disappears from the graph along with all
their edges. The only signal is a soft
parse_partialwarning naming a singleline range.
Reproduction
Two files.
Tgt.cls:Brace.cls, where the{inside the Python string is ordinary Python:Index the directory, then:
Observed:
RealOneandRealTwoare absent. And:returns zero rows. Both
CALLS -> My.Tgt.Hitedges are gone.Hititself isindexed, so the call sites were never parsed rather than failing to resolve.
The index response reports only:
A stray balanced
}inside a string (s = "close } brace") failssymmetrically: the body truncates early and
ERRORnodes appear.Root cause
internal/cbm/vendored/grammars/objectscript_udl/scanner.c:17-34.lex_fenced_texttracks only nesting depth on{/}. Dispatched at:60-66.The grammar's language-based production switch works correctly.
parser.c:1585definessym_method_keyword_language;Language = pythonandtsqlyieldexternal_method_keywordsplus an opaqueexternal_method_body_content, whileLanguage = cacheandobjectscriptyield parsed
statementnodes. Only the fenced-text lexer is at fault.Suggested fix
Make
lex_fenced_textskip string literals and line comments while counting.For Python bodies that means
',",''',""", string prefixes (f,r,b,uand combinations), backslash escapes, and#to end-of-line.Question before I write code
scanner.cis vendored fromintersystems/tree-sitter-objectscript,
which you audited and vendored yourself in #590. Patching it in-tree diverges
from the upstream grammar and will conflict on the next re-vendor.
How would you prefer this handled?
intersystems/tree-sitter-objectscript, then you re-vendor. Clean,but gated on that repo's review latency.
scanner.cwith a comment marking the localdelta, and an upstream PR filed in parallel.
the scanner restore in feat(objectscript): InterSystems IRIS ObjectScript language support #467.
Happy to do the work either way. I'd rather not touch a vendored file without
your direction.
Related
The embedded-Python graph-representation issue (filed separately) depends on this being
fixed. Re-parsing the Python body is only meaningful once the body's byte range
is correct.