Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/language/semantics/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const isExpression = (
/^@[^@]/.test(node['0']) &&
(!('1' in node) || typeof node[1] === 'object' || typeof node[1] === 'string')

export const isExpressionWithArgument = <Keyword extends `@${string}`>(
export const isKeywordExpressionWithArgument = <Keyword extends `@${string}`>(
keyword: Keyword,
node: Molecule | SemanticGraph,
): node is {
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/apply-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import { type SemanticGraph } from '../semantic-graph.js'
import { readArgumentsFromExpression } from './expression-utilities.js'
Expand All @@ -17,7 +17,7 @@ export type ApplyExpression = ObjectNode & {
export const readApplyExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, ApplyExpression> =>
isExpressionWithArgument('@apply', node)
isKeywordExpressionWithArgument('@apply', node)
? either.map(
readArgumentsFromExpression(node, ['function', 'argument']),
([f, argument]) => makeApplyExpression({ function: f, argument }),
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/check-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import { type SemanticGraph } from '../semantic-graph.js'
import { readArgumentsFromExpression } from './expression-utilities.js'
Expand All @@ -17,7 +17,7 @@ export type CheckExpression = ObjectNode & {
export const readCheckExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, CheckExpression> =>
isExpressionWithArgument('@check', node)
isKeywordExpressionWithArgument('@check', node)
? either.map(
readArgumentsFromExpression(node, ['value', 'type']),
([value, type]) => makeCheckExpression({ value, type }),
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/function-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Atom, Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import { serialize, type SemanticGraph } from '../semantic-graph.js'
import {
Expand All @@ -20,7 +20,7 @@ export type FunctionExpression = ObjectNode & {
export const readFunctionExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, FunctionExpression> =>
isExpressionWithArgument('@function', node)
isKeywordExpressionWithArgument('@function', node)
? either.flatMap(
readArgumentsFromExpression(node, ['parameter', 'body']),
([parameter, body]): Either<ElaborationError, FunctionExpression> =>
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/if-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import { type SemanticGraph } from '../semantic-graph.js'
import { readArgumentsFromExpression } from './expression-utilities.js'
Expand All @@ -19,7 +19,7 @@ export type IfExpression = ObjectNode & {
export const readIfExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, IfExpression> =>
isExpressionWithArgument('@if', node)
isKeywordExpressionWithArgument('@if', node)
? either.map(
readArgumentsFromExpression(node, ['condition', 'then', 'else']),
([condition, then, otherwise]) =>
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/index-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { keyPathFromObjectNodeOrMolecule } from '../key-path.js'
import {
isObjectNode,
Expand All @@ -25,7 +25,7 @@ export type IndexExpression = ObjectNode & {
export const readIndexExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, IndexExpression> =>
isExpressionWithArgument('@index', node)
isKeywordExpressionWithArgument('@index', node)
? either.flatMap(
readArgumentsFromExpression(node, ['object', 'query']),
([o, q]) => {
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/lookup-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Atom, Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { keyPathToMolecule, type NonEmptyKeyPath } from '../key-path.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import {
Expand All @@ -24,7 +24,7 @@ export type LookupExpression = ObjectNode & {
export const readLookupExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, LookupExpression> =>
isExpressionWithArgument('@lookup', node)
isKeywordExpressionWithArgument('@lookup', node)
? either.flatMap(readArgumentsFromExpression(node, ['key']), ([key]) => {
if (typeof key !== 'string') {
return either.makeLeft({
Expand Down
4 changes: 2 additions & 2 deletions src/language/semantics/expressions/runtime-expression.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import either, { type Either } from '@matt.kantor/either'
import type { ElaborationError } from '../../errors.js'
import type { Molecule } from '../../parsing.js'
import { isExpressionWithArgument } from '../expression.js'
import { isKeywordExpressionWithArgument } from '../expression.js'
import { isFunctionNode } from '../function-node.js'
import { makeObjectNode, type ObjectNode } from '../object-node.js'
import {
Expand All @@ -23,7 +23,7 @@ export type RuntimeExpression = ObjectNode & {
export const readRuntimeExpression = (
node: SemanticGraph | Molecule,
): Either<ElaborationError, RuntimeExpression> =>
isExpressionWithArgument('@runtime', node)
isKeywordExpressionWithArgument('@runtime', node)
? either.flatMap(readArgumentsFromExpression(node, ['function']), ([f]) => {
const runtimeFunction = asSemanticGraph(f)
if (
Expand Down