Compare commits
13 Commits
4eafa00648
...
c741cfee51
| Author | SHA1 | Date | |
|---|---|---|---|
| c741cfee51 | |||
| 012b8c8cf1 | |||
| 4c3f7a8bfc | |||
| fe6f54b402 | |||
| 49f3f3e09f | |||
| 0d1dce4868 | |||
| d18ab2507c | |||
| 7e69356f79 | |||
| 9863f46f38 | |||
| 45f31d0678 | |||
| 49a6320fef | |||
| 51f67ac908 | |||
| d4a772e88b |
2
bun.lock
2
bun.lock
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
"hono": ["hono@4.10.4", "", {}, "sha512-YG/fo7zlU3KwrBL5vDpWKisLYiM+nVstBQqfr7gCPbSYURnNEP9BDxEMz8KfsDR9JX0lJWDRNc6nXX31v7ZEyg=="],
|
"hono": ["hono@4.10.4", "", {}, "sha512-YG/fo7zlU3KwrBL5vDpWKisLYiM+nVstBQqfr7gCPbSYURnNEP9BDxEMz8KfsDR9JX0lJWDRNc6nXX31v7ZEyg=="],
|
||||||
|
|
||||||
"reefvm": ["reefvm@git+https://git.nose.space/defunkt/reefvm#d7a971db24aea5ddcaae2c18ce9f10dab793db19", { "peerDependencies": { "typescript": "^5" } }, "d7a971db24aea5ddcaae2c18ce9f10dab793db19"],
|
"reefvm": ["reefvm@git+https://git.nose.space/defunkt/reefvm#3e2e68b31f504347225a4d705c7568a0957d629e", { "peerDependencies": { "typescript": "^5" } }, "3e2e68b31f504347225a4d705c7568a0957d629e"],
|
||||||
|
|
||||||
"style-mod": ["style-mod@4.1.3", "", {}, "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ=="],
|
"style-mod": ["style-mod@4.1.3", "", {}, "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ=="],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"repl": "bun generate-parser && bun bin/repl",
|
"repl": "bun generate-parser && bun bin/repl",
|
||||||
"update-reef": "rm -rf ~/.bun/install/cache/ && rm bun.lock && bun update reefvm",
|
"update-reef": "rm -rf ~/.bun/install/cache/ && rm bun.lock && bun update reefvm",
|
||||||
"cli:install": "ln -s \"$(pwd)/bin/shrimp\" ~/.bun/bin/shrimp",
|
"cli:install": "ln -s \"$(pwd)/bin/shrimp\" ~/.bun/bin/shrimp",
|
||||||
"cli:remove": "rm ~/.bun/bin/shrimp",
|
"cli:remove": "rm ~/.bun/bin/shrimp"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/view": "^6.38.3",
|
"@codemirror/view": "^6.38.3",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ function processEscapeSeq(escapeSeq: string): string {
|
||||||
|
|
||||||
export class Compiler {
|
export class Compiler {
|
||||||
instructions: ProgramItem[] = []
|
instructions: ProgramItem[] = []
|
||||||
|
labelCount = 0
|
||||||
fnLabelCount = 0
|
fnLabelCount = 0
|
||||||
ifLabelCount = 0
|
ifLabelCount = 0
|
||||||
tryLabelCount = 0
|
tryLabelCount = 0
|
||||||
|
|
@ -105,11 +106,21 @@ export class Compiler {
|
||||||
|
|
||||||
switch (node.type.id) {
|
switch (node.type.id) {
|
||||||
case terms.Number:
|
case terms.Number:
|
||||||
const number = Number(value)
|
// Handle sign prefix for hex and binary literals
|
||||||
if (Number.isNaN(number))
|
// Number() doesn't parse '-0xFF' or '+0xFF' correctly
|
||||||
|
let numberValue: number
|
||||||
|
if (value.startsWith('-') && (value.includes('0x') || value.includes('0b'))) {
|
||||||
|
numberValue = -Number(value.slice(1))
|
||||||
|
} else if (value.startsWith('+') && (value.includes('0x') || value.includes('0b'))) {
|
||||||
|
numberValue = Number(value.slice(1))
|
||||||
|
} else {
|
||||||
|
numberValue = Number(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number.isNaN(numberValue))
|
||||||
throw new CompilerError(`Invalid number literal: ${value}`, node.from, node.to)
|
throw new CompilerError(`Invalid number literal: ${value}`, node.from, node.to)
|
||||||
|
|
||||||
return [[`PUSH`, number]]
|
return [[`PUSH`, numberValue]]
|
||||||
|
|
||||||
case terms.String: {
|
case terms.String: {
|
||||||
const { parts, hasInterpolation } = getStringParts(node, input)
|
const { parts, hasInterpolation } = getStringParts(node, input)
|
||||||
|
|
@ -367,7 +378,29 @@ export class Compiler {
|
||||||
|
|
||||||
case terms.FunctionCallOrIdentifier: {
|
case terms.FunctionCallOrIdentifier: {
|
||||||
if (node.firstChild?.type.id === terms.DotGet) {
|
if (node.firstChild?.type.id === terms.DotGet) {
|
||||||
return this.#compileNode(node.firstChild, input)
|
const instructions: ProgramItem[] = []
|
||||||
|
const callLabel = `.call_dotget_${++this.labelCount}`
|
||||||
|
const afterLabel = `.after_dotget_${++this.labelCount}`
|
||||||
|
|
||||||
|
instructions.push(...this.#compileNode(node.firstChild, input))
|
||||||
|
instructions.push(['DUP'])
|
||||||
|
instructions.push(['TYPE'])
|
||||||
|
instructions.push(['PUSH', 'function'])
|
||||||
|
instructions.push(['EQ'])
|
||||||
|
instructions.push(['JUMP_IF_TRUE', callLabel])
|
||||||
|
instructions.push(['DUP'])
|
||||||
|
instructions.push(['TYPE'])
|
||||||
|
instructions.push(['PUSH', 'native'])
|
||||||
|
instructions.push(['EQ'])
|
||||||
|
instructions.push(['JUMP_IF_TRUE', callLabel])
|
||||||
|
instructions.push(['JUMP', afterLabel])
|
||||||
|
instructions.push([`${callLabel}:`])
|
||||||
|
instructions.push(['PUSH', 0])
|
||||||
|
instructions.push(['PUSH', 0])
|
||||||
|
instructions.push(['CALL'])
|
||||||
|
instructions.push([`${afterLabel}:`])
|
||||||
|
|
||||||
|
return instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
return [['TRY_CALL', value]]
|
return [['TRY_CALL', value]]
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,10 @@ describe('compiler', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('function call with no args', () => {
|
test('function call with no args', () => {
|
||||||
expect(`bloop = do: 'bloop' end; bloop`).toEvaluateTo('bloop')
|
expect(`bloop = do: 'bleep' end; bloop`).toEvaluateTo('bleep')
|
||||||
|
expect(`bloop = [ go=do: 'bleep' end ]; bloop.go`).toEvaluateTo('bleep')
|
||||||
|
expect(`bloop = [ go=do: 'bleep' end ]; abc = do x: x end; abc (bloop.go)`).toEvaluateTo('bleep')
|
||||||
|
expect(`num = ((math.random) * 10 + 1) | math.floor; num >= 1 and num <= 10 `).toEvaluateTo(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('function call with if statement and multiple expressions', () => {
|
test('function call with if statement and multiple expressions', () => {
|
||||||
|
|
@ -298,6 +301,23 @@ describe('default params', () => {
|
||||||
expect('multiply = do x y=5: x * y end; multiply 5 2').toEvaluateTo(10)
|
expect('multiply = do x y=5: x * y end; multiply 5 2').toEvaluateTo(10)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('null triggers default value', () => {
|
||||||
|
expect('test = do n=true: n end; test').toEvaluateTo(true)
|
||||||
|
expect('test = do n=true: n end; test false').toEvaluateTo(false)
|
||||||
|
expect('test = do n=true: n end; test null').toEvaluateTo(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('null triggers default for named parameters', () => {
|
||||||
|
expect("greet = do name='World': name end; greet name=null").toEvaluateTo('World')
|
||||||
|
expect("greet = do name='World': name end; greet name='Bob'").toEvaluateTo('Bob')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('null triggers default with multiple parameters', () => {
|
||||||
|
expect('calc = do x=10 y=20: x + y end; calc null 5').toEvaluateTo(15)
|
||||||
|
expect('calc = do x=10 y=20: x + y end; calc 3 null').toEvaluateTo(23)
|
||||||
|
expect('calc = do x=10 y=20: x + y end; calc null null').toEvaluateTo(30)
|
||||||
|
})
|
||||||
|
|
||||||
test.skip('array default', () => {
|
test.skip('array default', () => {
|
||||||
expect('abc = do alpha=[a b c]: alpha end; abc').toEvaluateTo(['a', 'b', 'c'])
|
expect('abc = do alpha=[a b c]: alpha end; abc').toEvaluateTo(['a', 'b', 'c'])
|
||||||
expect('abc = do alpha=[a b c]: alpha end; abc [x y z]').toEvaluateTo(['x', 'y', 'z'])
|
expect('abc = do alpha=[a b c]: alpha end; abc [x y z]').toEvaluateTo(['x', 'y', 'z'])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,44 @@
|
||||||
import { describe } from 'bun:test'
|
import { describe } from 'bun:test'
|
||||||
import { expect, test } from 'bun:test'
|
import { expect, test } from 'bun:test'
|
||||||
|
|
||||||
|
describe('number literals', () => {
|
||||||
|
test('binary literals', () => {
|
||||||
|
expect('0b110').toEvaluateTo(6)
|
||||||
|
expect('0b1010').toEvaluateTo(10)
|
||||||
|
expect('0b11111111').toEvaluateTo(255)
|
||||||
|
expect('0b0').toEvaluateTo(0)
|
||||||
|
expect('0b1').toEvaluateTo(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('hex literals', () => {
|
||||||
|
expect('0xdeadbeef').toEvaluateTo(0xdeadbeef)
|
||||||
|
expect('0xdeadbeef').toEvaluateTo(3735928559)
|
||||||
|
expect('0xFF').toEvaluateTo(255)
|
||||||
|
expect('0xff').toEvaluateTo(255)
|
||||||
|
expect('0x10').toEvaluateTo(16)
|
||||||
|
expect('0x0').toEvaluateTo(0)
|
||||||
|
expect('0xABCDEF').toEvaluateTo(0xabcdef)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('decimal literals still work', () => {
|
||||||
|
expect('42').toEvaluateTo(42)
|
||||||
|
expect('3.14').toEvaluateTo(3.14)
|
||||||
|
expect('0').toEvaluateTo(0)
|
||||||
|
expect('999999').toEvaluateTo(999999)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('negative hex and binary', () => {
|
||||||
|
expect('-0xFF').toEvaluateTo(-255)
|
||||||
|
expect('-0b1010').toEvaluateTo(-10)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('positive prefix', () => {
|
||||||
|
expect('+0xFF').toEvaluateTo(255)
|
||||||
|
expect('+0b110').toEvaluateTo(6)
|
||||||
|
expect('+42').toEvaluateTo(42)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('array literals', () => {
|
describe('array literals', () => {
|
||||||
test('work with numbers', () => {
|
test('work with numbers', () => {
|
||||||
expect('[1 2 3]').toEvaluateTo([1, 2, 3])
|
expect('[1 2 3]').toEvaluateTo([1, 2, 3])
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,12 @@
|
||||||
@precedence { Number Regex }
|
@precedence { Number Regex }
|
||||||
|
|
||||||
StringFragment { !['\\$]+ }
|
StringFragment { !['\\$]+ }
|
||||||
NamedArgPrefix { $[a-z-]+ "=" }
|
NamedArgPrefix { $[a-z] $[a-z0-9-]* "=" }
|
||||||
Number { ("-" | "+")? $[0-9]+ ('.' $[0-9]+)? }
|
Number {
|
||||||
|
("-" | "+")? "0x" $[0-9a-fA-F]+ |
|
||||||
|
("-" | "+")? "0b" $[01]+ |
|
||||||
|
("-" | "+")? $[0-9]+ ("_"? $[0-9]+)* ('.' $[0-9]+ ("_"? $[0-9]+)*)?
|
||||||
|
}
|
||||||
Boolean { "true" | "false" }
|
Boolean { "true" | "false" }
|
||||||
newlineOrSemicolon { "\n" | ";" }
|
newlineOrSemicolon { "\n" | ";" }
|
||||||
eof { @eof }
|
eof { @eof }
|
||||||
|
|
@ -47,7 +51,8 @@ null { @specialize[@name=Null]<Identifier, "null"> }
|
||||||
comparison @left,
|
comparison @left,
|
||||||
multiplicative @left,
|
multiplicative @left,
|
||||||
additive @left,
|
additive @left,
|
||||||
call
|
call,
|
||||||
|
functionWithNewlines
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
|
|
@ -188,7 +193,21 @@ BinOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParenExpr {
|
ParenExpr {
|
||||||
leftParen (IfExpr | ambiguousFunctionCall | BinOp | expressionWithoutIdentifier | ConditionalOp | PipeExpr | FunctionDef) rightParen
|
leftParen newlineOrSemicolon* (
|
||||||
|
FunctionCallWithNewlines |
|
||||||
|
IfExpr |
|
||||||
|
ambiguousFunctionCall |
|
||||||
|
BinOp newlineOrSemicolon* |
|
||||||
|
expressionWithoutIdentifier |
|
||||||
|
ConditionalOp newlineOrSemicolon* |
|
||||||
|
PipeExpr |
|
||||||
|
FunctionDef
|
||||||
|
)
|
||||||
|
rightParen
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionCallWithNewlines[@name=FunctionCall] {
|
||||||
|
(DotGet | Identifier | ParenExpr) newlineOrSemicolon+ arg !functionWithNewlines (newlineOrSemicolon+ arg)* newlineOrSemicolon*
|
||||||
}
|
}
|
||||||
|
|
||||||
expression {
|
expression {
|
||||||
|
|
|
||||||
|
|
@ -28,39 +28,40 @@ export const
|
||||||
Program = 26,
|
Program = 26,
|
||||||
PipeExpr = 27,
|
PipeExpr = 27,
|
||||||
WhileExpr = 29,
|
WhileExpr = 29,
|
||||||
keyword = 70,
|
keyword = 71,
|
||||||
ConditionalOp = 31,
|
ConditionalOp = 31,
|
||||||
ParenExpr = 32,
|
ParenExpr = 32,
|
||||||
IfExpr = 33,
|
FunctionCallWithNewlines = 33,
|
||||||
FunctionCall = 35,
|
DotGet = 34,
|
||||||
DotGet = 36,
|
Number = 35,
|
||||||
Number = 37,
|
PositionalArg = 36,
|
||||||
PositionalArg = 38,
|
FunctionDef = 37,
|
||||||
FunctionDef = 39,
|
Params = 38,
|
||||||
Params = 40,
|
NamedParam = 39,
|
||||||
NamedParam = 41,
|
NamedArgPrefix = 40,
|
||||||
NamedArgPrefix = 42,
|
String = 41,
|
||||||
String = 43,
|
StringFragment = 42,
|
||||||
StringFragment = 44,
|
Interpolation = 43,
|
||||||
Interpolation = 45,
|
EscapeSeq = 44,
|
||||||
EscapeSeq = 46,
|
Boolean = 45,
|
||||||
Boolean = 47,
|
Null = 46,
|
||||||
Null = 48,
|
colon = 47,
|
||||||
colon = 49,
|
CatchExpr = 48,
|
||||||
CatchExpr = 50,
|
Block = 50,
|
||||||
Block = 52,
|
FinallyExpr = 51,
|
||||||
FinallyExpr = 53,
|
Underscore = 54,
|
||||||
Underscore = 56,
|
NamedArg = 55,
|
||||||
NamedArg = 57,
|
IfExpr = 56,
|
||||||
ElseIfExpr = 58,
|
FunctionCall = 58,
|
||||||
ElseExpr = 60,
|
ElseIfExpr = 59,
|
||||||
FunctionCallOrIdentifier = 61,
|
ElseExpr = 61,
|
||||||
BinOp = 62,
|
FunctionCallOrIdentifier = 62,
|
||||||
Regex = 63,
|
BinOp = 63,
|
||||||
Dict = 64,
|
Regex = 64,
|
||||||
Array = 65,
|
Dict = 65,
|
||||||
FunctionCallWithBlock = 66,
|
Array = 66,
|
||||||
TryExpr = 67,
|
FunctionCallWithBlock = 67,
|
||||||
Throw = 69,
|
TryExpr = 68,
|
||||||
CompoundAssign = 71,
|
Throw = 70,
|
||||||
Assign = 72
|
CompoundAssign = 72,
|
||||||
|
Assign = 73
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,24 @@ import {operatorTokenizer} from "./operatorTokenizer"
|
||||||
import {tokenizer, specializeKeyword} from "./tokenizer"
|
import {tokenizer, specializeKeyword} from "./tokenizer"
|
||||||
import {trackScope} from "./parserScopeContext"
|
import {trackScope} from "./parserScopeContext"
|
||||||
import {highlighting} from "./highlight"
|
import {highlighting} from "./highlight"
|
||||||
const spec_Identifier = {__proto__:null,while:60, if:68, null:96, catch:102, finally:108, end:110, else:118, try:136, throw:140}
|
const spec_Identifier = {__proto__:null,while:60, null:92, catch:98, finally:104, end:106, if:114, else:120, try:138, throw:142}
|
||||||
export const parser = LRParser.deserialize({
|
export const parser = LRParser.deserialize({
|
||||||
version: 14,
|
version: 14,
|
||||||
states: "9UQYQbOOO!dOpO'#DQO!iOSO'#DXO$_QcO'#DkO&rQcO'#EYOOQ`'#Eh'#EhO'uQRO'#DlO)[QcO'#EWO)lQbO'#C|OOQa'#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!VWR#[!P",
|
||||||
nodeNames: "⚠ Star Slash Plus Minus And Or Eq EqEq Neq Lt Lte Gt Gte Modulo PlusEq MinusEq StarEq SlashEq ModuloEq Identifier AssignableIdentifier Word IdentifierBeforeDot Do Comment Program PipeExpr operator WhileExpr keyword ConditionalOp ParenExpr IfExpr keyword FunctionCall DotGet Number PositionalArg FunctionDef Params NamedParam NamedArgPrefix String StringFragment Interpolation EscapeSeq Boolean Null colon CatchExpr keyword Block FinallyExpr keyword keyword Underscore NamedArg ElseIfExpr keyword ElseExpr FunctionCallOrIdentifier BinOp Regex Dict Array FunctionCallWithBlock TryExpr keyword Throw keyword CompoundAssign Assign",
|
nodeNames: "⚠ Star Slash Plus Minus And Or Eq EqEq Neq Lt Lte Gt Gte Modulo PlusEq MinusEq StarEq SlashEq ModuloEq Identifier AssignableIdentifier Word IdentifierBeforeDot Do Comment Program PipeExpr operator WhileExpr keyword ConditionalOp ParenExpr FunctionCall DotGet Number PositionalArg FunctionDef Params NamedParam NamedArgPrefix String StringFragment Interpolation EscapeSeq Boolean Null colon CatchExpr keyword Block FinallyExpr keyword keyword Underscore NamedArg IfExpr keyword FunctionCall ElseIfExpr keyword ElseExpr FunctionCallOrIdentifier BinOp Regex Dict Array FunctionCallWithBlock TryExpr keyword Throw keyword CompoundAssign Assign",
|
||||||
maxTerm: 109,
|
maxTerm: 111,
|
||||||
context: trackScope,
|
context: trackScope,
|
||||||
nodeProps: [
|
nodeProps: [
|
||||||
["closedBy", 49,"end"]
|
["closedBy", 47,"end"]
|
||||||
],
|
],
|
||||||
propSources: [highlighting],
|
propSources: [highlighting],
|
||||||
skippedNodes: [0,25],
|
skippedNodes: [0,25],
|
||||||
repeatNodeCount: 11,
|
repeatNodeCount: 12,
|
||||||
tokenData: "C_~R|OX#{XY$jYZ%TZp#{pq$jqs#{st%ntu'Vuw#{wx'[xy'ayz'zz{#{{|(e|}#{}!O+X!O!P#{!P!Q-n!Q![)S![!]6Z!]!^%T!^!}#{!}#O6t#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T#i<t#i#jAr#j#o<t#o;'S$O;'S;=`$g<%lO$OUHkUlQzSOt$Ouw$Ox#O$O#P;'S$O;'S;=`$g<%lO$O~ISO#c~",
|
||||||
tokenizers: [operatorTokenizer, 1, 2, 3, tokenizer, new LocalTokenGroup("[~RP!O!PU~ZO#P~~", 11)],
|
tokenizers: [operatorTokenizer, 1, 2, 3, tokenizer, new LocalTokenGroup("[~RP!O!PU~ZO#R~~", 11)],
|
||||||
topRules: {"Program":[0,26]},
|
topRules: {"Program":[0,26]},
|
||||||
specialized: [{term: 20, get: (value: any, stack: any) => (specializeKeyword(value, stack) << 1), external: specializeKeyword},{term: 20, get: (value: keyof typeof spec_Identifier) => spec_Identifier[value] || -1}],
|
specialized: [{term: 20, get: (value: any, stack: any) => (specializeKeyword(value, stack) << 1), external: specializeKeyword},{term: 20, get: (value: keyof typeof spec_Identifier) => spec_Identifier[value] || -1}],
|
||||||
tokenPrec: 1634
|
tokenPrec: 1922
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,118 @@ describe('Parentheses', () => {
|
||||||
PositionalArg
|
PositionalArg
|
||||||
Number 3`)
|
Number 3`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('function call with named args on multiple lines in parens', () => {
|
||||||
|
expect(`(tail
|
||||||
|
arg1=true
|
||||||
|
arg2=30
|
||||||
|
)`).toMatchTree(`
|
||||||
|
ParenExpr
|
||||||
|
FunctionCall
|
||||||
|
Identifier tail
|
||||||
|
NamedArg
|
||||||
|
NamedArgPrefix arg1=
|
||||||
|
Boolean true
|
||||||
|
NamedArg
|
||||||
|
NamedArgPrefix arg2=
|
||||||
|
Number 30
|
||||||
|
`)
|
||||||
|
|
||||||
|
expect(`(
|
||||||
|
tail
|
||||||
|
arg1=true
|
||||||
|
arg2=30
|
||||||
|
)`).toMatchTree(`
|
||||||
|
ParenExpr
|
||||||
|
FunctionCall
|
||||||
|
Identifier tail
|
||||||
|
NamedArg
|
||||||
|
NamedArgPrefix arg1=
|
||||||
|
Boolean true
|
||||||
|
NamedArg
|
||||||
|
NamedArgPrefix arg2=
|
||||||
|
Number 30
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('binop with newlines in parens', () => {
|
||||||
|
expect(`(
|
||||||
|
1 + 2
|
||||||
|
)`).toMatchTree(`
|
||||||
|
ParenExpr
|
||||||
|
BinOp
|
||||||
|
Number 1
|
||||||
|
Plus +
|
||||||
|
Number 2`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('comparison with newlines in parens', () => {
|
||||||
|
expect(`(
|
||||||
|
1 < 2
|
||||||
|
)`).toMatchTree(`
|
||||||
|
ParenExpr
|
||||||
|
ConditionalOp
|
||||||
|
Number 1
|
||||||
|
Lt <
|
||||||
|
Number 2`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('function call with multiple identifiers on separate lines in parens', () => {
|
||||||
|
expect(`(echo
|
||||||
|
arg1
|
||||||
|
arg2
|
||||||
|
arg3
|
||||||
|
)`).toMatchTree(`
|
||||||
|
ParenExpr
|
||||||
|
FunctionCall
|
||||||
|
Identifier echo
|
||||||
|
PositionalArg
|
||||||
|
Identifier arg1
|
||||||
|
PositionalArg
|
||||||
|
Identifier arg2
|
||||||
|
PositionalArg
|
||||||
|
Identifier arg3`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Number literals', () => {
|
||||||
|
test('allows underscores in integer literals', () => {
|
||||||
|
expect('10_000').toMatchTree(`Number 10_000`)
|
||||||
|
expect('1_000_000').toMatchTree(`Number 1_000_000`)
|
||||||
|
expect('100_000').toMatchTree(`Number 100_000`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('allows underscores in decimal literals', () => {
|
||||||
|
expect('3.14_159').toMatchTree(`Number 3.14_159`)
|
||||||
|
expect('1_000.50').toMatchTree(`Number 1_000.50`)
|
||||||
|
expect('0.000_001').toMatchTree(`Number 0.000_001`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('allows underscores in negative numbers', () => {
|
||||||
|
expect('-10_000').toMatchTree(`Number -10_000`)
|
||||||
|
expect('-3.14_159').toMatchTree(`Number -3.14_159`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('allows underscores in positive numbers with explicit sign', () => {
|
||||||
|
expect('+10_000').toMatchTree(`Number +10_000`)
|
||||||
|
expect('+3.14_159').toMatchTree(`Number +3.14_159`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('works in expressions', () => {
|
||||||
|
expect('1_000 + 2_000').toMatchTree(`
|
||||||
|
BinOp
|
||||||
|
Number 1_000
|
||||||
|
Plus +
|
||||||
|
Number 2_000`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('works in function calls', () => {
|
||||||
|
expect('echo 10_000').toMatchTree(`
|
||||||
|
FunctionCall
|
||||||
|
Identifier echo
|
||||||
|
PositionalArg
|
||||||
|
Number 10_000`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('BinOp', () => {
|
describe('BinOp', () => {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,65 @@ import { expect, describe, test } from 'bun:test'
|
||||||
|
|
||||||
import '../shrimp.grammar' // Importing this so changes cause it to retest!
|
import '../shrimp.grammar' // Importing this so changes cause it to retest!
|
||||||
|
|
||||||
|
describe('number literals', () => {
|
||||||
|
test('binary numbers', () => {
|
||||||
|
expect('0b110').toMatchTree(`
|
||||||
|
Number 0b110
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('hex numbers', () => {
|
||||||
|
expect('0xdeadbeef').toMatchTree(`
|
||||||
|
Number 0xdeadbeef
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('hex numbers uppercase', () => {
|
||||||
|
expect('0xFF').toMatchTree(`
|
||||||
|
Number 0xFF
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('decimal numbers still work', () => {
|
||||||
|
expect('42').toMatchTree(`
|
||||||
|
Number 42
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('negative binary', () => {
|
||||||
|
expect('-0b110').toMatchTree(`
|
||||||
|
Number -0b110
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('negative hex', () => {
|
||||||
|
expect('-0xFF').toMatchTree(`
|
||||||
|
Number -0xFF
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('positive prefix binary', () => {
|
||||||
|
expect('+0b110').toMatchTree(`
|
||||||
|
Number +0b110
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('positive prefix hex', () => {
|
||||||
|
expect('+0xFF').toMatchTree(`
|
||||||
|
Number +0xFF
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('hex and binary in arrays', () => {
|
||||||
|
expect('[0xFF 0b110 42]').toMatchTree(`
|
||||||
|
Array
|
||||||
|
Number 0xFF
|
||||||
|
Number 0b110
|
||||||
|
Number 42
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('array literals', () => {
|
describe('array literals', () => {
|
||||||
test('work with numbers', () => {
|
test('work with numbers', () => {
|
||||||
expect('[1 2 3]').toMatchTree(`
|
expect('[1 2 3]').toMatchTree(`
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
} from 'reefvm'
|
} from 'reefvm'
|
||||||
|
|
||||||
import { dict } from './dict'
|
import { dict } from './dict'
|
||||||
|
import { json } from './json'
|
||||||
import { load } from './load'
|
import { load } from './load'
|
||||||
import { list } from './list'
|
import { list } from './list'
|
||||||
import { math } from './math'
|
import { math } from './math'
|
||||||
|
|
@ -13,6 +14,7 @@ import { str } from './str'
|
||||||
|
|
||||||
export const globals = {
|
export const globals = {
|
||||||
dict,
|
dict,
|
||||||
|
json,
|
||||||
load,
|
load,
|
||||||
list,
|
list,
|
||||||
math,
|
math,
|
||||||
|
|
@ -40,6 +42,7 @@ export const globals = {
|
||||||
'var?': function (this: VM, v: string) {
|
'var?': function (this: VM, v: string) {
|
||||||
return typeof v !== 'string' || this.scope.has(v)
|
return typeof v !== 'string' || this.scope.has(v)
|
||||||
},
|
},
|
||||||
|
ref: (fn: Function) => fn,
|
||||||
|
|
||||||
// env
|
// env
|
||||||
args: Bun.argv.slice(1),
|
args: Bun.argv.slice(1),
|
||||||
|
|
|
||||||
7
src/prelude/json.ts
Normal file
7
src/prelude/json.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const json = {
|
||||||
|
encode: (s: any) => JSON.stringify(s),
|
||||||
|
decode: (s: string) => JSON.parse(s),
|
||||||
|
}
|
||||||
|
|
||||||
|
; (json as any).parse = json.decode
|
||||||
|
; (json as any).stringify = json.encode
|
||||||
|
|
@ -73,6 +73,13 @@ export const list = {
|
||||||
const realItems = items.map(item => item.value)
|
const realItems = items.map(item => item.value)
|
||||||
return toValue(realList.splice(realStart, realDeleteCount, ...realItems))
|
return toValue(realList.splice(realStart, realDeleteCount, ...realItems))
|
||||||
},
|
},
|
||||||
|
insert: (list: Value, index: Value, item: Value) => {
|
||||||
|
if (list.type !== 'array') return toNull()
|
||||||
|
const realList = list.value as any[]
|
||||||
|
const realIndex = index.value as number
|
||||||
|
realList.splice(realIndex, 0, item)
|
||||||
|
return toValue(realList.length)
|
||||||
|
},
|
||||||
|
|
||||||
// sequence operations
|
// sequence operations
|
||||||
reverse: (list: any[]) => list.slice().reverse(),
|
reverse: (list: any[]) => list.slice().reverse(),
|
||||||
|
|
@ -142,4 +149,5 @@ export const list = {
|
||||||
; (list.push as any).raw = true
|
; (list.push as any).raw = true
|
||||||
; (list.pop as any).raw = true
|
; (list.pop as any).raw = true
|
||||||
; (list.shift as any).raw = true
|
; (list.shift as any).raw = true
|
||||||
; (list.unshift as any).raw = true
|
; (list.unshift as any).raw = true
|
||||||
|
; (list.insert as any).raw = true
|
||||||
|
|
@ -91,3 +91,15 @@ describe('environment', () => {
|
||||||
await expect(`list.first args | str.ends-with? 'shrimp.test.ts'`).toEvaluateTo(true)
|
await expect(`list.first args | str.ends-with? 'shrimp.test.ts'`).toEvaluateTo(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('ref', () => {
|
||||||
|
expect(`rnd = do x: true end; rnd | type`).toEvaluateTo('boolean')
|
||||||
|
expect(`rnd = do x: true end; ref rnd | type`).toEvaluateTo('function')
|
||||||
|
|
||||||
|
expect(`math.random | type`).toEvaluateTo('number')
|
||||||
|
expect(`ref math.random | type`).toEvaluateTo('native')
|
||||||
|
|
||||||
|
expect(`rnd = math.random; rnd | type`).toEvaluateTo('number')
|
||||||
|
expect(`rnd = ref math.random; rnd | type`).toEvaluateTo('number')
|
||||||
|
expect(`rnd = ref math.random; ref rnd | type`).toEvaluateTo('native')
|
||||||
|
})
|
||||||
|
|
|
||||||
84
src/prelude/tests/json.test.ts
Normal file
84
src/prelude/tests/json.test.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
import { expect, describe, test } from 'bun:test'
|
||||||
|
|
||||||
|
describe('json', () => {
|
||||||
|
test('json.decode', () => {
|
||||||
|
expect(`json.decode '[1,2,3]'`).toEvaluateTo([1, 2, 3])
|
||||||
|
expect(`json.decode '"heya"'`).toEvaluateTo('heya')
|
||||||
|
expect(`json.decode '[true, false, null]'`).toEvaluateTo([true, false, null])
|
||||||
|
expect(`json.decode '{"a": true, "b": false, "c": "yeah"}'`).toEvaluateTo({ a: true, b: false, c: "yeah" })
|
||||||
|
})
|
||||||
|
|
||||||
|
test('json.encode', () => {
|
||||||
|
expect(`json.encode [1 2 3]`).toEvaluateTo('[1,2,3]')
|
||||||
|
expect(`json.encode 'heya'`).toEvaluateTo('"heya"')
|
||||||
|
expect(`json.encode [true false null]`).toEvaluateTo('[true,false,null]')
|
||||||
|
expect(`json.encode [a=true b=false c='yeah'] | json.decode`).toEvaluateTo({ a: true, b: false, c: "yeah" })
|
||||||
|
})
|
||||||
|
|
||||||
|
test('edge cases - empty structures', () => {
|
||||||
|
expect(`json.decode '[]'`).toEvaluateTo([])
|
||||||
|
expect(`json.decode '{}'`).toEvaluateTo({})
|
||||||
|
expect(`json.encode []`).toEvaluateTo('[]')
|
||||||
|
expect(`json.encode [=]`).toEvaluateTo('{}')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('edge cases - special characters in strings', () => {
|
||||||
|
expect(`json.decode '"hello\\\\nworld"'`).toEvaluateTo('hello\nworld')
|
||||||
|
expect(`json.decode '"tab\\\\there"'`).toEvaluateTo('tab\there')
|
||||||
|
expect(`json.decode '"forward/slash"'`).toEvaluateTo('forward/slash')
|
||||||
|
expect(`json.decode '"with\\\\\\\\backslash"'`).toEvaluateTo('with\\backslash')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('numbers - integers and floats', () => {
|
||||||
|
expect(`json.decode '42'`).toEvaluateTo(42)
|
||||||
|
expect(`json.decode '0'`).toEvaluateTo(0)
|
||||||
|
expect(`json.decode '-17'`).toEvaluateTo(-17)
|
||||||
|
expect(`json.decode '3.14159'`).toEvaluateTo(3.14159)
|
||||||
|
expect(`json.decode '-0.5'`).toEvaluateTo(-0.5)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('numbers - scientific notation', () => {
|
||||||
|
expect(`json.decode '1e10'`).toEvaluateTo(1e10)
|
||||||
|
expect(`json.decode '2.5e-3'`).toEvaluateTo(2.5e-3)
|
||||||
|
expect(`json.decode '1.23E+5'`).toEvaluateTo(1.23e5)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('unicode - emoji and special characters', () => {
|
||||||
|
expect(`json.decode '"hello 👋"'`).toEvaluateTo('hello 👋')
|
||||||
|
expect(`json.decode '"🎉🚀✨"'`).toEvaluateTo('🎉🚀✨')
|
||||||
|
expect(`json.encode '你好'`).toEvaluateTo('"你好"')
|
||||||
|
expect(`json.encode 'café'`).toEvaluateTo('"café"')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('nested structures - arrays', () => {
|
||||||
|
expect(`json.decode '[[1,2],[3,4],[5,6]]'`).toEvaluateTo([[1, 2], [3, 4], [5, 6]])
|
||||||
|
expect(`json.decode '[1,[2,[3,[4]]]]'`).toEvaluateTo([1, [2, [3, [4]]]])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('nested structures - objects', () => {
|
||||||
|
expect(`json.decode '{"user":{"name":"Alice","age":30}}'`).toEvaluateTo({
|
||||||
|
user: { name: 'Alice', age: 30 }
|
||||||
|
})
|
||||||
|
expect(`json.decode '{"a":{"b":{"c":"deep"}}}'`).toEvaluateTo({
|
||||||
|
a: { b: { c: 'deep' } }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('nested structures - mixed arrays and objects', () => {
|
||||||
|
expect(`json.decode '[{"id":1,"tags":["a","b"]},{"id":2,"tags":["c"]}]'`).toEvaluateTo([
|
||||||
|
{ id: 1, tags: ['a', 'b'] },
|
||||||
|
{ id: 2, tags: ['c'] }
|
||||||
|
])
|
||||||
|
expect(`json.decode '{"items":[1,2,3],"meta":{"count":3}}'`).toEvaluateTo({
|
||||||
|
items: [1, 2, 3],
|
||||||
|
meta: { count: 3 }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('error handling - invalid json', () => {
|
||||||
|
expect(`json.decode '{invalid}'`).toFailEvaluation()
|
||||||
|
expect(`json.decode '[1,2,3'`).toFailEvaluation()
|
||||||
|
expect(`json.decode 'undefined'`).toFailEvaluation()
|
||||||
|
expect(`json.decode ''`).toFailEvaluation()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -349,6 +349,22 @@ describe('collections', () => {
|
||||||
await expect(`arr = [1 2 3 4 5]; list.splice arr 3 2; arr`).toEvaluateTo([1, 2, 3])
|
await expect(`arr = [1 2 3 4 5]; list.splice arr 3 2; arr`).toEvaluateTo([1, 2, 3])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('list.insert adds element at index and mutates array', async () => {
|
||||||
|
await expect(`arr = [1 2 4 5]; list.insert arr 2 3; arr`).toEvaluateTo([1, 2, 3, 4, 5])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('list.insert returns array length', async () => {
|
||||||
|
await expect(`list.insert [1 2 4] 2 3`).toEvaluateTo(4)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('list.insert at start', async () => {
|
||||||
|
await expect(`arr = [2 3]; list.insert arr 0 1; arr`).toEvaluateTo([1, 2, 3])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('list.insert at end', async () => {
|
||||||
|
await expect(`arr = [1 2]; list.insert arr 2 99; arr`).toEvaluateTo([1, 2, 99])
|
||||||
|
})
|
||||||
|
|
||||||
test('list.sort with no callback sorts ascending', async () => {
|
test('list.sort with no callback sorts ascending', async () => {
|
||||||
await expect(`list.sort [3 1 4 1 5] null`).toEvaluateTo([1, 1, 3, 4, 5])
|
await expect(`list.sort [3 1 4 1 5] null`).toEvaluateTo([1, 1, 3, 4, 5])
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user