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:
@@ -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',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user