make ts compatible
commit 94803421acd2e5cb3a0f88e10f9244d374fab20b Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 08:48:33 2022 +0200 note on old habbits commit 2c47f80fce8fa6c12cb53b97f7150758eaa74b88 Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 08:18:16 2022 +0200 getTag returns enum value commit 733b9a820f1d01b618708896451a112d638ee811 Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 07:07:30 2022 +0200 result commit 64698f4a930182b3ccf122849824e4b6df251a9f Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 06:48:30 2022 +0200 return tags as ts enum commit 8ac802428a7aaac5367f5e8a9aaa592b89e305eb Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 06:16:26 2022 +0200 export tags commit 6c843e475a98ca1fcfa893d09d45ac9ad7c633ee Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 06:11:00 2022 +0200 distribution tag commit 9a43ec30fcaf967a672475431243949748d00bc7 Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 05:46:24 2022 +0200 opaque result commit f89bdd47c41135135baac99b18faf1c418cc4142 Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 05:24:18 2022 +0200 make ts compilable commit 6609bb3691b08405639e6f20da0fad309f2f232e Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 05:21:34 2022 +0200 compiles commit bace3eca63079de8f285069c65b219601e7310bf Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 04:33:34 2022 +0200 rescript compiles commit cd095f605c543902edec08fdcd407600296ec0cb Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 02:40:31 2022 +0200 squiggleValue commit 9b78b5d6c8b69287458fe392f142ceb3bca99407 Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 02:37:11 2022 +0200 project commit 20c8693b1eb6492f1662bedbb26b469aac11f8ff Author: Umur Ozkul <umur@hightechmind.io> Date: Mon Aug 22 00:59:44 2022 +0200 compiles
This commit is contained in:
parent
25fb6dec82
commit
e6464dbe5c
|
@ -10,7 +10,6 @@ Instead of a global function namespace we should use modules under ForTS directl
|
|||
|
||||
*/
|
||||
|
||||
|
||||
import * as _ from "lodash";
|
||||
import type {
|
||||
environment,
|
||||
|
@ -57,7 +56,6 @@ export let defaultSamplingInputs: environment = {
|
|||
xyPointLength: 10000,
|
||||
};
|
||||
|
||||
|
||||
/* Umur: All the functions below are invalid. ForTS_Reducer project is the new way to do this. */
|
||||
|
||||
// export function run(
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
import * as _ from "lodash";
|
||||
import type {
|
||||
expressionValue,
|
||||
mixedShape,
|
||||
sampleSetDist,
|
||||
genericDist,
|
||||
environment,
|
||||
symbolicDist,
|
||||
discreteShape,
|
||||
continuousShape,
|
||||
lambdaValue,
|
||||
lambdaDeclaration,
|
||||
declarationArg,
|
||||
} from "../rescript/TypescriptInterface.gen";
|
||||
import { Distribution } from "./distribution";
|
||||
import { tagged, tag } from "./types";
|
||||
/**
|
||||
Umur: Delete this file! There is nothing left to see here.
|
||||
**/
|
||||
|
||||
// import * as _ from "lodash";
|
||||
// import type {
|
||||
// // expressionValue,
|
||||
// mixedShape,
|
||||
// sampleSetDist,
|
||||
// genericDist,
|
||||
// // environment,
|
||||
// symbolicDist,
|
||||
// discreteShape,
|
||||
// continuousShape,
|
||||
// // lambdaValue,
|
||||
// // lambdaDeclaration,
|
||||
// // declarationArg,
|
||||
// } from "../rescript/TypescriptInterface.gen";
|
||||
// import { Distribution } from "./distribution";
|
||||
// import { tagged, tag } from "./types";
|
||||
// This file is here to compensate for genType not fully recursively converting types
|
||||
|
||||
// Raw rescript types.
|
||||
|
@ -81,24 +85,26 @@ import { tagged, tag } from "./types";
|
|||
// _0: { [key: string]: rescriptExport };
|
||||
// };
|
||||
|
||||
type rescriptDist =
|
||||
| { TAG: 0; _0: rescriptPointSetDist }
|
||||
| { TAG: 1; _0: sampleSetDist }
|
||||
| { TAG: 2; _0: symbolicDist };
|
||||
// Umur: opaque type
|
||||
// type rescriptDist =
|
||||
// | { TAG: 0; _0: rescriptPointSetDist }
|
||||
// | { TAG: 1; _0: sampleSetDist }
|
||||
// | { TAG: 2; _0: symbolicDist };
|
||||
|
||||
type rescriptPointSetDist =
|
||||
| {
|
||||
TAG: 0; // Mixed
|
||||
_0: mixedShape;
|
||||
}
|
||||
| {
|
||||
TAG: 1; // Discrete
|
||||
_0: discreteShape;
|
||||
}
|
||||
| {
|
||||
TAG: 2; // ContinuousShape
|
||||
_0: continuousShape;
|
||||
};
|
||||
// Umur: opaque type, no conversion
|
||||
// type rescriptPointSetDist =
|
||||
// | {
|
||||
// TAG: 0; // Mixed
|
||||
// _0: mixedShape;
|
||||
// }
|
||||
// | {
|
||||
// TAG: 1; // Discrete
|
||||
// _0: discreteShape;
|
||||
// }
|
||||
// | {
|
||||
// TAG: 2; // ContinuousShape
|
||||
// _0: continuousShape;
|
||||
// };
|
||||
|
||||
// type rescriptLambdaDeclaration = {
|
||||
// readonly fn: lambdaValue;
|
||||
|
@ -211,32 +217,33 @@ type rescriptPointSetDist =
|
|||
// }
|
||||
// }
|
||||
|
||||
function convertRawDistributionToGenericDist(
|
||||
result: rescriptDist
|
||||
): genericDist {
|
||||
switch (result.TAG) {
|
||||
case 0: // Point Set Dist
|
||||
switch (result._0.TAG) {
|
||||
case 0: // Mixed
|
||||
return tag("PointSet", tag("Mixed", result._0._0));
|
||||
case 1: // Discrete
|
||||
return tag("PointSet", tag("Discrete", result._0._0));
|
||||
case 2: // Continuous
|
||||
return tag("PointSet", tag("Continuous", result._0._0));
|
||||
}
|
||||
case 1: // Sample Set Dist
|
||||
return tag("SampleSet", result._0);
|
||||
case 2: // Symbolic Dist
|
||||
return tag("Symbolic", result._0);
|
||||
}
|
||||
}
|
||||
// Umur: opaque type no conversion!
|
||||
// function convertRawDistributionToGenericDist(
|
||||
// result: rescriptDist
|
||||
// ): genericDist {
|
||||
// switch (result.TAG) {
|
||||
// case 0: // Point Set Dist
|
||||
// switch (result._0.TAG) {
|
||||
// case 0: // Mixed
|
||||
// return tag("PointSet", tag("Mixed", result._0._0));
|
||||
// case 1: // Discrete
|
||||
// return tag("PointSet", tag("Discrete", result._0._0));
|
||||
// case 2: // Continuous
|
||||
// return tag("PointSet", tag("Continuous", result._0._0));
|
||||
// }
|
||||
// case 1: // Sample Set Dist
|
||||
// return tag("SampleSet", result._0);
|
||||
// case 2: // Symbolic Dist
|
||||
// return tag("Symbolic", result._0);
|
||||
// }
|
||||
// }
|
||||
|
||||
export type jsValue =
|
||||
| string
|
||||
| number
|
||||
| jsValue[]
|
||||
| { [key: string]: jsValue }
|
||||
| boolean;
|
||||
// export type jsValue =
|
||||
// | string
|
||||
// | number
|
||||
// | jsValue[]
|
||||
// | { [key: string]: jsValue }
|
||||
// | boolean;
|
||||
|
||||
// export function jsValueToBinding(value: jsValue): rescriptExport {
|
||||
// if (typeof value === "boolean") {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
|
||||
type functionCallInfo = DistributionTypes.DistributionOperation.genericFunctionCallInfo
|
||||
type genericDist = DistributionTypes.genericDist
|
||||
type error = DistributionTypes.error
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
|
||||
@genType
|
||||
let defaultEnv: GenericDist.env
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@genType
|
||||
//FIXME accessor methods or not opaque?
|
||||
@genType.opaque
|
||||
type genericDist =
|
||||
| PointSet(PointSetTypes.pointSetDist)
|
||||
| SampleSet(SampleSetDist.t)
|
||||
|
@ -6,6 +7,7 @@ type genericDist =
|
|||
|
||||
type asAlgebraicCombinationStrategy = AsDefault | AsSymbolic | AsMonteCarlo | AsConvolution
|
||||
|
||||
@genType.opaque
|
||||
type error =
|
||||
| NotYetImplemented
|
||||
| Unreachable
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
//TODO: multimodal, add interface, test somehow, track performance, refactor sampleSet, refactor ASTEvaluator.res.
|
||||
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
|
||||
|
||||
type t = DistributionTypes.genericDist
|
||||
type error = DistributionTypes.error
|
||||
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
|
||||
|
||||
type t = DistributionTypes.genericDist
|
||||
type error = DistributionTypes.error
|
||||
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
|
||||
|
|
|
@ -47,7 +47,7 @@ type pointSetDistMonad<'a, 'b, 'c> =
|
|||
| Discrete('b)
|
||||
| Continuous('c)
|
||||
|
||||
@genType
|
||||
@genType.opaque
|
||||
type pointSetDist = pointSetDistMonad<mixedShape, discreteShape, continuousShape>
|
||||
|
||||
module ShapeMonad = {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// Genetic Distribution happens to be abstract distribution
|
||||
@genType type distribution = DistributionTypes.genericDist
|
||||
@genType type pointSetDistribution = ForTS_Distribution_PointSetDistribution.pointSetDistribution
|
||||
@genType type sampleSetDistribution = ForTS_Distribution_SampleSetDistribution.sampleSetDistribution
|
||||
@genType type symbolicDistribution = ForTS_Distribution_SymbolicDistribution.symbolicDistribution
|
||||
|
||||
type environment = ForTS_Distribution_Environment.environment //use
|
||||
|
||||
@genType
|
||||
let defaultEnvironment: environment = DistributionOperation.defaultEnv
|
||||
|
||||
@module("ForTS_Distribution_tag") @scope("distributionTag")
|
||||
external dtPointSet_: int = "DtPointSet"
|
||||
|
||||
@module("ForTS_Distribution_tag") @scope("distributionTag")
|
||||
external dtSampleSet_: int = "DtSampleSet"
|
||||
|
||||
@module("ForTS_Distribution_tag") @scope("distributionTag")
|
||||
external dtSymbolic_: int = "DtSymbolic"
|
||||
|
||||
@genType.import("./ForTS_Distribution_tag")
|
||||
type distributionTag
|
||||
|
||||
external castEnum: int => distributionTag = "%identity"
|
||||
|
||||
// type genericDist =
|
||||
// | PointSet(PointSetTypes.pointSetDist)
|
||||
// | SampleSet(SampleSetDist.t)
|
||||
// | Symbolic(SymbolicDistTypes.symbolicDist)
|
||||
@genType
|
||||
let getTag = (variant: distribution): distributionTag =>
|
||||
switch variant {
|
||||
| PointSet(_) => dtPointSet_->castEnum
|
||||
| SampleSet(_) => dtSampleSet_->castEnum
|
||||
| Symbolic(_) => dtSymbolic_->castEnum
|
||||
}
|
||||
|
||||
@genType
|
||||
let getPointSet = (variant: distribution): option<pointSetDistribution> =>
|
||||
switch variant {
|
||||
| PointSet(dist) => dist->Some
|
||||
| _ => None
|
||||
}
|
||||
|
||||
@genType
|
||||
let getSampleSet = (variant: distribution): option<sampleSetDistribution> =>
|
||||
switch variant {
|
||||
| SampleSet(dist) => dist->Some
|
||||
| _ => None
|
||||
}
|
||||
|
||||
@genType
|
||||
let getSymbolic = (variant: distribution): option<symbolicDistribution> =>
|
||||
switch variant {
|
||||
| Symbolic(dist) => dist->Some
|
||||
| _ => None
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
@genType type environment = GenericDist.env //re-export
|
|
@ -1,4 +1,4 @@
|
|||
open ForTS__Types
|
||||
@genType type distributionError = DistributionTypes.error
|
||||
|
||||
@genType
|
||||
let toString = (e: distributionError) => DistributionTypes.Error.toString(e)
|
|
@ -0,0 +1,44 @@
|
|||
@genType type pointSetDistribution = PointSetTypes.pointSetDist
|
||||
|
||||
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
|
||||
external pstMixed_: int = "PstMixed"
|
||||
|
||||
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
|
||||
external pstDiscrete_: int = "PstDiscrete"
|
||||
|
||||
@module("ForTS_Distribution_PointSetDistribution_tag") @scope("pointSetDistributionTag")
|
||||
external pstContinuous_: int = "PstContinuous"
|
||||
|
||||
@genType.import("./ForTS_Distribution_PointSetDistribution_tag")
|
||||
type pointSetDistributionTag
|
||||
|
||||
external castEnum: int => pointSetDistributionTag = "%identity"
|
||||
|
||||
@genType
|
||||
let getTag = (variant: pointSetDistribution): pointSetDistributionTag =>
|
||||
switch variant {
|
||||
| Mixed(_) => pstMixed_->castEnum
|
||||
| Discrete(_) => pstDiscrete_->castEnum
|
||||
| Continuous(_) => pstContinuous_->castEnum
|
||||
}
|
||||
|
||||
@genType
|
||||
let getMixed = (variant: pointSetDistribution): 'd =>
|
||||
switch variant {
|
||||
| Mixed(mixed) => mixed->Some
|
||||
| _ => None
|
||||
}
|
||||
|
||||
@genType
|
||||
let getDiscrete = (variant: pointSetDistribution): 'd =>
|
||||
switch variant {
|
||||
| Discrete(discrete) => discrete->Some
|
||||
| _ => None
|
||||
}
|
||||
|
||||
@genType
|
||||
let getContinues = (variant: pointSetDistribution): 'd =>
|
||||
switch variant {
|
||||
| Continuous(continuous) => continuous->Some
|
||||
| _ => None
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.pointSetDistributionTag = void 0;
|
||||
var pointSetDistributionTag;
|
||||
(function (pointSetDistributionTag) {
|
||||
pointSetDistributionTag[(pointSetDistributionTag["PstMixed"] = 0)] =
|
||||
"PstMixed";
|
||||
pointSetDistributionTag[(pointSetDistributionTag["PstDiscrete"] = 1)] =
|
||||
"PstDiscrete";
|
||||
pointSetDistributionTag[(pointSetDistributionTag["PstContinuous"] = 2)] =
|
||||
"PstContinuous";
|
||||
})(
|
||||
(pointSetDistributionTag =
|
||||
exports.pointSetDistributionTag || (exports.pointSetDistributionTag = {}))
|
||||
);
|
|
@ -0,0 +1,5 @@
|
|||
export enum pointSetDistributionTag {
|
||||
PstMixed,
|
||||
PstDiscrete,
|
||||
PstContinuous,
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
@genType type sampleSetDistribution = SampleSetDist.t
|
|
@ -0,0 +1 @@
|
|||
@genType type symbolicDistribution = SymbolicDistTypes.symbolicDist
|
|
@ -0,0 +1,5 @@
|
|||
export enum distributionTag {
|
||||
DtPointSet,
|
||||
DtSampleSet,
|
||||
DtSymbolic,
|
||||
}
|
|
@ -1,6 +1,13 @@
|
|||
open ForTS__Types
|
||||
// If a module is built for TypeScript then it can only refer to ForTS__Types for other types and modules
|
||||
// The exception is its implementation and private modules
|
||||
@genType type reducerProject = ReducerProject_T.t //re-export
|
||||
|
||||
type result<'a, 'e> = ForTS_Result.result<'a, 'e> // Use opaque result type
|
||||
type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //use
|
||||
|
||||
type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
|
||||
type squiggleValue_Module = ForTS_SquiggleValue_Module.squiggleValue_Module //use
|
||||
|
||||
type environment = ForTS_Distribution_Environment.environment //use
|
||||
|
||||
module T = ReducerProject_T
|
||||
module Private = ReducerProject.Private
|
||||
|
||||
|
@ -9,6 +16,8 @@ module Private = ReducerProject.Private
|
|||
*/
|
||||
|
||||
/*
|
||||
A project links and runs sources that continue or include each other.
|
||||
|
||||
Creates a new project to hold the sources, executables, bindings, and other data.
|
||||
The new project runs the sources according to their topological sorting because of the includes and continues.
|
||||
|
||||
|
@ -92,7 +101,7 @@ let cleanAllResults = (project: reducerProject): unit =>
|
|||
To set the includes one first has to call "parseIncludes". The parsed includes or the parser error is returned.
|
||||
*/
|
||||
@genType
|
||||
let getIncludes = (project: reducerProject, sourceId: string): result_<
|
||||
let getIncludes = (project: reducerProject, sourceId: string): result<
|
||||
array<string>,
|
||||
reducerErrorValue,
|
||||
> => project->T.Private.castToInternalProject->Private.getIncludes(sourceId)
|
||||
|
@ -145,7 +154,7 @@ let getRunOrderFor = (project: reducerProject, sourceId: string) =>
|
|||
Parse includes so that you can load them before running.
|
||||
Load includes by calling getIncludes which returns the includes that have been parsed.
|
||||
It is your responsibility to load the includes before running.
|
||||
*/ module Topology = ReducerProject_Topology
|
||||
*/
|
||||
|
||||
@genType
|
||||
let parseIncludes = (project: reducerProject, sourceId: string): unit =>
|
||||
|
@ -186,7 +195,7 @@ Get the result after running this source file or the project
|
|||
*/
|
||||
@genType
|
||||
let getResult = (project: reducerProject, sourceId: string): option<
|
||||
result_<squiggleValue, reducerErrorValue>,
|
||||
result<squiggleValue, reducerErrorValue>,
|
||||
> => project->T.Private.castToInternalProject->Private.getResult(sourceId)
|
||||
|
||||
/*
|
||||
|
@ -194,7 +203,11 @@ This is a convenience function to get the result of a single source without crea
|
|||
However, without a project, you cannot handle include directives.
|
||||
The source has to be include free
|
||||
*/
|
||||
@genType let evaluate = (sourceCode: string): ('r, 'b) => Private.evaluate(sourceCode)
|
||||
@genType
|
||||
let evaluate = (sourceCode: string): (
|
||||
result<squiggleValue, reducerErrorValue>,
|
||||
squiggleValue_Module,
|
||||
) => Private.evaluate(sourceCode)
|
||||
|
||||
@genType
|
||||
let setEnvironment = (project: reducerProject, environment: environment): unit =>
|
||||
|
@ -211,7 +224,7 @@ If the conversion to the new project is too difficult, I can add it later.
|
|||
// lambdaValue: squiggleValue_Lambda,
|
||||
// argArray: array<squiggleValue>,
|
||||
// environment: environment,
|
||||
// ): result_<squiggleValue, reducerErrorValue> => {
|
||||
// ): result<squiggleValue, reducerErrorValue> => {
|
||||
// let accessors = ReducerProject_ProjectAccessors_T.identityAccessorsWithEnvironment(environment)
|
||||
// Reducer_Expression_Lambda.foreignFunctionInterface(
|
||||
// lambdaValue,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
open ForTS__Types
|
||||
@genType type reducerErrorValue = Reducer_ErrorValue.errorValue //alias
|
||||
@genType type syntaxErrorLocation = Reducer_ErrorValue.syntaxErrorLocation //alias
|
||||
|
||||
@genType
|
||||
let toString = (e: reducerErrorValue): string => Reducer_ErrorValue.errorToString(e)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
open ForTS__Types
|
||||
@genType.opaque type result_<'a, 'e> = result<'a, 'e>
|
||||
@genType type result<'a, 'e> = result_<'a, 'e> // alias and re-export
|
||||
|
||||
@genType let isError = (r: result_<'a, 'e>): bool => Belt.Result.isError(r)
|
||||
@genType let isOk = (r: result_<'a, 'e>): bool => Belt.Result.isOk(r)
|
||||
|
@ -11,27 +12,32 @@ let getError = (r: result_<'a, 'e>): option<'e> =>
|
|||
}
|
||||
|
||||
@genType
|
||||
let getValue = (r: result_<'a, 'e>): option<'a> =>
|
||||
let getValue = (r: result<'a, 'e>): option<'a> =>
|
||||
switch r {
|
||||
| Ok(v) => Some(v)
|
||||
| Error(_) => None
|
||||
}
|
||||
|
||||
@module("ForTS_Result_tag") @scope("ResultTag")
|
||||
@module("ForTS_Result_tag") @scope("resultTag")
|
||||
external rtOk_: int = "RtOk"
|
||||
|
||||
@module("ForTS_Result_tag") @scope("ResultTag")
|
||||
@module("ForTS_Result_tag") @scope("resultTag")
|
||||
external rtError_: int = "RtError"
|
||||
|
||||
@genType.import("./ForTS_Result_tag")
|
||||
type resultTag
|
||||
|
||||
external castEnum: int => resultTag = "%identity"
|
||||
|
||||
@genType
|
||||
let getTag = (r: result_<'a, 'e>): int =>
|
||||
let getTag = (r: result<'a, 'e>): resultTag =>
|
||||
switch r {
|
||||
| Ok(_) => rtOk_
|
||||
| Error(_) => rtError_
|
||||
| Ok(_) => rtOk_->castEnum
|
||||
| Error(_) => rtError_->castEnum
|
||||
}
|
||||
|
||||
@genType
|
||||
let fmap = (r: result_<'a, 'e>, f: 'a => 'b): result_<'b, 'e> =>
|
||||
let fmap = (r: result<'a, 'e>, f: 'a => 'b): result<'b, 'e> =>
|
||||
switch r {
|
||||
| Ok(v) => Ok(f(v))
|
||||
| Error(e) => Error(e)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
enum ResultTag {
|
||||
export enum resultTag {
|
||||
Ok,
|
||||
Error,
|
||||
}
|
|
@ -1,78 +1,93 @@
|
|||
open ForTS__Types
|
||||
@genType type squiggleValue = ReducerInterface_InternalExpressionValue.t //re-export
|
||||
type result_<'a, 'e> = ForTS_Result.result_<'a, 'e> //use
|
||||
type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //use
|
||||
|
||||
// Return values as they are if they are JavaScript types.
|
||||
@genType type squiggleValue_Array = ReducerInterface_InternalExpressionValue.squiggleArray //re-export recursive type
|
||||
@genType type squiggleValue_Module = ReducerInterface_InternalExpressionValue.nameSpace //re-export recursive type
|
||||
@genType type squiggleValue_Record = ReducerInterface_InternalExpressionValue.map //re-export recursive type
|
||||
@genType type squiggleValue_Type = ReducerInterface_InternalExpressionValue.map //re-export recursive type
|
||||
type squiggleValue_Declaration = ForTS_SquiggleValue_Declaration.squiggleValue_Declaration //use
|
||||
type squiggleValue_Distribution = ForTS_SquiggleValue_Distribution.squiggleValue_Distribution //use
|
||||
type squiggleValue_Lambda = ForTS_SquiggleValue_Lambda.squiggleValue_Lambda //use
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
// Return values are kept as they are if they are JavaScript types.
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtArray_: int = "SvtArray"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtArrayString_: int = "SvtArrayString"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtBool_: int = "SvtBool"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtCall_: int = "SvtCall"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtDate_: int = "SvtDate"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtDeclaration_: int = "SvtDeclaration"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtDistribution_: int = "SvtDistribution"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtLambda_: int = "SvtLambda"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtModule_: int = "SvtModule"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtNumber_: int = "SvtNumber"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtRecord_: int = "SvtRecord"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtString_: int = "SvtString"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtSymbol_: int = "SvtSymbol"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtTimeDuration_: int = "SvtTimeDuration"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtType_: int = "SvtType"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtTypeIdentifier_: int = "SvtUndefined"
|
||||
|
||||
@module("ForTS_SquiggleValue_tag") @scope("SquiggleValueTag")
|
||||
@module("ForTS_SquiggleValue_tag") @scope("squiggleValueTag")
|
||||
external svtVoid_: int = "SvtVoid"
|
||||
|
||||
@genType.import("./ForTS_SquiggleValue_tag")
|
||||
type squiggleValueTag
|
||||
|
||||
external castEnum: int => squiggleValueTag = "%identity"
|
||||
|
||||
@genType
|
||||
let getTag = (variant: squiggleValue) =>
|
||||
let getTag = (variant: squiggleValue): squiggleValueTag =>
|
||||
switch variant {
|
||||
| IEvArray(_) => svtArray_
|
||||
| IEvArrayString(_) => svtArrayString_
|
||||
| IEvBool(_) => svtBool_
|
||||
| IEvCall(_) => svtCall_ //Impossible
|
||||
| IEvDate(_) => svtDate_
|
||||
| IEvDeclaration(_) => svtDeclaration_
|
||||
| IEvDistribution(_) => svtDistribution_
|
||||
| IEvLambda(_) => svtLambda_
|
||||
| IEvBindings(_) => svtModule_ //Impossible
|
||||
| IEvNumber(_) => svtNumber_
|
||||
| IEvRecord(_) => svtRecord_
|
||||
| IEvString(_) => svtString_
|
||||
| IEvSymbol(_) => svtSymbol_
|
||||
| IEvTimeDuration(_) => svtTimeDuration_
|
||||
| IEvType(_) => svtType_
|
||||
| IEvTypeIdentifier(_) => svtTypeIdentifier_
|
||||
| IEvVoid => svtVoid_
|
||||
| IEvArray(_) => svtArray_->castEnum
|
||||
| IEvArrayString(_) => svtArrayString_->castEnum
|
||||
| IEvBool(_) => svtBool_->castEnum
|
||||
| IEvCall(_) => svtCall_->castEnum //Impossible
|
||||
| IEvDate(_) => svtDate_->castEnum
|
||||
| IEvDeclaration(_) => svtDeclaration_->castEnum
|
||||
| IEvDistribution(_) => svtDistribution_->castEnum
|
||||
| IEvLambda(_) => svtLambda_->castEnum
|
||||
| IEvBindings(_) => svtModule_->castEnum //Impossible
|
||||
| IEvNumber(_) => svtNumber_->castEnum
|
||||
| IEvRecord(_) => svtRecord_->castEnum
|
||||
| IEvString(_) => svtString_->castEnum
|
||||
| IEvSymbol(_) => svtSymbol_->castEnum
|
||||
| IEvTimeDuration(_) => svtTimeDuration_->castEnum
|
||||
| IEvType(_) => svtType_->castEnum
|
||||
| IEvTypeIdentifier(_) => svtTypeIdentifier_->castEnum
|
||||
| IEvVoid => svtVoid_->castEnum
|
||||
}
|
||||
|
||||
@genType
|
|
@ -1,6 +1,5 @@
|
|||
open ForTS__Types
|
||||
// Note: Internal representation will not be an array in the future.
|
||||
// Thus we still to have a conversion
|
||||
type squiggleValue = ForTS_SquiggleValue.squiggleValue
|
||||
@genType type squiggleValue_Array = ForTS_SquiggleValue.squiggleValue_Array //re-export recursive type
|
||||
|
||||
@genType
|
||||
let getValues = (v: squiggleValue_Array): array<squiggleValue> =>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
@genType type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambdaDeclaration //re-export
|
|
@ -0,0 +1 @@
|
|||
@genType type squiggleValue_Distribution = ForTS_Distribution.distribution
|
|
@ -0,0 +1 @@
|
|||
@genType type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue //re-export
|
|
@ -1,4 +1,5 @@
|
|||
open ForTS__Types
|
||||
type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
|
||||
@genType type squiggleValue_Module = ForTS_SquiggleValue.squiggleValue_Module //re-export recursive type
|
||||
|
||||
@genType
|
||||
let getKeyValuePairs = (v: squiggleValue_Module): array<(string, squiggleValue)> =>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
open ForTS__Types
|
||||
type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
|
||||
@genType type squiggleValue_Record = ForTS_SquiggleValue.squiggleValue_Record //re-export recursive type
|
||||
|
||||
@genType
|
||||
let getKeyValuePairs = (value: squiggleValue_Record): array<(string, squiggleValue)> =>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
open ForTS__Types
|
||||
type squiggleValue = ForTS_SquiggleValue.squiggleValue //use
|
||||
@genType type squiggleValue_Type = ForTS_SquiggleValue.squiggleValue_Type //re-export recursive type
|
||||
|
||||
@genType
|
||||
let getKeyValuePairs = (value: squiggleValue_Type): array<(string, squiggleValue)> =>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
export enum squiggleValueTag {
|
||||
SvtArray,
|
||||
SvtArrayString,
|
||||
SvtBool,
|
||||
SvtCall,
|
||||
SvtDate,
|
||||
SvtDeclaration,
|
||||
SvtDistribution,
|
||||
SvtLambda,
|
||||
SvtModule,
|
||||
SvtNumber,
|
||||
SvtRecord,
|
||||
SvtString,
|
||||
SvtSymbol,
|
||||
SvtTimeDuration,
|
||||
SvtType,
|
||||
SvtTypeIdentifier,
|
||||
SvtVoid,
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
enum SquiggleValueTag {
|
||||
SvtArray,
|
||||
SvtArrayString,
|
||||
SvtBool,
|
||||
SvtCall,
|
||||
SvtDate,
|
||||
SvtDeclaration,
|
||||
SvtDistribution,
|
||||
SvtLambda,
|
||||
SvtModule,
|
||||
SvtNumber,
|
||||
SvtRecord,
|
||||
SvtString,
|
||||
SvtSymbol,
|
||||
SvtTimeDuration,
|
||||
SvtType,
|
||||
SvtTypeIdentifier,
|
||||
SvtVoid,
|
||||
}
|
|
@ -1,31 +1,24 @@
|
|||
@genType.opaque type result_<'a, 'e> = result<'a, 'e>
|
||||
@genType.opaque type reducerErrorValue = Reducer_ErrorValue.errorValue
|
||||
@genType type syntaxErrorLocation = Reducer_ErrorValue.syntaxErrorLocation
|
||||
@genType type result_<'a, 'e> = ForTS_Result.result_<'a, 'e> //re-export
|
||||
@genType type result<'a, 'e> = ForTS_Result.result<'a, 'e> //re-export
|
||||
@genType type reducerErrorValue = ForTS_Reducer_ErrorValue.reducerErrorValue //re-export
|
||||
@genType type syntaxErrorLocation = ForTS_Reducer_ErrorValue.syntaxErrorLocation //re-export
|
||||
|
||||
/*
|
||||
The reason this is not ExpressionValue is that ExpressionValue is becoming a parametric type
|
||||
to allow expressions for different domains.
|
||||
So we rename it right away not cause a compatibility problem
|
||||
*/
|
||||
@genType.opaque type squiggleValue = ReducerInterface_InternalExpressionValue.t
|
||||
@genType.opaque type squiggleValue_Array = ReducerInterface_InternalExpressionValue.squiggleArray
|
||||
@genType.opaque
|
||||
type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambdaDeclaration
|
||||
@genType.opaque type squiggleValue_Module = ReducerInterface_InternalExpressionValue.nameSpace
|
||||
@genType.opaque type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue
|
||||
@genType.opaque type squiggleValue_Record = ReducerInterface_InternalExpressionValue.map
|
||||
@genType.opaque type squiggleValue_Type = ReducerInterface_InternalExpressionValue.map
|
||||
|
||||
@genType.opaque type reducerProject = ReducerProject_T.t
|
||||
@genType type reducerProject = ForTS_ReducerProject.reducerProject //re-export
|
||||
@genType type squiggleValue = ForTS_SquiggleValue.squiggleValue //re-export
|
||||
@genType type squiggleValue_Array = ForTS_SquiggleValue_Array.squiggleValue_Array //re-export
|
||||
@genType type squiggleValue_Declaration = ForTS_SquiggleValue_Declaration.squiggleValue_Declaration //re-export
|
||||
@genType type squiggleValue_Lambda = ForTS_SquiggleValue_Lambda.squiggleValue_Lambda //re-export
|
||||
@genType type squiggleValue_Module = ForTS_SquiggleValue_Module.squiggleValue_Module //re-export
|
||||
@genType type squiggleValue_Record = ForTS_SquiggleValue_Record.squiggleValue_Record //re-export
|
||||
@genType type squiggleValue_Type = ForTS_SquiggleValue_Type.squiggleValue_Type //re-export
|
||||
|
||||
/* Distribution related */
|
||||
@genType type environment = GenericDist.env
|
||||
@genType.opaque
|
||||
type distributionError = DistributionTypes.error
|
||||
@genType type squiggleValue_Distribution = ForTS_Distribution.distribution //re-export
|
||||
@genType type distribution = squiggleValue_Distribution //candid
|
||||
@genType type distributionError = ForTS_Distribution_Error.distributionError //re-export
|
||||
@genType type environment = ForTS_Distribution_Environment.environment //re-export
|
||||
|
||||
// From now on one should introduce any new types as opaque types.
|
||||
// Exception: The intended type is really a JavaScript type or record. Not by coincidence
|
||||
// Already existing open types we cannot dive in now
|
||||
@genType type squiggleValue_Distribution = DistributionTypes.genericDist
|
||||
@genType type pointSetDistribution = ForTS_Distribution_PointSetDistribution.pointSetDistribution //re-export
|
||||
@genType type sampleSetDistribution = ForTS_Distribution_SampleSetDistribution.sampleSetDistribution //re-export
|
||||
@genType type symbolicDistribution = ForTS_Distribution_SymbolicDistribution.symbolicDistribution //re-export
|
||||
|
||||
//TODO: index.ts should use types from here or vice versa
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
open ForTS__Types
|
||||
|
||||
@genType
|
||||
let defaultEnvironment: environment = DistributionOperation.defaultEnv
|
|
@ -2,6 +2,7 @@
|
|||
@gentype.import("peggy") @genType.as("LocationRange")
|
||||
type syntaxErrorLocation
|
||||
|
||||
@genType.opaque
|
||||
type errorValue =
|
||||
| REArityError(option<string>, int, int)
|
||||
| REArrayIndexNotFound(string, int)
|
||||
|
|
|
@ -5,6 +5,7 @@ type environment = GenericDist.env
|
|||
|
||||
let defaultEnvironment: environment = DistributionOperation.defaultEnv
|
||||
|
||||
@genType.opaque
|
||||
type rec t =
|
||||
| IEvArray(array<t>) // FIXME: Convert to MapInt
|
||||
| IEvArrayString(array<string>)
|
||||
|
@ -23,17 +24,17 @@ type rec t =
|
|||
| IEvType(map)
|
||||
| IEvTypeIdentifier(string)
|
||||
| IEvVoid
|
||||
and squiggleArray = array<t>
|
||||
and map = Belt.Map.String.t<t>
|
||||
and nameSpace = NameSpace(Belt.Map.String.t<t>)
|
||||
@genType.opaque and squiggleArray = array<t>
|
||||
@genType.opaque and map = Belt.Map.String.t<t>
|
||||
@genType.opaque and nameSpace = NameSpace(Belt.Map.String.t<t>)
|
||||
@genType.opaque
|
||||
and lambdaValue = {
|
||||
parameters: array<string>,
|
||||
context: nameSpace,
|
||||
body: internalCode,
|
||||
}
|
||||
and lambdaDeclaration = Declaration.declaration<lambdaValue>
|
||||
@genType.opaque and lambdaDeclaration = Declaration.declaration<lambdaValue>
|
||||
|
||||
type squiggleMap = map
|
||||
type internalExpressionValue = t
|
||||
|
||||
type functionCall = (string, array<t>)
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
"use strict";
|
||||
|
||||
function peg$subclass(child, parent) {
|
||||
function C() { this.constructor = child; }
|
||||
function C() {
|
||||
this.constructor = child;
|
||||
}
|
||||
C.prototype = parent.prototype;
|
||||
child.prototype = new C();
|
||||
}
|
||||
|
@ -27,13 +29,15 @@ peg$subclass(peg$SyntaxError, Error);
|
|||
|
||||
function peg$padEnd(str, targetLength, padString) {
|
||||
padString = padString || " ";
|
||||
if (str.length > targetLength) { return str; }
|
||||
if (str.length > targetLength) {
|
||||
return str;
|
||||
}
|
||||
targetLength -= str.length;
|
||||
padString += padString.repeat(targetLength);
|
||||
return str + padString.slice(0, targetLength);
|
||||
}
|
||||
|
||||
peg$SyntaxError.prototype.format = function(sources) {
|
||||
peg$SyntaxError.prototype.format = function (sources) {
|
||||
var str = "Error: " + this.message;
|
||||
if (this.location) {
|
||||
var src = null;
|
||||
|
@ -48,15 +52,24 @@ peg$SyntaxError.prototype.format = function(sources) {
|
|||
var loc = this.location.source + ":" + s.line + ":" + s.column;
|
||||
if (src) {
|
||||
var e = this.location.end;
|
||||
var filler = peg$padEnd("", s.line.toString().length, ' ');
|
||||
var filler = peg$padEnd("", s.line.toString().length, " ");
|
||||
var line = src[s.line - 1];
|
||||
var last = s.line === e.line ? e.column : line.length + 1;
|
||||
var hatLen = (last - s.column) || 1;
|
||||
str += "\n --> " + loc + "\n"
|
||||
+ filler + " |\n"
|
||||
+ s.line + " | " + line + "\n"
|
||||
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
|
||||
+ peg$padEnd("", hatLen, "^");
|
||||
var hatLen = last - s.column || 1;
|
||||
str +=
|
||||
"\n --> " +
|
||||
loc +
|
||||
"\n" +
|
||||
filler +
|
||||
" |\n" +
|
||||
s.line +
|
||||
" | " +
|
||||
line +
|
||||
"\n" +
|
||||
filler +
|
||||
" | " +
|
||||
peg$padEnd("", s.column - 1, " ") +
|
||||
peg$padEnd("", hatLen, "^");
|
||||
} else {
|
||||
str += "\n at " + loc;
|
||||
}
|
||||
|
@ -64,33 +77,35 @@ peg$SyntaxError.prototype.format = function(sources) {
|
|||
return str;
|
||||
};
|
||||
|
||||
peg$SyntaxError.buildMessage = function(expected, found) {
|
||||
peg$SyntaxError.buildMessage = function (expected, found) {
|
||||
var DESCRIBE_EXPECTATION_FNS = {
|
||||
literal: function(expectation) {
|
||||
return "\"" + literalEscape(expectation.text) + "\"";
|
||||
literal: function (expectation) {
|
||||
return '"' + literalEscape(expectation.text) + '"';
|
||||
},
|
||||
|
||||
class: function(expectation) {
|
||||
var escapedParts = expectation.parts.map(function(part) {
|
||||
class: function (expectation) {
|
||||
var escapedParts = expectation.parts.map(function (part) {
|
||||
return Array.isArray(part)
|
||||
? classEscape(part[0]) + "-" + classEscape(part[1])
|
||||
: classEscape(part);
|
||||
});
|
||||
|
||||
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
||||
return (
|
||||
"[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"
|
||||
);
|
||||
},
|
||||
|
||||
any: function() {
|
||||
any: function () {
|
||||
return "any character";
|
||||
},
|
||||
|
||||
end: function() {
|
||||
end: function () {
|
||||
return "end of input";
|
||||
},
|
||||
|
||||
other: function(expectation) {
|
||||
other: function (expectation) {
|
||||
return expectation.description;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function hex(ch) {
|
||||
|
@ -100,13 +115,17 @@ peg$SyntaxError.buildMessage = function(expected, found) {
|
|||
function literalEscape(s) {
|
||||
return s
|
||||
.replace(/\\/g, "\\\\")
|
||||
.replace(/"/g, "\\\"")
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\0/g, "\\0")
|
||||
.replace(/\t/g, "\\t")
|
||||
.replace(/\n/g, "\\n")
|
||||
.replace(/\r/g, "\\r")
|
||||
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
|
||||
.replace(/[\x00-\x0F]/g, function (ch) {
|
||||
return "\\x0" + hex(ch);
|
||||
})
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
||||
return "\\x" + hex(ch);
|
||||
});
|
||||
}
|
||||
|
||||
function classEscape(s) {
|
||||
|
@ -119,8 +138,12 @@ peg$SyntaxError.buildMessage = function(expected, found) {
|
|||
.replace(/\t/g, "\\t")
|
||||
.replace(/\n/g, "\\n")
|
||||
.replace(/\r/g, "\\r")
|
||||
.replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
|
||||
.replace(/[\x00-\x0F]/g, function (ch) {
|
||||
return "\\x0" + hex(ch);
|
||||
})
|
||||
.replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
||||
return "\\x" + hex(ch);
|
||||
});
|
||||
}
|
||||
|
||||
function describeExpectation(expectation) {
|
||||
|
@ -151,17 +174,25 @@ peg$SyntaxError.buildMessage = function(expected, found) {
|
|||
return descriptions[0] + " or " + descriptions[1];
|
||||
|
||||
default:
|
||||
return descriptions.slice(0, -1).join(", ")
|
||||
+ ", or "
|
||||
+ descriptions[descriptions.length - 1];
|
||||
return (
|
||||
descriptions.slice(0, -1).join(", ") +
|
||||
", or " +
|
||||
descriptions[descriptions.length - 1]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function describeFound(found) {
|
||||
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
||||
return found ? '"' + literalEscape(found) + '"' : "end of input";
|
||||
}
|
||||
|
||||
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
||||
return (
|
||||
"Expected " +
|
||||
describeExpected(expected) +
|
||||
" but " +
|
||||
describeFound(found) +
|
||||
" found."
|
||||
);
|
||||
};
|
||||
|
||||
function peg$parse(input, options) {
|
||||
|
@ -175,7 +206,7 @@ function peg$parse(input, options) {
|
|||
|
||||
var peg$c0 = "#include";
|
||||
var peg$c1 = "'";
|
||||
var peg$c2 = "\"";
|
||||
var peg$c2 = '"';
|
||||
var peg$c3 = "//";
|
||||
var peg$c4 = "/*";
|
||||
var peg$c5 = "*/";
|
||||
|
@ -191,8 +222,8 @@ function peg$parse(input, options) {
|
|||
var peg$e1 = peg$otherExpectation("string");
|
||||
var peg$e2 = peg$literalExpectation("'", false);
|
||||
var peg$e3 = peg$classExpectation(["'"], true, false);
|
||||
var peg$e4 = peg$literalExpectation("\"", false);
|
||||
var peg$e5 = peg$classExpectation(["\""], true, false);
|
||||
var peg$e4 = peg$literalExpectation('"', false);
|
||||
var peg$e5 = peg$classExpectation(['"'], true, false);
|
||||
var peg$e6 = peg$literalExpectation("//", false);
|
||||
var peg$e7 = peg$literalExpectation("/*", false);
|
||||
var peg$e8 = peg$classExpectation(["*"], true, false);
|
||||
|
@ -203,12 +234,24 @@ function peg$parse(input, options) {
|
|||
var peg$e13 = peg$classExpectation(["\n", "\r"], false, false);
|
||||
var peg$e14 = peg$classExpectation(["\r", "\n"], true, false);
|
||||
|
||||
var peg$f0 = function(head, tail) {return [head, ...tail].filter( e => e != '');};
|
||||
var peg$f1 = function() {return [];};
|
||||
var peg$f2 = function(characters) {return characters.join('');};
|
||||
var peg$f3 = function(characters) {return characters.join('');};
|
||||
var peg$f4 = function() { return '';};
|
||||
var peg$f5 = function() { return '';};
|
||||
var peg$f0 = function (head, tail) {
|
||||
return [head, ...tail].filter((e) => e != "");
|
||||
};
|
||||
var peg$f1 = function () {
|
||||
return [];
|
||||
};
|
||||
var peg$f2 = function (characters) {
|
||||
return characters.join("");
|
||||
};
|
||||
var peg$f3 = function (characters) {
|
||||
return characters.join("");
|
||||
};
|
||||
var peg$f4 = function () {
|
||||
return "";
|
||||
};
|
||||
var peg$f5 = function () {
|
||||
return "";
|
||||
};
|
||||
var peg$currPos = 0;
|
||||
var peg$savedPos = 0;
|
||||
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
||||
|
@ -222,7 +265,9 @@ function peg$parse(input, options) {
|
|||
|
||||
if ("startRule" in options) {
|
||||
if (!(options.startRule in peg$startRuleFunctions)) {
|
||||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
||||
throw new Error(
|
||||
"Can't start parsing from rule \"" + options.startRule + '".'
|
||||
);
|
||||
}
|
||||
|
||||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
||||
|
@ -240,7 +285,7 @@ function peg$parse(input, options) {
|
|||
return {
|
||||
source: peg$source,
|
||||
start: peg$savedPos,
|
||||
end: peg$currPos
|
||||
end: peg$currPos,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -249,7 +294,8 @@ function peg$parse(input, options) {
|
|||
}
|
||||
|
||||
function expected(description, location) {
|
||||
location = location !== undefined
|
||||
location =
|
||||
location !== undefined
|
||||
? location
|
||||
: peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
|
||||
|
@ -261,7 +307,8 @@ function peg$parse(input, options) {
|
|||
}
|
||||
|
||||
function error(message, location) {
|
||||
location = location !== undefined
|
||||
location =
|
||||
location !== undefined
|
||||
? location
|
||||
: peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
|
||||
|
@ -273,7 +320,12 @@ function peg$parse(input, options) {
|
|||
}
|
||||
|
||||
function peg$classExpectation(parts, inverted, ignoreCase) {
|
||||
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
|
||||
return {
|
||||
type: "class",
|
||||
parts: parts,
|
||||
inverted: inverted,
|
||||
ignoreCase: ignoreCase,
|
||||
};
|
||||
}
|
||||
|
||||
function peg$anyExpectation() {
|
||||
|
@ -303,7 +355,7 @@ function peg$parse(input, options) {
|
|||
details = peg$posDetailsCache[p];
|
||||
details = {
|
||||
line: details.line,
|
||||
column: details.column
|
||||
column: details.column,
|
||||
};
|
||||
|
||||
while (p < pos) {
|
||||
|
@ -332,18 +384,20 @@ function peg$parse(input, options) {
|
|||
start: {
|
||||
offset: startPos,
|
||||
line: startPosDetails.line,
|
||||
column: startPosDetails.column
|
||||
column: startPosDetails.column,
|
||||
},
|
||||
end: {
|
||||
offset: endPos,
|
||||
line: endPosDetails.line,
|
||||
column: endPosDetails.column
|
||||
}
|
||||
column: endPosDetails.column,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function peg$fail(expected) {
|
||||
if (peg$currPos < peg$maxFailPos) { return; }
|
||||
if (peg$currPos < peg$maxFailPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (peg$currPos > peg$maxFailPos) {
|
||||
peg$maxFailPos = peg$currPos;
|
||||
|
@ -501,7 +555,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos += 8;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e0);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = [];
|
||||
|
@ -559,7 +615,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e2); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e2);
|
||||
}
|
||||
}
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = [];
|
||||
|
@ -568,7 +626,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e3); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e3);
|
||||
}
|
||||
}
|
||||
while (s4 !== peg$FAILED) {
|
||||
s3.push(s4);
|
||||
|
@ -577,7 +637,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e3); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e3);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input.charCodeAt(peg$currPos) === 39) {
|
||||
|
@ -585,7 +647,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e2); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e2);
|
||||
}
|
||||
}
|
||||
if (s4 !== peg$FAILED) {
|
||||
s1 = s3;
|
||||
|
@ -610,7 +674,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e4); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e4);
|
||||
}
|
||||
}
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = [];
|
||||
|
@ -619,7 +685,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e5); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e5);
|
||||
}
|
||||
}
|
||||
while (s4 !== peg$FAILED) {
|
||||
s3.push(s4);
|
||||
|
@ -628,7 +696,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e5); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e5);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input.charCodeAt(peg$currPos) === 34) {
|
||||
|
@ -636,7 +706,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s4 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e4); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e4);
|
||||
}
|
||||
}
|
||||
if (s4 !== peg$FAILED) {
|
||||
s1 = s3;
|
||||
|
@ -657,7 +729,9 @@ function peg$parse(input, options) {
|
|||
peg$silentFails--;
|
||||
if (s0 === peg$FAILED) {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e1);
|
||||
}
|
||||
}
|
||||
|
||||
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
||||
|
@ -719,7 +793,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos += 2;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e6); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e6);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = [];
|
||||
|
@ -758,7 +834,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos += 2;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e7); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e7);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = [];
|
||||
|
@ -767,7 +845,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e8); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e8);
|
||||
}
|
||||
}
|
||||
while (s3 !== peg$FAILED) {
|
||||
s2.push(s3);
|
||||
|
@ -776,7 +856,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e8); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e8);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input.substr(peg$currPos, 2) === peg$c5) {
|
||||
|
@ -784,7 +866,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos += 2;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e9); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e9);
|
||||
}
|
||||
}
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
|
@ -821,12 +905,16 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s0 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e11); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e11);
|
||||
}
|
||||
}
|
||||
peg$silentFails--;
|
||||
if (s0 === peg$FAILED) {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e10); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e10);
|
||||
}
|
||||
}
|
||||
|
||||
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
||||
|
@ -852,12 +940,16 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s0 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e13); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e13);
|
||||
}
|
||||
}
|
||||
peg$silentFails--;
|
||||
if (s0 === peg$FAILED) {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e12); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e12);
|
||||
}
|
||||
}
|
||||
|
||||
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
||||
|
@ -882,7 +974,9 @@ function peg$parse(input, options) {
|
|||
peg$currPos++;
|
||||
} else {
|
||||
s0 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$e14);
|
||||
}
|
||||
}
|
||||
|
||||
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
||||
|
@ -911,5 +1005,5 @@ function peg$parse(input, options) {
|
|||
|
||||
module.exports = {
|
||||
SyntaxError: peg$SyntaxError,
|
||||
parse: peg$parse
|
||||
parse: peg$parse,
|
||||
};
|
||||
|
|
|
@ -2,7 +2,10 @@ module ProjectItem = ReducerProject_ProjectItem
|
|||
module ExpressionT = Reducer_Expression_T
|
||||
module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
|
||||
|
||||
@genType.opaque
|
||||
type project = {"tag": string}
|
||||
//re-export
|
||||
@genType
|
||||
type t = project
|
||||
|
||||
module Private = {
|
||||
|
|
|
@ -8,28 +8,17 @@ would be preferable.
|
|||
The below few seem to work fine. In the future there's definitely more work to do here.
|
||||
*/
|
||||
|
||||
@genType
|
||||
type samplingParams = environment
|
||||
// For backwards compatibility:
|
||||
//Alternatives if one wants to keep the old habits
|
||||
@genType type samplingParams = environment
|
||||
@genType type squiggleValue_Dist = squiggleValue_Distribution //alternative
|
||||
@genType type genericDist = squiggleValue_Distribution //alternative
|
||||
@genType type sampleSetDist = sampleSetDistribution //alternative
|
||||
@genType type symbolicDist = symbolicDistribution //alternative
|
||||
@genType type resultDist = result_<distribution, distributionError> //alternative
|
||||
@genType type resultFloat = result_<float, distributionError> //alternative
|
||||
@genType type resultString = result_<string, distributionError> //alternative
|
||||
|
||||
@genType
|
||||
type genericDist = squiggleValue_Distribution
|
||||
|
||||
@genType
|
||||
type sampleSetDist = SampleSetDist.t
|
||||
|
||||
@genType
|
||||
type symbolicDist = SymbolicDistTypes.symbolicDist
|
||||
|
||||
@genType
|
||||
type resultDist = result_<genericDist, distributionError>
|
||||
|
||||
@genType
|
||||
type resultFloat = result_<float, distributionError>
|
||||
|
||||
@genType
|
||||
type resultString = result_<string, distributionError>
|
||||
|
||||
//TODO: ForTS Interface module candid
|
||||
@genType
|
||||
let makeSampleSetDist: array<float> => result_<
|
||||
sampleSetDist,
|
||||
|
@ -55,15 +44,15 @@ type discreteShape = PointSetTypes.discreteShape
|
|||
@genType
|
||||
type continuousShape = PointSetTypes.continuousShape
|
||||
|
||||
// ForTS_Distributions_Error.toString
|
||||
@genType
|
||||
let distributionErrorToString = ForTS_Distribution_Error.toString
|
||||
|
||||
@genType
|
||||
let defaultSamplingEnv = ForTS_Distribution.defaultEnvironment
|
||||
|
||||
// Umur: opaqe types
|
||||
// @genType
|
||||
// let distributionErrorToString = DistributionTypes.Error.toString
|
||||
// type declarationArg = Declaration.arg
|
||||
|
||||
@genType
|
||||
let defaultSamplingEnv = DistributionOperation.defaultEnv
|
||||
|
||||
@genType
|
||||
type declarationArg = Declaration.arg
|
||||
|
||||
@genType
|
||||
type declaration<'a> = Declaration.declaration<'a>
|
||||
// @genType
|
||||
// type declaration<'a> = Declaration.declaration<'a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user