File tree Expand file tree Collapse file tree 9 files changed +41
-27
lines changed
Expand file tree Collapse file tree 9 files changed +41
-27
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ import {
1313 type KeywordHandlers ,
1414 type SemanticGraph ,
1515} from '../semantics.js'
16- import { lookupPropertyOfObjectNode } from '../semantics/object-node.js'
16+ import {
17+ lookupPropertyOfObjectNode ,
18+ makeUnelaboratedObjectNode ,
19+ } from '../semantics/object-node.js'
1720
1821const unserializableFunction = ( ) =>
1922 either . makeLeft ( {
@@ -164,7 +167,10 @@ const lookupWithinExpression = (
164167 expression : Expression ,
165168) : Option < SemanticGraph > => {
166169 for ( const key of keyAliases ) {
167- const result = lookupPropertyOfObjectNode ( key , expression )
170+ const result = lookupPropertyOfObjectNode (
171+ key ,
172+ makeUnelaboratedObjectNode ( expression ) ,
173+ )
168174 if ( ! option . isNone ( result ) ) {
169175 return result
170176 }
Original file line number Diff line number Diff line change 1- import type { ObjectNode , SemanticGraph } from '../semantics.js'
1+ import type { Molecule } from '../parsing.js'
2+ import type { SemanticGraph } from './semantic-graph.js'
23
3- export type Expression = ObjectNode & {
4+ export type Expression = {
45 readonly 0 : `@${string } `
56}
67
7- export const isExpression = ( node : SemanticGraph ) : node is Expression =>
8+ export const isExpression = (
9+ node : SemanticGraph | Molecule ,
10+ ) : node is Expression =>
811 typeof node === 'object' && typeof node [ 0 ] === 'string' && node [ 0 ] [ 0 ] === '@'
Original file line number Diff line number Diff line change 11import { either , type Either } from '../../../adts.js'
22import type { ElaborationError } from '../../errors.js'
33import type { Molecule } from '../../parsing.js'
4- import { isExpression , type Expression } from '../expression.js'
5- import { makeUnelaboratedObjectNode } from '../object-node.js'
4+ import { isExpression } from '../expression.js'
5+ import { makeUnelaboratedObjectNode , type ObjectNode } from '../object-node.js'
66import { type SemanticGraph , type unelaboratedKey } from '../semantic-graph.js'
77import { readArgumentsFromExpression } from './expression-utilities.js'
88
9- export type ApplyExpression = Expression & {
9+ export type ApplyExpression = ObjectNode & {
1010 readonly 0 : '@apply'
1111 readonly function : SemanticGraph | Molecule
1212 readonly argument : SemanticGraph | Molecule
1313}
1414
1515export const readApplyExpression = (
16- node : SemanticGraph ,
16+ node : SemanticGraph | Molecule ,
1717) : Either < ElaborationError , ApplyExpression > =>
1818 isExpression ( node )
1919 ? either . map (
Original file line number Diff line number Diff line change 11import { either , type Either } from '../../../adts.js'
22import type { ElaborationError } from '../../errors.js'
33import type { Molecule } from '../../parsing.js'
4- import { isExpression , type Expression } from '../expression.js'
5- import { makeUnelaboratedObjectNode } from '../object-node.js'
4+ import { isExpression } from '../expression.js'
5+ import { makeUnelaboratedObjectNode , type ObjectNode } from '../object-node.js'
66import { type SemanticGraph , type unelaboratedKey } from '../semantic-graph.js'
77import { readArgumentsFromExpression } from './expression-utilities.js'
88
9- export type CheckExpression = Expression & {
9+ export type CheckExpression = ObjectNode & {
1010 readonly 0 : '@check'
1111 readonly value : SemanticGraph | Molecule
1212 readonly type : SemanticGraph | Molecule
1313}
1414
1515export const readCheckExpression = (
16- node : SemanticGraph ,
16+ node : SemanticGraph | Molecule ,
1717) : Either < ElaborationError , CheckExpression > =>
1818 isExpression ( node )
1919 ? either . map (
Original file line number Diff line number Diff line change @@ -72,7 +72,10 @@ const lookupWithinExpression = (
7272 expression : Expression ,
7373) : Option < SemanticGraph > => {
7474 for ( const key of keyAliases ) {
75- const result = lookupPropertyOfObjectNode ( key , expression )
75+ const result = lookupPropertyOfObjectNode (
76+ key ,
77+ makeUnelaboratedObjectNode ( expression ) ,
78+ )
7679 if ( ! option . isNone ( result ) ) {
7780 return result
7881 }
Original file line number Diff line number Diff line change 11import { either , type Either } from '../../../adts.js'
22import type { ElaborationError } from '../../errors.js'
33import type { Atom , Molecule } from '../../parsing.js'
4- import { isExpression , type Expression } from '../expression.js'
5- import { makeUnelaboratedObjectNode } from '../object-node.js'
4+ import { isExpression } from '../expression.js'
5+ import { makeUnelaboratedObjectNode , type ObjectNode } from '../object-node.js'
66import {
77 serialize ,
88 type SemanticGraph ,
@@ -13,14 +13,14 @@ import {
1313 readArgumentsFromExpression ,
1414} from './expression-utilities.js'
1515
16- export type FunctionExpression = Expression & {
16+ export type FunctionExpression = ObjectNode & {
1717 readonly 0 : '@function'
1818 readonly parameter : Atom
1919 readonly body : SemanticGraph | Molecule
2020}
2121
2222export const readFunctionExpression = (
23- node : SemanticGraph ,
23+ node : SemanticGraph | Molecule ,
2424) : Either < ElaborationError , FunctionExpression > =>
2525 isExpression ( node )
2626 ? either . flatMap (
Original file line number Diff line number Diff line change 11import { either , type Either } from '../../../adts.js'
22import type { ElaborationError , InvalidExpressionError } from '../../errors.js'
3- import { isExpression , type Expression } from '../expression.js'
3+ import type { Molecule } from '../../parsing.js'
4+ import { isExpression } from '../expression.js'
45import { isFunctionNode } from '../function-node.js'
56import { keyPathToMolecule , type KeyPath } from '../key-path.js'
67import {
@@ -14,13 +15,13 @@ import {
1415 readArgumentsFromExpression ,
1516} from './expression-utilities.js'
1617
17- export type LookupExpression = Expression & {
18+ export type LookupExpression = ObjectNode & {
1819 readonly 0 : '@lookup'
1920 readonly query : ObjectNode
2021}
2122
2223export const readLookupExpression = (
23- node : SemanticGraph ,
24+ node : SemanticGraph | Molecule ,
2425) : Either < ElaborationError , LookupExpression > =>
2526 isExpression ( node )
2627 ? either . flatMap (
Original file line number Diff line number Diff line change 11import { either , type Either } from '../../../adts.js'
22import type { ElaborationError } from '../../errors.js'
3- import { isExpression , type Expression } from '../expression.js'
3+ import type { Molecule } from '../../parsing.js'
4+ import { isExpression } from '../expression.js'
45import { isFunctionNode } from '../function-node.js'
5- import { makeUnelaboratedObjectNode } from '../object-node.js'
6+ import { makeUnelaboratedObjectNode , type ObjectNode } from '../object-node.js'
67import {
78 containsAnyUnelaboratedNodes ,
89 type SemanticGraph ,
@@ -13,13 +14,13 @@ import {
1314 readArgumentsFromExpression ,
1415} from './expression-utilities.js'
1516
16- export type RuntimeExpression = Expression & {
17+ export type RuntimeExpression = ObjectNode & {
1718 readonly 0 : '@runtime'
1819 readonly function : SemanticGraph
1920}
2021
2122export const readRuntimeExpression = (
22- node : SemanticGraph ,
23+ node : SemanticGraph | Molecule ,
2324) : Either < ElaborationError , RuntimeExpression > =>
2425 isExpression ( node )
2526 ? either . flatMap (
Original file line number Diff line number Diff line change 1- import { type Expression } from '../expression .js'
1+ import type { ObjectNode } from '../object-node .js'
22
3- export type TodoExpression = Expression & {
3+ export type TodoExpression = ObjectNode & {
44 readonly 0 : '@todo'
55}
You can’t perform that action at this time.
0 commit comments