Skip to content

Commit

Permalink
^+
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Nov 29, 2024
1 parent 1c53334 commit cc8e12c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
30 changes: 6 additions & 24 deletions priv/static/squared_away.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 }
Expand All @@ -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: $ }
Expand All @@ -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 }
Expand Down
3 changes: 1 addition & 2 deletions src/squared_away/squared_away_lang/scanner.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions src/squared_away/squared_away_lang/scanner/token.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ pub type Token {
BuiltinAvg(key: option.Option(grid.GridKey))
MustBe
Minimum

UpAnglePlus
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cc8e12c

Please sign in to comment.