Skip to content

Commit

Permalink
remove columns and rows from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Sep 2, 2024
1 parent 6fb00af commit 0223429
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 96 deletions.
14 changes: 2 additions & 12 deletions squared_away/src/squared_away.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ fn update(model: Model, msg: Msg) -> #(Model, effect.Effect(Msg)) {
fn view(model: Model) -> element.Element(Msg) {
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |> string.to_graphemes

let columns = [
html.th([class("sticky-header")], [html.text("")]),
..list.map(alphabet, fn(l) {
html.th([class("sticky-header")], [html.text(l)])
})
]

let rows =
list.range(1, 100)
|> list.map(int.to_string)
Expand Down Expand Up @@ -132,15 +125,12 @@ fn view(model: Model) -> element.Element(Msg) {
})
})

html.tr([], [html.th([class("sticky-column")], t(row)), ..cells])
html.tr([], cells)
})

let grid =
html.div([class("table-container")], [
html.table([], [
html.thead([], [html.tr([], columns)]),
html.tbody([], rows),
]),
html.table([], [html.tbody([], rows)]),
])

let formula_mode_toggle =
Expand Down
7 changes: 0 additions & 7 deletions squared_away_lang/src/squared_away_lang/interpreter.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ pub fn interpret(
typed_expr.BooleanLiteral(_, b) -> Ok(value.Boolean(b))
typed_expr.IntegerLiteral(_, n) -> Ok(value.Integer(n))
typed_expr.FloatLiteral(_, f) -> Ok(value.FloatingPointNumber(f))
typed_expr.CellReference(_, cell_ref) -> {
let assert Ok(maybe_expr) = dict.get(env, cell_ref)
case maybe_expr {
Error(e) -> Error(e)
Ok(expr) -> interpret(env, expr)
}
}
typed_expr.UnaryOp(_, op, expr) -> {
use value <- result.try(interpret(env, expr))
case op, value {
Expand Down
6 changes: 0 additions & 6 deletions squared_away_lang/src/squared_away_lang/parser.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ fn do_parse(
Error(_) -> Ok(#(expr.FloatLiteral(f), rest))
}
}
[token.CellReference(key), ..rest] -> {
case try_parse_binary_ops(rest) {
Ok(#(op, rest)) -> Ok(#(op(expr.CellReference(key)), rest))
Error(_) -> Ok(#(expr.CellReference(key), rest))
}
}
[token.TrueToken, ..rest] -> {
case try_parse_binary_ops(rest) {
Ok(#(op, rest)) -> Ok(#(op(expr.BooleanLiteral(True)), rest))
Expand Down
1 change: 0 additions & 1 deletion squared_away_lang/src/squared_away_lang/parser/expr.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub type Expr {
Label(txt: String)
CrossLabel(row: String, col: String)
IntegerLiteral(n: Int)
CellReference(key: String)
BooleanLiteral(val: Bool)
UnaryOp(op: UnaryOpKind, expr: Expr)
BinaryOp(lhs: Expr, op: BinaryOpKind, rhs: Expr)
Expand Down
60 changes: 4 additions & 56 deletions squared_away_lang/src/squared_away_lang/scanner.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,10 @@ fn do_scan(
}

Error(_) -> {
case parse_cell_ref(src, "") {
Ok(#(cell_ref, rest)) ->
do_scan(string.trim_left(rest), [
token.CellReference(cell_ref),
..acc
])
_ -> {
case parse_identifier(src, "") {
Error(Nil) -> Error(scan_error.ScanError)
Ok(#(ident, rest)) ->
do_scan(string.trim_left(rest), [token.Label(ident), ..acc])
}
}
case parse_identifier(src, "") {
Error(Nil) -> Error(scan_error.ScanError)
Ok(#(ident, rest)) ->
do_scan(string.trim_left(rest), [token.Label(ident), ..acc])
}
}
}
Expand Down Expand Up @@ -148,49 +139,6 @@ fn parse_identifier(src: String, acc: String) -> Result(#(String, String), Nil)
}
}

fn parse_cell_ref(src: String, acc: String) -> Result(#(String, String), Nil) {
// A cell reference is a string of characters followed by a string of numbers (aka an int),
// so we can reuse the integer parsing at a slight runtime cost for now
case src {
"A" as l <> rest
| "B" as l <> rest
| "C" as l <> rest
| "D" as l <> rest
| "E" as l <> rest
| "F" as l <> rest
| "G" as l <> rest
| "H" as l <> rest
| "I" as l <> rest
| "J" as l <> rest
| "K" as l <> rest
| "L" as l <> rest
| "M" as l <> rest
| "N" as l <> rest
| "O" as l <> rest
| "P" as l <> rest
| "Q" as l <> rest
| "R" as l <> rest
| "S" as l <> rest
| "T" as l <> rest
| "U" as l <> rest
| "V" as l <> rest
| "W" as l <> rest
| "X" as l <> rest
| "Y" as l <> rest
| "Z" as l <> rest -> parse_cell_ref(rest, acc <> l)
_ -> {
case acc {
// Meaning we called this on something that didnt start with a capital letter
"" -> Error(Nil)
_ -> {
use #(n, rest) <- result.try(parse_integer(src, ""))
Ok(#(acc <> int.to_string(n), rest))
}
}
}
}
}

fn parse_integer(src: String, acc: String) -> Result(#(Int, String), Nil) {
case src {
"1" as x <> rest
Expand Down
3 changes: 0 additions & 3 deletions squared_away_lang/src/squared_away_lang/scanner/token.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pub type Token {
LParen
/// )
RParen
/// Cell Reference A3, XX532
CellReference(key: String)
/// Anything not starting with an = in a cell is a string literal
Label(String)
LabelDef(txt: String)
Underscore
Expand Down
10 changes: 0 additions & 10 deletions squared_away_lang/src/squared_away_lang/typechecker.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ pub fn typecheck(
use expr <- result.try(typecheck(env, inner))
Ok(typed_expr.Group(type_: expr.type_, expr:))
}
expr.CellReference(key) -> {
let assert Ok(ref_expr) = dict.get(env, key)
case ref_expr {
Ok(expr) -> {
use expr <- result.try(typecheck(env, expr))
Ok(typed_expr.CellReference(type_: expr.type_, key:))
}
Error(e) -> Error(e)
}
}
expr.UnaryOp(op, expr) -> {
use expr <- result.try(typecheck(env, expr))
case op, expr.type_ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub type TypedExpr {
CrossLabel(type_: typ.Typ, key: String)
LabelDef(type_: typ.Typ, txt: String)
IntegerLiteral(type_: typ.Typ, n: Int)
CellReference(type_: typ.Typ, key: String)
BooleanLiteral(type_: typ.Typ, b: Bool)
UnaryOp(type_: typ.Typ, op: expr.UnaryOpKind, expr: TypedExpr)
BinaryOp(
Expand Down

0 comments on commit 0223429

Please sign in to comment.