From cc8e12c152e4228c7d0394f93ed80940533f4063 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 28 Nov 2024 19:39:23 -0600 Subject: [PATCH] ^+ --- priv/static/squared_away.mjs | 30 ++++--------------- .../squared_away_lang/scanner.gleam | 3 +- .../squared_away_lang/scanner/token.gleam | 2 ++ .../typechecker/typed_expr.gleam | 2 +- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/priv/static/squared_away.mjs b/priv/static/squared_away.mjs index c9cca87..0208a5b 100644 --- a/priv/static/squared_away.mjs +++ b/priv/static/squared_away.mjs @@ -1179,15 +1179,6 @@ function trim_left(string3) { function trim_right(string3) { return string3.replace(right_trim_regex, ""); } -function print_debug(string3) { - if (typeof process === "object" && process.stderr?.write) { - process.stderr.write(string3 + "\n"); - } else if (typeof Deno === "object") { - Deno.stderr.writeSync(new TextEncoder().encode(string3 + "\n")); - } else { - console.log(string3); - } -} function ceiling(float3) { return Math.ceil(float3); } @@ -2733,14 +2724,6 @@ function guard(requirement, consequence, alternative) { } } -// build/dev/javascript/gleam_stdlib/gleam/io.mjs -function debug(term) { - let _pipe = term; - let _pipe$1 = inspect2(_pipe); - print_debug(_pipe$1); - return term; -} - // build/dev/javascript/lustre/lustre/effect.mjs var Effect = class extends CustomType { constructor(all) { @@ -5230,7 +5213,7 @@ function do_to_string2(te) { rhs ); } else if (te instanceof BuiltinSum2) { - return "sum"; + return "^+"; } else if (te instanceof BuiltinAvg) { return "avg"; } else { @@ -7038,8 +7021,8 @@ function do_scan(loop$src, loop$acc) { let rest = src.slice(6); loop$src = trim_left2(rest); loop$acc = prepend(new MustBe2(), acc); - } else if (src.startsWith("sum")) { - let rest = src.slice(3); + } else if (src.startsWith("^+")) { + let rest = src.slice(2); loop$src = trim_left2(rest); loop$acc = prepend(new BuiltinSum3(new None()), acc); } else if (src.startsWith("avg")) { @@ -8635,7 +8618,6 @@ function update(model, msg) { } else if (msg instanceof UserShiftPressedArrowDown) { let cell = msg.cell; let maybe_cell_below = cell_underneath(model.src_grid, cell); - debug(get4(model.type_checked_grid, cell)); if (!maybe_cell_below.isOk() && !maybe_cell_below[0]) { return [model, none()]; } else { @@ -8655,7 +8637,7 @@ function update(model, msg) { throw makeError( "let_assert", "squared_away", - 334, + 333, "", "Pattern match failed, no pattern matched the value.", { value: maybe_expr } @@ -8670,7 +8652,7 @@ function update(model, msg) { throw makeError( "let_assert", "squared_away", - 339, + 338, "", "Pattern match failed, no pattern matched the value.", { value: $ } @@ -8697,7 +8679,7 @@ function update(model, msg) { throw makeError( "let_assert", "squared_away", - 358, + 357, "", "Pattern match failed, no pattern matched the value.", { value: $1 } diff --git a/src/squared_away/squared_away_lang/scanner.gleam b/src/squared_away/squared_away_lang/scanner.gleam index ccae987..a021ffd 100644 --- a/src/squared_away/squared_away_lang/scanner.gleam +++ b/src/squared_away/squared_away_lang/scanner.gleam @@ -94,13 +94,12 @@ fn do_scan( // Builtins "mustbe" <> rest -> do_scan(string.trim_left(rest), [token.MustBe, ..acc]) - "sum" <> rest -> + "^+" <> rest -> do_scan(string.trim_left(rest), [token.BuiltinSum(option.None), ..acc]) "avg" <> rest -> do_scan(string.trim_left(rest), [token.BuiltinAvg(option.None), ..acc]) "min" <> rest -> do_scan(string.trim_left(rest), [token.Minimum, ..acc]) - // Operators "&&" <> rest -> do_scan(string.trim_left(rest), [token.And, ..acc]) "||" <> rest -> do_scan(string.trim_left(rest), [token.Or, ..acc]) "**" <> rest -> do_scan(string.trim_left(rest), [token.StarStar, ..acc]) diff --git a/src/squared_away/squared_away_lang/scanner/token.gleam b/src/squared_away/squared_away_lang/scanner/token.gleam index 1215b69..1e1991a 100644 --- a/src/squared_away/squared_away_lang/scanner/token.gleam +++ b/src/squared_away/squared_away_lang/scanner/token.gleam @@ -56,4 +56,6 @@ pub type Token { BuiltinAvg(key: option.Option(grid.GridKey)) MustBe Minimum + + UpAnglePlus } diff --git a/src/squared_away/squared_away_lang/typechecker/typed_expr.gleam b/src/squared_away/squared_away_lang/typechecker/typed_expr.gleam index ebe2701..cfb12f2 100644 --- a/src/squared_away/squared_away_lang/typechecker/typed_expr.gleam +++ b/src/squared_away/squared_away_lang/typechecker/typed_expr.gleam @@ -133,7 +133,7 @@ fn do_to_string(te: TypedExpr) -> String { <> expr.binary_to_string(bop) <> " " <> do_to_string(rhs) - BuiltinSum(_, _) -> "sum" + BuiltinSum(_, _) -> "^+" BuiltinAvg(_, _) -> "avg" UsdLiteral(_, dollars) -> { let str = "$" <> rational.to_string(dollars, 100, False)