From 4ff56d61c2c4f58176c3b69e80f081c65a28d886 Mon Sep 17 00:00:00 2001 From: John Dvorak Date: Thu, 21 May 2026 14:39:01 -0700 Subject: [PATCH] feat: wire directional alignment predicates into dense DSL grammar - Add leftAlignedWith/rightAlignedWith/topAlignedWith/bottomAlignedWith to lexer TokenKind union and keyword map - Add to grammar.ts consumeRelation() recognized relation kinds - Dense DSL users can now write: '.a' leftAlignedWith '.b', etc. (previously returned parser error 'Expected relation') --- packages/imhotep-dsl/src/grammar.ts | 3 ++- packages/imhotep-dsl/src/lexer.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/imhotep-dsl/src/grammar.ts b/packages/imhotep-dsl/src/grammar.ts index 8cac529..dc62c61 100644 --- a/packages/imhotep-dsl/src/grammar.ts +++ b/packages/imhotep-dsl/src/grammar.ts @@ -1139,7 +1139,8 @@ export class GrammarParser { const relationKinds: Array = [ 'leftOf', 'rightOf', 'above', 'below', - 'alignedWith', 'centeredWithin', 'inside', 'contains', 'overlaps', 'separatedFrom', + 'alignedWith', 'leftAlignedWith', 'rightAlignedWith', 'topAlignedWith', 'bottomAlignedWith', + 'centeredWithin', 'inside', 'contains', 'overlaps', 'separatedFrom', // Spatial aliases 'beside', 'nextTo', 'adjacent', 'touching', 'near', 'under', 'within', ] diff --git a/packages/imhotep-dsl/src/lexer.ts b/packages/imhotep-dsl/src/lexer.ts index e9d6793..356aa72 100644 --- a/packages/imhotep-dsl/src/lexer.ts +++ b/packages/imhotep-dsl/src/lexer.ts @@ -62,6 +62,10 @@ export type TokenKind = | 'contains' | 'overlaps' | 'separatedFrom' + | 'leftAlignedWith' + | 'rightAlignedWith' + | 'topAlignedWith' + | 'bottomAlignedWith' // Spatial aliases | 'beside' | 'nextTo' @@ -190,6 +194,10 @@ const KEYWORDS: Record = { contains: 'contains', overlaps: 'overlaps', separatedFrom: 'separatedFrom', + leftAlignedWith: 'leftAlignedWith', + rightAlignedWith: 'rightAlignedWith', + topAlignedWith: 'topAlignedWith', + bottomAlignedWith: 'bottomAlignedWith', // Spatial aliases beside: 'beside', nextTo: 'nextTo',