Skip to content

Commit fbc0d4c

Browse files
akoclaude
andcommitted
fix: allow keyword module names in DESCRIBE MODULE
Adding AGENT, AGENTS, KNOWLEDGE, BASES, CONSUMED, MCP as lexer tokens shadowed module names matching those keywords — e.g. a module literally called "Agents" could no longer be parsed by DESCRIBE MODULE Agents because the rule required a bare IDENTIFIER and "Agents" now lexes as the AGENTS keyword. Fix: DESCRIBE MODULE now accepts identifierOrKeyword (the same helper rule qualifiedName uses), which matches both IDENTIFIER and any reserved keyword. The visitor reads via ctx.IdentifierOrKeyword() with a fallback to ctx.IDENTIFIER() for safety. Verified: - DESCRIBE MODULE Agents now works - DESCRIBE MODULE Agents WITH ALL now works - DESCRIBE MODULE WeatherDemo still works (non-keyword module) - LIST AGENTS IN Agents still works (qualifiedName path was already OK) Note: LIST MODULES Agents is not supported — LIST MODULES takes no filter. Users looking at a single module's contents should use DESCRIBE MODULE <name> WITH ALL or LIST <type> IN <module>. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be9dc7f commit fbc0d4c

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

mdl/grammar/MDLParser.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3038,7 +3038,7 @@ describeStatement
30383038
| DESCRIBE CONSTANT qualifiedName
30393039
| DESCRIBE JAVA ACTION qualifiedName
30403040
| DESCRIBE JAVASCRIPT ACTION qualifiedName
3041-
| DESCRIBE MODULE IDENTIFIER (WITH ALL)? // DESCRIBE MODULE Name [WITH ALL] - optionally include all objects
3041+
| DESCRIBE MODULE identifierOrKeyword (WITH ALL)? // DESCRIBE MODULE Name [WITH ALL] - optionally include all objects
30423042
| DESCRIBE MODULE ROLE qualifiedName // DESCRIBE MODULE ROLE Module.RoleName
30433043
| DESCRIBE USER ROLE STRING_LITERAL // DESCRIBE USER ROLE 'Administrator'
30443044
| DESCRIBE DEMO USER STRING_LITERAL // DESCRIBE DEMO USER 'demo_admin'

mdl/grammar/parser/MDLParser.interp

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

mdl/grammar/parser/mdl_parser.go

Lines changed: 19 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/visitor/visitor_query.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,14 @@ func (b *Builder) ExitDescribeStatement(ctx *parser.DescribeStatementContext) {
668668
return
669669
}
670670

671-
// Handle DESCRIBE MODULE specially (uses IDENTIFIER not qualifiedName)
671+
// Handle DESCRIBE MODULE specially (uses identifierOrKeyword — accepts
672+
// module names that happen to match a keyword, like "Agents").
672673
if ctx.MODULE() != nil {
673674
var moduleName string
674-
if id := ctx.IDENTIFIER(); id != nil {
675+
if iok := ctx.IdentifierOrKeyword(); iok != nil {
676+
moduleName = iok.GetText()
677+
} else if id := ctx.IDENTIFIER(); id != nil {
678+
// Fallback for older grammar versions.
675679
moduleName = id.GetText()
676680
}
677681
b.statements = append(b.statements, &ast.DescribeStmt{

0 commit comments

Comments
 (0)