Commit graph

285 commits

Author SHA1 Message Date
Vincent Ambo
07d99a30e2 feat(tazjin/tverskoy): Enable redshift & geoclue2
... also nuke that Bluetooth headset daemon, it doesn't work anyways.

Change-Id: Iee884046a2bf2718767442ec62b2f731e14e39e8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2624
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 13:06:42 +00:00
Vincent Ambo
13a43a6392 feat(tazjin/tverskoy): Configure ephemeral home bind-mounts
Uses the impermanence module to configure the bind-mounts for the few
applications that are allowed to persist stuff between boots.

For now this setup uses ZFS rollbacks to get /home back into a clean
state, where the `tazjin-clean` snapshot is a partition with only the
`/home/tazjin` folder and the correct partitions on it.

This gives me enough scratch space to e.g. download stuff larger than
my RAM without accumulating state.

Change-Id: I7cdb2276f087ea62201690cb8b36ae074203f87c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2623
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 13:06:42 +00:00
Vincent Ambo
1fdf581e97 fix(tazjin/emacs): Ensure company is installed
I don't know where this went.

Change-Id: I82d27e273e38ffeffe683d6ff2236d383c7b1fcf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2622
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 00:55:58 +00:00
Vincent Ambo
e653366153 feat(tazjin/tverskoy): Configure impermanence module
This module is responsible for mounting persistent storage into the
ephemeral root disk of this machine.

Currently only very basic configuration and data are retained, and
hopefully that won't change.

Change-Id: If800cbee60b7b3c5b8c457b9b332a0c05c33f20e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2621
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 00:55:58 +00:00
Vincent Ambo
6e94b3ca2f feat(tazjin/nixos): Initial check in of new host (tverskoy)
This is my new X13 AMD Thinkpad, on which many fun things will be done.

Change-Id: I4de114a8c5ebb37d2f4844f407d2dc0e7cc9557e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2620
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 00:55:58 +00:00
Vincent Ambo
8baa4a9595 fix(tazjin/emacs): Use ace-window from MELPA instead of ELPA
This package definition is broken for ELPA in nixpkgs, but adisbladis
is working on it.

Change-Id: Ibe140a2daf7a3a294dae4c6340be33db05a47a44
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2619
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-21 00:55:58 +00:00
Vincent Ambo
eb110e9d7c fix(tazjin/emacs): Set notmuch custom variables through :custom
It seems like some of them end up file-local anyways, and the explicit
call to `custom-set-variables` in mail-setup.el had seemingly no effect.

Change-Id: Iad5011b5f8348b1ca5973813995c9644ac85ddf5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2610
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-19 23:07:17 +00:00
sterni
90fdd7f23d chore(3p): bump NixOS channels to 2021-03-18
Making this a monthly service apparently.

Necessary changes:

* 3p: expose emacs27 instead of emacs26 which got removed
  users/tazjin/{camden, frog}: switch from emacs26 to emacs27

* 3p/lieer: google_api_python_client got renamed to
  google-api-python-client

Change-Id: I1011665d10eebc99990addbef6a8a6b000b93896
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2605
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
2021-03-19 14:00:50 +00:00
Vincent Ambo
e41bd6a82d fix(tazjin/emacs): Always show newest emails first
The default for this seems to have changed in a recent notmuch
release.

Change-Id: I1542b20c2e3edf72a3472c5277bce313c6df12b8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2595
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-06 11:53:16 +00:00
Vincent Ambo
4162186a19 feat(tazjin/rlox): Implement global variable access
This also includes a fix for an issue where the identifiers of
variables were pushed onto the stack, which is incorrect.

Change-Id: Id89b388268efad295f29978d767aa4b33c4ded14
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2594
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-06 11:52:00 +00:00
Vincent Ambo
29b2a54705 feat(tazjin/rlox): Implement global variable definition
identifier_str might look a bit overengineered, but we want to reuse
this bit of code and it needs a reference to the token from which to
pick the identifier.

The problem with this is that the token would be owned by self, but
the function needs to mutate (the interner), so this implementation is
the most straightforward way of acquiring and working with an
immutable reference to the token before interning the identifier.

Change-Id: I618ce8f789cb59b3a9c5b79a13111ea6d00b2424
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2592
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-06 11:52:00 +00:00
Vincent Ambo
b7b94335cc refactor(tazjin/rlox): Refactor Compiler::consume into a macro
Making this function a macro instead makes it possible to match
arbitrary token kinds, even the ones that carry data, without changing
the syntax too much.

Change-Id: I5cda9e36d6833bd9c259f7d4d8340db6e783b4e8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2593
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-06 11:52:00 +00:00
Vincent Ambo
822e5ae57f fix(tazjin/rlox): Resynchronise after panicking
Change-Id: I60939f7a2c523b6ca1e9782e58c97959da38cfff
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2591
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-06 11:52:00 +00:00
Vincent Ambo
ed3fce2b19 feat(tazjin/rlox): Implement expression statements
These aren't particularly useful without side effects, but one step at
a time.

This diverges slightly from the book, in that OpPop retains the last
value it "forgot" from the stack in a special field on the
interpreter.

This makes it possible to return values from expression statements,
which helps in cases where Lox is embedded as a scripting
language (please don't do this ever) or in tests.

Change-Id: Ided0bc04c6e80ddb23ba4693d61ac9e08b002d58
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2584
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-03 10:51:05 +00:00
Vincent Ambo
2cd77ea26d feat(tazjin/rlox): Add support for print statement
Change-Id: Ic3e7e722325c8784b848c0bcd573c2e51e123c40
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2583
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-03 10:50:39 +00:00
Vincent Ambo
432e7a7ddd feat(tazjin/rlox): Intern all string constants
This is again a step closer to the book, but there are some notable
differences:

* Only constants encountered by the compiler are interned, all other
  string operations (well, concatenation) happen with heap objects.

* OpReturn will always ensure that a returned string value is newly
  heap allocated and does not reference the interner.

Change-Id: If4f04309446e01b8ff2db51094e9710d465dbc50
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2582
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-02 19:48:46 +00:00
Vincent Ambo
bcea8e0d16 test(tazjin/rlox): Add simple string assertions
Change-Id: I6c60934d57170157d877e71cc87a97ab773342b5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2581
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-03-02 19:48:46 +00:00
Vincent Ambo
ef7a0da8cb feat(tazjin/rlox): Add a simple string interner
This is based on this matklad post:

https://matklad.github.io/2020/03/22/fast-simple-rust-interner.html

It's modified slightly to provide a safer interface and slightly more
readable implementation:

* interned string IDs are wrapped in a newtype that is not publicly
  constructible

* unsafe block is reduced to only the small scope in which it is
  needed

* lookup lifetime is pinned explicitly to make the intent clearer when
  reading this code

Change-Id: Ia3dae988f33f8e5e7d8dc0c1a9216914a945b036
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2578
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-01 21:09:37 +00:00
Vincent Ambo
6f600c8300 feat(tazjin/rlox): Add initial support for strings
... including concatenation.

This diverges significantly from the book, as I'm using std::String
instead of implementing the book's whole heap object management
system.

It's possible that Lox in Rust actually doesn't need a GC and the
ownership model works just fine.

Change-Id: I374a0461d627cfafc26b2b54bfefac8b7c574d00
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2577
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-03-01 21:09:37 +00:00
Vincent Ambo
369f504250 feat(tazjin/rlox): Implement comparison operators
Change-Id: I03b751db52a3bd502fb4fbda6e89cad087ccad74
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2575
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 14:36:40 +00:00
Vincent Ambo
c58fe2093e feat(tazjin/rlox): Implement equality operator
Change-Id: I5587a11646e228c5af4dc7ca6da026bb4a2592a6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2574
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 14:36:40 +00:00
Vincent Ambo
93c30b339c refactor(tazjin/rlox): Let binary_op! work on different types
This makes it possible to specify the input & output types of the
binary_op macro. If only one type is specified, it is assumed that the
input and output types are the same.

Change-Id: Idfcc9ba462db3976b69379b6693d091e1a525a3b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2573
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 14:36:40 +00:00
Vincent Ambo
2d9456d247 feat(tazjin/rlox): Implement unary negation operator
Change-Id: I9a5bd3581d4ed05371651697ec496341eb7971ae
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2572
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 14:36:40 +00:00
Vincent Ambo
47ffa80711 feat(tazjin/rlox): Support trivial literals in bytecode compiler
Adds support for true, false & nil. These each come with a new
separate opcode and are pushed directly on the stack.

Change-Id: I405b5b09496dcf99d514d3411c083e0834377167
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2571
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 14:36:40 +00:00
Vincent Ambo
127ef98486 refactor(tazjin/rlox): Represent VM values as enums
Introduces a new enum which represents the different types of possible
values, and modifies the rest of the existing code to wrap/unwrap
these enum variants correctly.

Notably in the vm module, a new macro has been introduced that makes
it possible to encode a type expectation and return a runtime error in
case of a type mismatch.

Change-Id: I325b5e31e395c62d8819ab2af6d398e1277333c0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2570
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 12:54:29 +00:00
Vincent Ambo
6b990a7571 test(tazjin/rlox): Add some tests for numerical operations
If I was adding any dependencies, this might be a good one for a
property-based test thing, but I'm not going to.

Change-Id: Ia801d041479d1a88c59ef9e0fe1460b3640382e3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2569
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00
Vincent Ambo
fd2139ce31 chore(tazjin/rlox): Add stack printing when 'disassemble' is on
Change-Id: I71ae83101002f8fead3fa6cbd4cb229a2d6e3902
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2568
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00
Vincent Ambo
47c1a9a280 fix(tazjin/rlox): Fix selection of next parser precedence rule
Without this fix we would keep parsing in the same precedence level
and get weird things like:

    10 - -10 + 10
    => 10

Change-Id: If2bed4569fbf566027011037165a9b3c09b7427c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2567
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00
Vincent Ambo
995d024f03 feat(tazjin/rlox): Wire up bytecode interpreter & print results
This makes the bytecode interpreter actually usable.

Change-Id: I24afc7ce461c6673dc42581378f6e14da7aece5c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2566
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00
Vincent Ambo
0c9a7de5be fix(tazjin/rlox): Fix identifier order in binary_op macro
Change-Id: I92253e875436bcb42732a157979a9d1e7ca0cd06
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2565
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-28 11:14:03 +00:00
Vincent Ambo
f3d00b84bb chore(tazjin/rlox): Fill in minor missing implementations
This should clean up everything in the way of actually running this
end-to-end.

Change-Id: Ie89d82472a458256a251a4fddc1c36d88d21f5f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2563
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 20:19:14 +00:00
Vincent Ambo
758730d25d feat(tazjin/rlox): Print compiled bytecode with disassemble feature
Change-Id: I42293b334248b5228dd90f13b9a400ccdca20a84
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2562
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 20:19:14 +00:00
Vincent Ambo
56f6a6e9f2 feat(tazjin/rlox): Implement parser precedence rules
Change-Id: Idcf3c84126603086bbf7e8d54773bccb3ae3b5ab
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2561
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 20:19:14 +00:00
Vincent Ambo
7778a58f8d feat(tazjin/rlox): Add initial Pratt parser table lookup
Change-Id: I1b894d2f84d23ddddcd1bb8794f771512b7d677e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2560
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 20:19:14 +00:00
Vincent Ambo
d2f24c925d feat(tazjin/rlox): Partial implementation of binary operators
Change-Id: I6f0bc9f58b51dec2673c918e08b199b52e793ed4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2559
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 19:22:58 +00:00
Vincent Ambo
1d3d9d32e3 feat(tazjin/rlox): Set up precedence parsing scaffolding
Defines a new precedence levels enum which can be used to restrict the
parser precedence in any given location. As an example, unary
expressions and grouping are implemented, as these have a different
precedence from e.g. expression()

Change-Id: I91f299fc77530f76c3aba717f638985428104ee5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2558
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 19:22:58 +00:00
Vincent Ambo
b13a6736dd chore(tazjin/rlox): Set up some scaffolding for panic mode
This lets us suppress reporting of additional errors from the compiler
until a synchronisation point is reached.

Change-Id: Iacf90949f868fbdb4349750065b5e458cf74d32a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2557
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-27 19:22:58 +00:00
Vincent Ambo
ee974b3edd feat(tazjin/rlox): Bootstrap rough shape of bytecode compiler
This one necessarily has to diverge more from the book than the
treewalk interpreter did, so some of this is expected to change, but
I'm happy with the rough shape.

Since we're reusing the old scanner, the compiler/parser struct owns
an iterator over all tokens with which the pull-scanner from the
bytecode chapters is simulated.

Change-Id: Icfa0bd4729d9df786e08f7e49a25cba1b9989a91
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2556
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-02-27 13:05:18 +00:00
Vincent Ambo
da2dfb42c6 chore(tazjin/rlox): Add From<Error> for Vec<Error>
This makes it easier to transition between the single/multi error
functions via ?

Change-Id: Ie027f4700da463a549be6f0d4a0022a9b8dc0d61
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2555
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-02-27 13:05:18 +00:00
Vincent Ambo
75750ba683 style(tazjin/rlox): Set max_width=80
Change-Id: Ib64831c0b97c94fdfbdbae64f4dfccc86879ef73
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2554
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-02-27 13:05:18 +00:00
Vincent Ambo
ebc987f4aa chore(tazjin/rlox): Implement From<ScannerError> for bytecode errors
Change-Id: I446c6e38cf239a132882d37df156884d319ca111
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2553
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-02-27 13:05:18 +00:00
Vincent Ambo
bef01b1419 feat(tazjin/emacs): Add #'rg-in-project
Uses project.el to anchor the ripgrep search. In combination with my
project detection logic, this means that grepping in TVL subprojects
works automatically.

Change-Id: I2705466d1de156c08ff0401a71112864aa24f976
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2542
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-22 13:50:34 +00:00
Vincent Ambo
e174bad35b feat(tazjin/emacs): Add layout for reMarkable as primary screen
Change-Id: I4c10e36250aa112d2dd0cebf4ed41e0b6fd8182d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2539
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-02-19 13:37:37 +00:00
Vincent Ambo
83465be599 feat(3p/telega): Pin tdlib version used for telega
Recent channel updates have caused some issues for telega.el, mostly
because the version of tdlib (the C++ library for Telegram) and the
Emacs package are out of sync.

This overrides the version used in the Emacs package to a "known good"
commit. It would be useful to change the tdlib derivation in nixpkgs
to make this version mismatch a hard build error.

Change-Id: I9c994f783e1cc17e933432507cd13b65697efd4a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2445
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-26 13:25:43 +00:00
Vincent Ambo
aa6e7f7c10 chore(tazjin/emacs): Disable my default dark theme temporarily
There's a giant laser in the sky which makes it hard to read anything
on a dark theme.

Change-Id: I1dd0631dc8f8f693cceada4e62b25d4bde322e09
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2442
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-26 10:29:16 +00:00
Vincent Ambo
cf4357d9b7 chore(tazjin/emacs): Remove some unused packages
Change-Id: I4adf7c1e028c997f776c635e1c6210f904274582
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2441
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-25 19:18:09 +00:00
Vincent Ambo
ea9982d9ea feat(tazjin/nittredir): Add Chrome extension to redirect to Nitter
There is another extension for this already, but it hooks in after the
page has already started loading - doing it on the URL change handler
is much faster.

Change-Id: I442552cbd8bb040df999a1624cafd436f4a7b875
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2430
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-20 15:36:05 +00:00
Vincent Ambo
de64ebbbaa feat(tazjin/emacs): Reset keyboard layout before locking screen
I managed to lock myself out by having the layout set to Russian while
locking the screen. This prevents that from happening.

Change-Id: I15780d2a626d96abe0af8db3736fad75034e66d8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2424
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-19 15:04:16 +00:00
Vincent Ambo
5868d4bd49 refactor(tazjin/rlox): Prepare scanner for shared use
In the book, the clox interpreter has its own scanner which uses a
pull-based model for a single pass compiler.

I can't be bothered to write another scanner, or amend this one into
pull-mode to work with the treewalk interpreter, so instead I will
just reuse it and pull from a vector of tokens.

The tokens are shared between both interpreters and the scanner is not
what I'm interested in here.

Change-Id: Ib07e89127fce2b047f9b3e1ff7e9908d798b3b2b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2420
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-19 09:57:05 +00:00
Vincent Ambo
1ff7a2686c refactor(tazjin/rlox): Add Interpreter trait for switching impls
Change-Id: Iae28d64ce879014c5e5d7e145c536c1f16ad307d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2418
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-18 00:24:16 +00:00
Vincent Ambo
d6d3c12efb feat(tazjin/rlox): Implement simple arithmetic operators
Change-Id: I9873bcd281053f4e9820a5119f5992a0b8cb8cfc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2417
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-01-17 21:17:54 +00:00
Vincent Ambo
7fb93fb490 feat(tazjin/rlox): Bootstrap VM for Lox bytecode
Change-Id: I479e20bf2087e5c4aa20e31b364c57ed0d961bcf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2416
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-01-17 21:17:54 +00:00
Vincent Ambo
b1d0e22b1f chore(tazjin/rlox): Move other modules under treewalk::
It's unclear if the second part of the book can reuse anything from
the first part (I'm guessing probably the scanner, but I'll move that
back if it turns out to be the case).

Change-Id: I9411355929e31ac6e953599e51665406b1f48d55
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2415
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 21:17:54 +00:00
Vincent Ambo
c26915d012 feat(tazjin/rlox): Track source lines along with bytecode
Change-Id: I272e73b9b1c9571fbfe4fa983fb4283ddee02bd4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2414
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 21:17:54 +00:00
Vincent Ambo
49c4cc6c56 feat(tazjin/rlox): Initial bytecode representation
This is significantly simplified from the version in the book, since
I'm using Rust's Vec and not implementing dynamic arrays manually.

We'll see if I run into issues with that ...

Change-Id: Ie3446ac3884b850f3ba73a4b1a6ca14e68054188
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2413
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 21:17:54 +00:00
Vincent Ambo
30a6fcccee refactor(tazjin/rlox): Move entrypoints into interpreters
Right now this introduces a simple mechanism to flip between the
interpreters.

Change-Id: I92ee920c53d76ab6b664ac671993a6d6426af61a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2412
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 21:17:54 +00:00
Vincent Ambo
f8b3e2a100 refactor(tazjin/rlox): Move treewalk interpreter into subdirectory
Change-Id: I9163f75db5a1ff75e1b1f81bad78fd9d8ddb104a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2409
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 09:34:13 +00:00
Vincent Ambo
052f8976bb fix(tazjin/rlox): Include static globals in resolution
Change-Id: Id377ce1fe4c9b9cd65395d15873399d9b6d38af8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2408
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 09:34:13 +00:00
Vincent Ambo
06a6aa5dc0 refactor(tazjin/rlox): Call resolver from interpreter
This makes the interpreter API a bit cleaner and allows for tighter
integration between the two parts (e.g. for static globals, which are
unhandled in the resolver right now).

Change-Id: I363714dc2e13cefa7731b54326573e0b871295d6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2407
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-17 09:34:13 +00:00
Vincent Ambo
e7a7e09300 chore(tazjin/homepage): Remove mentions of Twitter
I've stopped using it. This makes the header look a bit empty, but
I'll write new copy at some point.

Change-Id: I39bf36ba915c44e3d57905d0036de693b6431071
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2406
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-01-16 20:51:48 +00:00
Vincent Ambo
da7e99a4ff feat(tazjin/rlox): Use variable depth for env lookup
Finishes the binding implementation from https://craftinginterpreters.com/resolving-and-binding.html

Change-Id: I1e2c1f4139d9e77ce0b99e38db26edd4cdb56ad2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2404
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-16 13:46:31 +00:00
Vincent Ambo
29335a8b63 feat(tazjin/rlox): Implement variable depth resolver
Implements the first part of the resolver from
https://craftinginterpreters.com/resolving-and-binding.html

This is wired up to the execution paths in main, but not yet in the
tests. The resolved depth is also not actually used for variable
lookups (yet).

Change-Id: I3a8615252b7b9b12d5a290c5ddf85988f61b9184
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2403
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-16 13:46:31 +00:00
Vincent Ambo
740a9a3565 feat(tazjin/rlox): Implement support for closures
Change-Id: I0ffc810807a1a6ec90455a4f2d2bd977833005bd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2396
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 20:26:37 +00:00
Vincent Ambo
39439d59e8 feat(tazjin/rlox): Implement early return from functions
In the book this is implemented via exceptions as control flow, and
I'm sticking somewhat closely to that by doing it via an error
variant.

Change-Id: I9c7b84d6bb28265ab94021ea681df84f16a53da2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2395
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 20:26:37 +00:00
Vincent Ambo
20a6cfeee2 refactor(tazjin/rlox): Let scanner tokens own their lexeme
This removes the runtime dependency on a borrow into the program
source code.

It's not yet ideal because there are a lot of tokens where we really
don't care about the lexeme, but this is what the book does and I
am not going to change that.

Change-Id: I888e18f98597766d6f725cbf9241e8eb2bd839e2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2394
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 16:53:02 +00:00
Vincent Ambo
1d8e3f4f8b feat(tazjin/rlox): Implement function definitions
... with this, functions now work.

Note that this bubbled up another weird code structure nit: The
parser::Function type should probably not carry its name directly.

However this doesn't matter much and I don't care right now.

Change-Id: If8e3b23f07033260433b9acd45f37c0e61fd2ff8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2393
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 15:19:01 +00:00
Vincent Ambo
56d8fa97ed feat(tazjin/rlox): Implement calling user-defined functions
This slightly jiggles around interpret_block to let callers pass in an
environment.

Change-Id: I03112a38be0e8696242d8eae8d41da8c2cc66b48
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2392
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 15:19:01 +00:00
Vincent Ambo
fe97398fd9 refactor(tazjin/rlox): Thread lifetimes through interpreter
In order to store a function in the interpreter's representation of a
callable, the lifetimes used throughout rlox need to be threaded
through properly.

This is currently not optimal, for two reasons:

* following the design of the book's scanner, the source code slice
  needs to still be available at runtime. Rust makes this explicit,
  but it seems unnecessary.

* the interpreter's lifetime is now bounded to be smaller than the
  source's, which means that the REPL no longer persists state between
  evaluations

Both of these can be fixed eventually by diverging the scanner from
the book slightly, but right now that's not my priority.

Change-Id: Id0bf694541ff59795cfdea3c64a965384a49bfe2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2391
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 15:19:01 +00:00
Vincent Ambo
1ed34443d8 feat(tazjin/rlox): Parse function declarations
Change-Id: I1db4316563827976e5233dc7a626968f80b992ef
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2390
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 02:05:00 +00:00
Vincent Ambo
8bcbb04160 refactor(tazjin/rlox): Add helper method for parsing identifiers
Change-Id: I9a45f823f16919319d6135225d5bd53ed54c2530
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2388
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 02:05:00 +00:00
Vincent Ambo
fcd9801b01 refactor(tazjin/rlox): Let Parser::match_token take a single kind
This is much easier to read & write. It's been annoying me all the way
through.

Change-Id: Ia91756d3111a2ce3f74e1c14bccc210118d221dd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2387
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 02:05:00 +00:00
Vincent Ambo
f4a6e9f133 test(tazjin/rlox): Add a handful of interpreter tests
Change-Id: I32dd896d42cc73d68d73093e9cbb74b48d95e041
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2386
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:52:51 +00:00
Vincent Ambo
0c1c4584cb feat(tazjin/rlox): Implement PartialEq for interpreter::Value
Values have equality, unless they're functions.

Change-Id: Ie5c623081a1fa556e6b7a5251b0ce85af68dd31a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2385
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:52:51 +00:00
Vincent Ambo
9b477975d4 feat(tazjin/rlox): Always return values from interpreter
This makes it easier to write interpreter tests, as we don't need to
look at output and such.

Change-Id: I6f8ce0cb0c482b8c00707d09e6be750c8e534176
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2384
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:31:27 +00:00
Vincent Ambo
a03b509fb8 refactor(tazjin/rlox): Constructor for interpreter with globals
Change-Id: Id8242c22500c8e2781cc656d3faabb28d9bdf091
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2383
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:31:27 +00:00
Vincent Ambo
26544aa5f0 feat(tazjin/rlox): Implement function call evaluation
Change-Id: I6767c3a1a9654475b4066415f8c026b9c5b5907a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2382
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:31:27 +00:00
Vincent Ambo
090c96eae9 feat(tazjin/rlox): Scaffolding for builtin functions
... and adds an example builtin which returns the current epoch.

The types introduced by this, especially in the interpreter module,
are going to be used for user-defined functions, too.

Change-Id: I0364a67241e94642cde08489ac711a340e30ebe8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2381
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-14 00:31:27 +00:00
Vincent Ambo
73c2b8fb85 refactor(tazjin/rlox): Wrap interpreter values in new enum
This makes it possible to distinguish between literal and other
values, such as functions.

Change-Id: I4d87b96c2988e25a61eecfeeb56188fabfd0dc40
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2367
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-13 17:03:15 +00:00
Vincent Ambo
f3c60865a3 feat(tazjin/rlox): Parse function calls
Change-Id: I1836c73dbfd5fc4ca30c2d22bbffee2fb222d566
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2366
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-13 17:03:15 +00:00
Vincent Ambo
b4e420d4ff chore(3p): Bump NixOS channels to 2021-01-09
Your regularly scheduled channel update, but slightly more regular
than before.

Included fixes:

* 3p/emacs: Pick telega.el from stable channel, unstable is broken.
* glittershark/fprintd: Compile with gcc9, since build fails with the
  new default of gcc10
* glittershark/fprintd: Use a global overlay for the fprintd package
  until https://github.com/NixOS/nixpkgs/pull/108962 lands in
  nixos-unstable
* glittershark/home: Don't install rr, as it's not building with gcc10

Co-Author: Griffin Smith <grfn@gws.fyi>
Change-Id: Ia715fef64a405a220049fc540017356fa7370e0b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2341
Reviewed-by: tazjin <mail@tazj.in>
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Tested-by: BuildkiteCI
2021-01-13 16:53:20 +00:00
Vincent Ambo
c1cb4c260c chore(tazjin/emacs): Remove org-journal
I haven't used this much in the last months and it's causing issues
via some hook now, so bye bye.

Change-Id: If2b321887569b31c0ac7ad3fdd1b9c1d9f7b69f7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2344
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-10 13:32:47 +00:00
Vincent Ambo
4e34276b69 feat(tazjin/nisp): Add initial source-to-source transform
... this isn't finished yet, in particular it lacks:

* better support for attribute sets
* support for defining functions that take attribute sets

Change-Id: Ia897fccd9d2b674b6ed12907ae297bfdcc86db48
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2237
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
2021-01-09 16:52:34 +00:00
Vincent Ambo
0b4e280a07 feat(tazjin/rlox): Implement for loops via desugaring to while
Change-Id: I31a93efcc8e0c2bcb8549e2a2c05bb58d2dc74ca
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2326
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-06 23:02:31 +00:00
Vincent Ambo
d47e55ba4d feat(tazjin/rlox): Parse & interpret while statements
Change-Id: Iee772274de95dfd6a6d4af973402859aeda17b1d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2325
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-06 23:02:31 +00:00
Vincent Ambo
0a0335ae6c feat(tazjin/rlox): Parse & interpret logical operators
Change-Id: I1a7d0eda61f7f077b820dc0d2c2516e204966962
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2324
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2021-01-06 23:02:31 +00:00
Vincent Ambo
93122a212e feat(tazjin/rlox): Interpret if statements
Change-Id: Ic6aed29bec42098eb07e1ba9eb01dbcaae8d11e3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2322
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-01-06 17:14:17 +00:00
Vincent Ambo
a89777b34f feat(tazjin/rlox): Parse if statements
Change-Id: I2352d75a3f02d65a5a2d04fb2cc4daa50f11ca1e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2321
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2021-01-06 17:14:17 +00:00
Vincent Ambo
1686355d2e refactor(tazjin/rlox): Hold shared environment ptr in interpreter
Change-Id: Ia4c4ef330be431a344d42bc00d3a518825fb9399
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2305
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-12-31 19:10:39 +00:00
Vincent Ambo
b55caf0338 feat(tazjin/rlox): Implement block scope in interpreter
This is currently a bit hacky because of the environment
wrapping/unwrapping, will refactor this to just keep a single Rc
around instead.

Change-Id: Iad1cbbe35112d0329248d4655a09260fc60644c8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2304
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-12-31 19:10:39 +00:00
Vincent Ambo
8915cd6fba feat(tazjin/rlox): Implement block parsing
Change-Id: I1b7235ed71fa36120984a36f22cd564f59581352
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2303
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-31 15:33:08 +00:00
Vincent Ambo
3c979acdf3 refactor(tazjin/rlox): Unify parser::Statement & parser::Declaration
Change-Id: I6f21b246eb9d3bf760edb3220ce6be5de5b05b08
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2302
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-31 15:33:08 +00:00
Vincent Ambo
26ed836e1d feat(tazjin/rlox): Add support for scoped environments
Adds scoped environments using a sophisticated structure known as an
SRPT, which stands for "shitty parent pointer tree".

Change-Id: I62f66aabe6eb32ea01c4cabcca5b03cfefcc28ee
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2301
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-31 15:33:08 +00:00
Vincent Ambo
48a54625ce refactor(tazjin/rlox): Separate assignment and definition
So that:

> var a = 15;
> b = 12;
Error in program: Error { line: 0, kind: UndefinedVariable("b") }
> a = 12; print a;
Number(12.0)

Change-Id: I687e95ccc2d3084e39a71bd452656ae981c95191
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2300
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-31 14:32:03 +00:00
Vincent Ambo
cc958e6730 feat(tazjin/rlox): Implement mutable variable assignment
Change-Id: I56db10a5ac26958ae27a8d4c8fa7b8f8285bc7e1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2299
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-31 14:32:03 +00:00
Vincent Ambo
8ab66f1689 refactor(tazjin/rlox): Retain interpreter state in REPL
Change-Id: Id60760e241ad0e45871b48e499f58e9831d57316
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2298
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-12-31 11:19:42 +00:00
Vincent Ambo
78355d3c0b feat(tazjin/rlox): Add global variable support in interpreter
Change-Id: I4134cf78dc3934a517ad0c848ae1d3729abaf882
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2297
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
2020-12-31 11:19:42 +00:00
Vincent Ambo
0f9a7b3f86 feat(tazjin/rlox): Parse variable assignment & access
Change-Id: I9894d76716d739e85a4757d9e658f884228e7f52
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2290
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-22 20:18:01 +00:00
Vincent Ambo
5010b79718 fix(tazjin/emacs): Don't override CARGO_INCREMENTAL
Change-Id: Ib25c45795cb8aea87fc7e22343af6710a6339d32
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2289
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-22 10:13:28 +00:00
Vincent Ambo
a104afa6ea refactor(tazjin/rlox): Introduce declarations in parser
Change-Id: I873fdd53319ec36da18926d9477e809a69dbace7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2288
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-22 10:13:28 +00:00
Vincent Ambo
75ae25daa9 feat(tazjin/rlox): Add support for statements
First part of
https://craftinginterpreters.com/statements-and-state.html

Supports print statements, as well as evaluation for the sake of
it (i.e. future side-effects).

Change-Id: Ic6653b568f98d6cfe3f297615b7113c0ba1d9a70
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2287
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
2020-12-22 10:13:28 +00:00