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')
This commit is contained in:
John Dvorak
2026-05-21 14:39:01 -07:00
parent 96bcce1ddb
commit 4ff56d61c2
2 changed files with 10 additions and 1 deletions
+2 -1
View File
@@ -1139,7 +1139,8 @@ export class GrammarParser {
const relationKinds: Array<Token['kind']> = [ const relationKinds: Array<Token['kind']> = [
'leftOf', 'rightOf', 'above', 'below', 'leftOf', 'rightOf', 'above', 'below',
'alignedWith', 'centeredWithin', 'inside', 'contains', 'overlaps', 'separatedFrom', 'alignedWith', 'leftAlignedWith', 'rightAlignedWith', 'topAlignedWith', 'bottomAlignedWith',
'centeredWithin', 'inside', 'contains', 'overlaps', 'separatedFrom',
// Spatial aliases // Spatial aliases
'beside', 'nextTo', 'adjacent', 'touching', 'near', 'under', 'within', 'beside', 'nextTo', 'adjacent', 'touching', 'near', 'under', 'within',
] ]
+8
View File
@@ -62,6 +62,10 @@ export type TokenKind =
| 'contains' | 'contains'
| 'overlaps' | 'overlaps'
| 'separatedFrom' | 'separatedFrom'
| 'leftAlignedWith'
| 'rightAlignedWith'
| 'topAlignedWith'
| 'bottomAlignedWith'
// Spatial aliases // Spatial aliases
| 'beside' | 'beside'
| 'nextTo' | 'nextTo'
@@ -190,6 +194,10 @@ const KEYWORDS: Record<string, TokenKind> = {
contains: 'contains', contains: 'contains',
overlaps: 'overlaps', overlaps: 'overlaps',
separatedFrom: 'separatedFrom', separatedFrom: 'separatedFrom',
leftAlignedWith: 'leftAlignedWith',
rightAlignedWith: 'rightAlignedWith',
topAlignedWith: 'topAlignedWith',
bottomAlignedWith: 'bottomAlignedWith',
// Spatial aliases // Spatial aliases
beside: 'beside', beside: 'beside',
nextTo: 'nextTo', nextTo: 'nextTo',