evaluate booleans

This commit is contained in:
Lizzy Hunt 2024-03-05 14:28:28 -07:00
parent 9d1bd0d489
commit 2f77b3fb5a
No known key found for this signature in database
GPG Key ID: E835BD4B08CCAF96
5 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,4 @@
import type { Identifier } from '@/parser'; import type { Identifier } from '@/parser';
import { testingLogger } from '@t/logger';
export type UnionDenotableType = export type UnionDenotableType =
| Array<DenotableType | DenotableFunctionSignature> | Array<DenotableType | DenotableFunctionSignature>

View File

@ -29,6 +29,11 @@ const evaluateValue = (
if ('int' in value) { if ('int' in value) {
return { type: 'int', value: value.int }; return { type: 'int', value: value.int };
} }
if ('bool' in value) {
return { type: 'bool', value: value.bool };
}
if ('name' in value) { if ('name' in value) {
return env.get(value.name); return env.get(value.name);
} }

View File

@ -234,7 +234,7 @@ IntStatement = INT _ int:Integer { return int; }
RealStatement = REAL _ real:Real { return real; } RealStatement = REAL _ real:Real { return real; }
BoolStatement = BOOL _ bool:Integer { return bool; } BoolStatement = BOOL _ bool:Integer { return { bool: bool.int }; }
StringStatement = STRING _ string:QuotedString { return string; } StringStatement = STRING _ string:QuotedString { return string; }

View File

@ -2,5 +2,5 @@ export * from './generate';
export * from './parser'; export * from './parser';
import * as peggy from './parser'; import * as peggy from './parser';
export const peggyParse = (source: string): peggy.FunctionDefinition[] => export const peggyParse = (source: string): peggy.ContinuationExpression[] =>
peggy.parse(source); peggy.parse(source);

View File

@ -512,7 +512,7 @@ function peg$parse(input, options) {
return real; };// @ts-ignore return real; };// @ts-ignore
var peg$f18 = function(bool) {// @ts-ignore var peg$f18 = function(bool) {// @ts-ignore
return bool; };// @ts-ignore return { bool: bool.int }; };// @ts-ignore
var peg$f19 = function(string) {// @ts-ignore var peg$f19 = function(string) {// @ts-ignore
return string; };// @ts-ignore return string; };// @ts-ignore
@ -5395,7 +5395,7 @@ export type VarStatement = Identifier;
export type LabelStatement = Identifier; export type LabelStatement = Identifier;
export type IntStatement = Integer; export type IntStatement = Integer;
export type RealStatement = Real; export type RealStatement = Real;
export type BoolStatement = Integer; export type BoolStatement = { bool: any };
export type StringStatement = QuotedString; export type StringStatement = QuotedString;
export type AccessStatement = OffsetStatement | SelectStatement; export type AccessStatement = OffsetStatement | SelectStatement;
export type OffsetStatement = Integer; export type OffsetStatement = Integer;