Skip to content

Commit 78275f9

Browse files
committed
Stub out @if keyword expression
1 parent d2d95d5 commit 78275f9

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import either, { type Either } from '@matt.kantor/either'
2+
import type { ElaborationError } from '../../../errors.js'
3+
import {
4+
type Expression,
5+
type ExpressionContext,
6+
type KeywordHandler,
7+
type SemanticGraph,
8+
} from '../../../semantics.js'
9+
10+
export const ifKeywordHandler: KeywordHandler = (
11+
_expression: Expression,
12+
_context: ExpressionContext,
13+
): Either<ElaborationError, SemanticGraph> =>
14+
either.makeLeft({ kind: 'bug', message: 'not implemented' })

src/language/compiling/semantics/keywords.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { type KeywordHandlers } from '../../semantics.js'
22
import { applyKeywordHandler } from './keyword-handlers/apply-handler.js'
33
import { checkKeywordHandler } from './keyword-handlers/check-handler.js'
44
import { functionKeywordHandler } from './keyword-handlers/function-handler.js'
5+
import { ifKeywordHandler } from './keyword-handlers/if-handler.js'
56
import { indexKeywordHandler } from './keyword-handlers/index-handler.js'
67
import { lookupKeywordHandler } from './keyword-handlers/lookup-handler.js'
78
import { panicKeywordHandler } from './keyword-handlers/panic-handler.js'
@@ -24,6 +25,11 @@ export const keywordHandlers: KeywordHandlers = {
2425
*/
2526
'@function': functionKeywordHandler,
2627

28+
/**
29+
* Conditionally evaluates one of two expressions based on a boolean value.
30+
*/
31+
'@if': ifKeywordHandler,
32+
2733
/**
2834
* Returns the value of a property within an object.
2935
*/

src/language/semantics/keyword.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const isKeyword = (input: string) =>
22
input === '@apply' ||
33
input === '@check' ||
44
input === '@function' ||
5+
input === '@if' ||
56
input === '@index' ||
67
input === '@lookup' ||
78
input === '@panic' ||

0 commit comments

Comments
 (0)