feat(parser): complete DotGet implementation with scope tracking
- Fixed tokenizer input.read() to use absolute positions - Fixed FN_KEYWORD term ID (33 after DotGet added to expression) - Added DotGet to expression for use as function argument - All 8 DotGet tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
22fba65a53
commit
d894713744
|
|
@ -43,7 +43,7 @@ let pendingIdentifiers: string[] = []
|
||||||
let isInParams = false
|
let isInParams = false
|
||||||
|
|
||||||
// Term ID for 'fn' keyword - verified by parsing and inspecting the tree
|
// Term ID for 'fn' keyword - verified by parsing and inspecting the tree
|
||||||
const FN_KEYWORD = 32
|
const FN_KEYWORD = 33
|
||||||
|
|
||||||
export const trackScope = new ContextTracker<Scope>({
|
export const trackScope = new ContextTracker<Scope>({
|
||||||
start: new Scope(null, new Set()),
|
start: new Scope(null, new Set()),
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ ParenExpr {
|
||||||
}
|
}
|
||||||
|
|
||||||
expression {
|
expression {
|
||||||
expressionWithoutIdentifier | Identifier
|
expressionWithoutIdentifier | DotGet | Identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
@skip {} {
|
@skip {} {
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ export const
|
||||||
Boolean = 28,
|
Boolean = 28,
|
||||||
Regex = 29,
|
Regex = 29,
|
||||||
Null = 30,
|
Null = 30,
|
||||||
FunctionDef = 31,
|
DotGet = 31,
|
||||||
Params = 33,
|
FunctionDef = 32,
|
||||||
colon = 34,
|
Params = 34,
|
||||||
end = 35,
|
colon = 35,
|
||||||
Underscore = 36,
|
end = 36,
|
||||||
NamedArg = 37,
|
Underscore = 37,
|
||||||
NamedArgPrefix = 38,
|
NamedArg = 38,
|
||||||
DotGet = 40,
|
NamedArgPrefix = 39,
|
||||||
IfExpr = 41,
|
IfExpr = 41,
|
||||||
ThenBlock = 44,
|
ThenBlock = 44,
|
||||||
ElsifExpr = 45,
|
ElsifExpr = 45,
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,21 @@ import {trackScope} from "./scopeTracker"
|
||||||
import {highlighting} from "./highlight"
|
import {highlighting} from "./highlight"
|
||||||
export const parser = LRParser.deserialize({
|
export const parser = LRParser.deserialize({
|
||||||
version: 14,
|
version: 14,
|
||||||
states: ".dQVQaOOO#OQbO'#CdO#cQPO'#CeO#qQPO'#DkO$qQaO'#CcO$xOSO'#CsOOQ`'#Do'#DoO%WQPO'#DnO%oQaO'#DyOOQ`'#C{'#C{OOQO'#Dl'#DlO%wQPO'#DkO&VQaO'#EOOOQO'#DV'#DVOOQO'#Dk'#DkO&^QPO'#DjOOQ`'#Dj'#DjOOQ`'#D`'#D`QVQaOOOOQ`'#Dn'#DnOOQ`'#Cb'#CbO&fQaO'#DROOQ`'#Dm'#DmOOQ`'#Da'#DaO&sQbO,58{O'dQaO,59pO'iQaO,59yO&VQaO,59PO&VQaO,59PO'vQbO'#CdO)RQPO'#CeO)cQPO,58}O)tQPO,58}O)oQPO,58}O*oQPO,58}O*wQaO'#CuO+PQWO'#CvOOOO'#Ds'#DsOOOO'#Db'#DbO+eOSO,59_OOQ`,59_,59_OOQ`'#Dc'#DcO+sQaO'#C}O+{QPO,5:eO,QQaO'#DeO,VQPO,58zO,hQPO,5:jO,oQPO,5:jOOQ`,5:U,5:UOOQ`-E7^-E7^OOQ`,59m,59mOOQ`-E7_-E7_OOQO1G/[1G/[OOQO1G/e1G/eOOQO1G.k1G.kO,tQPO1G.kO&VQaO,59UO&VQaO,59UOOQ`1G.i1G.iOOOO,59a,59aOOOO,59b,59bOOOO-E7`-E7`OOQ`1G.y1G.yOOQ`-E7a-E7aO-`QaO1G0PO-pQbO'#CdOOQO,5:P,5:POOQO-E7c-E7cO.aQaO1G0UOOQO1G.p1G.pO.qQPO1G.pO.{QPO7+%kO/QQaO7+%lOOQO'#DX'#DXOOQO7+%p7+%pO/bQaO7+%qOOQ`<<IV<<IVO/xQPO'#DdO/}QaO'#D|O0e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!c!wRpSTvTwoXOPbehjm!b!c!f!j!m!p#V#WQ!q!jV!r!m#V#We]Obj!b!f!j!m!p#V#W",
|
goto: "+u!tPPPP!u#U#d#j#U$VPPPP$lPPPPPPPP$xP%b%bPPPP%f&QP&gPPP#dPP&jP&v&y'SP'WP&j'^'d'l'r'x(R(YPPP(`(d(x)[)b*^PPP*zPPPPPP+O+OP+a+i+id^Obk!d!h!l!o!r#X#YRrSiYOSbk}!d!h!l!o!r#X#YXhPjn!e|UOPS[bgjklmn![!]!d!e!h!l!o!r!y#X#YR!_tdRObk!d!h!l!o!r#X#YQpSQ!YlR!ZmQrSQ!R[Q!i!]R#Q!y}UOPS[bgjklmn![!]!d!e!h!l!o!r!y#X#YTvTxdVObk!d!h!l!o!r#X#YiePS[gjlmn![!]!e!yd^Obk!d!h!l!o!r#X#YWfPjn!eR!VgR|We^Obk!d!h!l!o!r#X#YR!n!hQ!u!oQ#Z#XR#[#YT!z!u!{Q#O!uR#T!{QbOR!TbUjPn!eR!WjQxTR!axQ{WR!c{W!r!l!o#X#YR!w!rS!OZsR!g!OQ!{!uR#R!{TaObS_ObQ!XkQ!k!dQ!m!hZ!q!l!o!r#X#YdZObk!d!h!l!o!r#X#YQsSR!f}XiPjn!edQObk!d!h!l!o!r#X#YWfPjn!eQoSQ!P[Q!VgQ!YlQ!ZmQ!i![Q!j!]R#P!ydVObk!d!h!l!o!r#X#YfeP[gjlmn![!]!e!yRqSTwTxoXOPbgjkn!d!e!h!l!o!r#X#YQ!s!lV!t!o#X#Ye]Obk!d!h!l!o!r#X#Y",
|
||||||
nodeNames: "⚠ Identifier Word Program PipeExpr FunctionCall PositionalArg ParenExpr FunctionCallOrIdentifier BinOp operator operator operator operator ConditionalOp operator operator operator operator operator operator operator operator String StringFragment Interpolation EscapeSeq Number Boolean Regex Null FunctionDef keyword Params colon end Underscore NamedArg NamedArgPrefix operator DotGet IfExpr keyword ThenBlock ThenBlock ElsifExpr keyword ElseExpr keyword Assign",
|
nodeNames: "⚠ Identifier Word Program PipeExpr FunctionCall PositionalArg ParenExpr FunctionCallOrIdentifier BinOp operator operator operator operator ConditionalOp operator operator operator operator operator operator operator operator String StringFragment Interpolation EscapeSeq Number Boolean Regex Null DotGet FunctionDef keyword Params colon end Underscore NamedArg NamedArgPrefix operator IfExpr keyword ThenBlock ThenBlock ElsifExpr keyword ElseExpr keyword Assign",
|
||||||
maxTerm: 82,
|
maxTerm: 82,
|
||||||
context: trackScope,
|
context: trackScope,
|
||||||
nodeProps: [
|
nodeProps: [
|
||||||
["closedBy", 34,"end"],
|
["closedBy", 35,"end"],
|
||||||
["openedBy", 35,"colon"]
|
["openedBy", 36,"colon"]
|
||||||
],
|
],
|
||||||
propSources: [highlighting],
|
propSources: [highlighting],
|
||||||
skippedNodes: [0],
|
skippedNodes: [0],
|
||||||
repeatNodeCount: 7,
|
repeatNodeCount: 7,
|
||||||
tokenData: "!&X~R!SOX$_XY$|YZ%gZp$_pq$|qr&Qrt$_tu'Yuw$_wx'_xy'dyz'}z{(h{|)R|}$_}!O)l!O!P,b!P!Q,{!Q![*]![!]5j!]!^%g!^!_6T!_!`7_!`!a7x!a#O$_#O#P9S#P#R$_#R#S9X#S#T$_#T#U9r#U#X;W#X#Y=m#Y#ZDs#Z#];W#]#^JO#^#b;W#b#cKp#c#d! Y#d#f;W#f#g!!z#g#h;W#h#i!#q#i#o;W#o#p$_#p#q!%i#q;'S$_;'S;=`$v<%l~$_~O$_~~!&SS$dUhSOt$_uw$_x#O$_#P;'S$_;'S;=`$v<%lO$_S$yP;=`<%l$__%TUhS!]ZOt$_uw$_x#O$_#P;'S$_;'S;=`$v<%lO$_V%nUhS!oROt$_uw$_x#O$_#P;'S$_;'S;=`$v<%lO$_V&VWhSOt$_uw$_x!_$_!_!`&o!`#O$_#P;'S$_;'S;=`$v<%lO$_V&vU`RhSOt$_uw$_x#O$_#P;'S$_;'S;=`$v<%lO$_~'_O!h~~'dO!f~V'kUhS!dROt$_uw$_x#O$_#P;'S$_;'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#o;'S$_;'S;=`$v<%lO$_VKQYzPhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#o;W#o;'S$_;'S;=`$v<%lO$__Kw[!jWhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#i;W#i#jLm#j#o;W#o;'S$_;'S;=`$v<%lO$_VLr[hSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#`;W#`#aMh#a#o;W#o;'S$_;'S;=`$v<%lO$_VMm[hSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#`;W#`#aNc#a#o;W#o;'S$_;'S;=`$v<%lO$_VNjYnRhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#o;W#o;'S$_;'S;=`$v<%lO$_V! _[hSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#f;W#f#g!!T#g#o;W#o;'S$_;'S;=`$v<%lO$_V!![YfRhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#o;W#o;'S$_;'S;=`$v<%lO$_^!#RY!lWhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#o;W#o;'S$_;'S;=`$v<%lO$__!#x[!kWhSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#f;W#f#g!$n#g#o;W#o;'S$_;'S;=`$v<%lO$_V!$s[hSOt$_uw$_x!_$_!_!`:m!`#O$_#P#T$_#T#i;W#i#jGg#j#o;W#o;'S$_;'S;=`$v<%lO$_V!%pUxRhSOt$_uw$_x#O$_#P;'S$_;'S;=`$v<%lO$_~!&XO!t~",
|
||||||
tokenizers: [0, 1, 2, 3, tokenizer],
|
tokenizers: [0, 1, 2, 3, tokenizer],
|
||||||
topRules: {"Program":[0,3]},
|
topRules: {"Program":[0,3]},
|
||||||
tokenPrec: 775
|
tokenPrec: 858
|
||||||
})
|
})
|
||||||
|
|
|
||||||
130
src/parser/tests/dot-get.test.ts
Normal file
130
src/parser/tests/dot-get.test.ts
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
import { describe, test, expect } from 'bun:test'
|
||||||
|
import '../../testSetup'
|
||||||
|
|
||||||
|
describe('DotGet', () => {
|
||||||
|
test('readme.txt is Word when readme not in scope', () => {
|
||||||
|
expect('readme.txt').toMatchTree(`Word readme.txt`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('obj.prop is DotGet when obj is assigned', () => {
|
||||||
|
expect('obj = 5; obj.prop').toMatchTree(`
|
||||||
|
Assign
|
||||||
|
Identifier obj
|
||||||
|
operator =
|
||||||
|
Number 5
|
||||||
|
DotGet
|
||||||
|
Identifier obj
|
||||||
|
Identifier prop
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('function parameters are in scope within function body', () => {
|
||||||
|
expect('fn config: config.path end').toMatchTree(`
|
||||||
|
FunctionDef
|
||||||
|
keyword fn
|
||||||
|
Params
|
||||||
|
Identifier config
|
||||||
|
colon :
|
||||||
|
DotGet
|
||||||
|
Identifier config
|
||||||
|
Identifier path
|
||||||
|
end end
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('parameters out of scope outside function', () => {
|
||||||
|
expect('fn x: x.prop end; x.prop').toMatchTree(`
|
||||||
|
FunctionDef
|
||||||
|
keyword fn
|
||||||
|
Params
|
||||||
|
Identifier x
|
||||||
|
colon :
|
||||||
|
DotGet
|
||||||
|
Identifier x
|
||||||
|
Identifier prop
|
||||||
|
end end
|
||||||
|
Word x.prop
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('multiple parameters work correctly', () => {
|
||||||
|
expect(`fn x y:
|
||||||
|
x.foo
|
||||||
|
y.bar
|
||||||
|
end`).toMatchTree(`
|
||||||
|
FunctionDef
|
||||||
|
keyword fn
|
||||||
|
Params
|
||||||
|
Identifier x
|
||||||
|
Identifier y
|
||||||
|
colon :
|
||||||
|
DotGet
|
||||||
|
Identifier x
|
||||||
|
Identifier foo
|
||||||
|
DotGet
|
||||||
|
Identifier y
|
||||||
|
Identifier bar
|
||||||
|
end end
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('nested functions with scope isolation', () => {
|
||||||
|
expect(`fn x:
|
||||||
|
x.outer
|
||||||
|
fn y: y.inner end
|
||||||
|
end`).toMatchTree(`
|
||||||
|
FunctionDef
|
||||||
|
keyword fn
|
||||||
|
Params
|
||||||
|
Identifier x
|
||||||
|
colon :
|
||||||
|
DotGet
|
||||||
|
Identifier x
|
||||||
|
Identifier outer
|
||||||
|
FunctionDef
|
||||||
|
keyword fn
|
||||||
|
Params
|
||||||
|
Identifier y
|
||||||
|
colon :
|
||||||
|
DotGet
|
||||||
|
Identifier y
|
||||||
|
Identifier inner
|
||||||
|
end end
|
||||||
|
end end
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('dot get works as function argument', () => {
|
||||||
|
expect('config = 42; echo config.path').toMatchTree(`
|
||||||
|
Assign
|
||||||
|
Identifier config
|
||||||
|
operator =
|
||||||
|
Number 42
|
||||||
|
FunctionCall
|
||||||
|
Identifier echo
|
||||||
|
PositionalArg
|
||||||
|
DotGet
|
||||||
|
Identifier config
|
||||||
|
Identifier path
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('mixed file paths and dot get', () => {
|
||||||
|
expect('config = 42; cat readme.txt; echo config.path').toMatchTree(`
|
||||||
|
Assign
|
||||||
|
Identifier config
|
||||||
|
operator =
|
||||||
|
Number 42
|
||||||
|
FunctionCall
|
||||||
|
Identifier cat
|
||||||
|
PositionalArg
|
||||||
|
Word readme.txt
|
||||||
|
FunctionCall
|
||||||
|
Identifier echo
|
||||||
|
PositionalArg
|
||||||
|
DotGet
|
||||||
|
Identifier config
|
||||||
|
Identifier path
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -17,7 +17,7 @@ export const tokenizer = new ExternalTokenizer((input: InputStream, stack: Stack
|
||||||
|
|
||||||
// Check for dot and scope - property access detection
|
// Check for dot and scope - property access detection
|
||||||
if (ch === 46 /* . */ && isValidIdentifier) {
|
if (ch === 46 /* . */ && isValidIdentifier) {
|
||||||
const identifierText = input.read(0, pos)
|
const identifierText = input.read(input.pos, input.pos + pos)
|
||||||
const scope = stack.context as Scope | undefined
|
const scope = stack.context as Scope | undefined
|
||||||
|
|
||||||
if (scope?.has(identifierText)) {
|
if (scope?.has(identifierText)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user