diff --git a/src/lang/abstractSyntaxTree.ts b/src/lang/abstractSyntaxTree.ts index 49b10d224..020168961 100644 --- a/src/lang/abstractSyntaxTree.ts +++ b/src/lang/abstractSyntaxTree.ts @@ -181,6 +181,23 @@ function makeArguments( const isIdentifierOrLiteral = nextBraceOrCommaToken.token.type === 'comma' || nextBraceOrCommaToken.token.type === 'brace' + if ( + argumentToken.token.type === 'brace' && + argumentToken.token.value === '[' + ) { + const { expression, lastIndex } = makeArrayExpression( + tokens, + argumentToken.index + ) + const nextCommarOrBraceTokenIndex = nextMeaningfulToken( + tokens, + lastIndex + ).index + return makeArguments(tokens, nextCommarOrBraceTokenIndex, [ + ...previousArgs, + expression, + ]) + } if (!isIdentifierOrLiteral) { const { expression, lastIndex } = makeBinaryExpression(tokens, index) return makeArguments(tokens, lastIndex, [...previousArgs, expression]) diff --git a/src/lang/executor.ts b/src/lang/executor.ts index 37e498d73..f07ffe36a 100644 --- a/src/lang/executor.ts +++ b/src/lang/executor.ts @@ -286,6 +286,17 @@ function executePipeBody( return programMemory.root[arg.name] } else if (arg.type === 'PipeSubstitution') { return previousResults[expressionIndex - 1] + } else if (arg.type === 'ArrayExpression') { + return arg.elements.map((el) => { + if (el.type === 'Literal') { + return el.value + } else if (el.type === 'Identifier') { + return programMemory.root[el.name] + } else if (el.type === 'BinaryExpression') { + return getBinaryExpressionResult(el, programMemory) + } + throw new Error('Invalid argument type') + }) } throw new Error('Invalid argument type') })