Make basic Signal Digith work
This commit is contained in:
parent
bf5eb54932
commit
c0198d419f
15 changed files with 464 additions and 73 deletions
|
|
@ -5,7 +5,7 @@ import { CodeEditor } from "src/ui/Component/CodeEditor";
|
|||
import { sourceText } from "src/lang/parser/source_text";
|
||||
import { Program } from "src/lang/program";
|
||||
import { V, Validation, letValidate } from "src/ui/validation";
|
||||
import { validateExprRaw, validateParamsRaw } from "./Helpers";
|
||||
import { validateExprRaw, validateParamsRaw } from "src/ui/validation/helpers";
|
||||
import { updateDigith } from "src/ui/Scrowl/scrowlStore";
|
||||
import { DigithError } from "src/ui/Digith/DigithError";
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ export function FunctionDigith(props: { function: Digith.Function }) {
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<div class="grid">
|
||||
<div>
|
||||
<label>
|
||||
Name
|
||||
<input
|
||||
|
|
@ -131,7 +131,6 @@ export function FunctionDigith(props: { function: Digith.Function }) {
|
|||
<button
|
||||
onClick={handleRedefine}
|
||||
disabled={!isDirty()}
|
||||
class={isDirty() ? "" : "secondary outline"}
|
||||
>
|
||||
Redefine
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import { ParseError, parseExpr, parseFunctionName, parseFunctionParameters } from "src/lang/parser/parser";
|
||||
import { sourceText } from "src/lang/parser/source_text";
|
||||
import { Expr, FunctionName, ProductPattern } from "src/lang/expr";
|
||||
import { V } from "src/ui/validation";
|
||||
|
||||
// === Parser wrappers ===
|
||||
export function validateNameRaw(input: string): V<FunctionName, ParseError> {
|
||||
const src = sourceText(input);
|
||||
const res = parseFunctionName(src);
|
||||
return res.tag === "ok" ? V.ok(res.value) : V.errors([res.error]);
|
||||
};
|
||||
|
||||
export function validateParamsRaw(input: string): V<ProductPattern[], ParseError> {
|
||||
const src = sourceText(input);
|
||||
const res = parseFunctionParameters(src);
|
||||
return res.tag === "ok" ? V.ok(res.value) : V.errors([res.error]);
|
||||
};
|
||||
|
||||
export function validateExprRaw(input: string): V<Expr, ParseError> {
|
||||
const src = sourceText(input);
|
||||
const res = parseExpr(src);
|
||||
return res.tag === "ok" ? V.ok(res.value) : V.errors([res.error]);
|
||||
};
|
||||
|
||||
|
|
@ -5,12 +5,10 @@ import { CodeEditor } from "src/ui/Component/CodeEditor";
|
|||
import { sourceText } from "src/lang/parser/source_text";
|
||||
import { Program } from "src/lang/program";
|
||||
import { V, Validation, letValidate } from "src/ui/validation";
|
||||
import { validateExprRaw, validateNameRaw, validateParamsRaw } from "./Helpers";
|
||||
import { validateExprRaw, validateNameRaw, validateParamsRaw } from "src/ui/validation/helpers";
|
||||
import { spawnFunctionDigith } from "src/ui/Scrowl/scrowlStore";
|
||||
import { DigithError } from "src/ui/Digith/DigithError";
|
||||
|
||||
|
||||
|
||||
type Input = {
|
||||
raw_name: string,
|
||||
raw_params: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue