about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/main.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-02-28 r/2247 feat(tazjin/rlox): Wire up bytecode interpreter & print resultsVincent Ambo1-4/+7
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-27 r/2235 style(tazjin/rlox): Set max_width=80Vincent Ambo1-3/+9
Change-Id: Ib64831c0b97c94fdfbdbae64f4dfccc86879ef73 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2554 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2021-01-19 r/2132 refactor(tazjin/rlox): Prepare scanner for shared useVincent Ambo1-0/+1
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-18 r/2129 refactor(tazjin/rlox): Add Interpreter trait for switching implsVincent Ambo1-2/+57
Change-Id: Iae28d64ce879014c5e5d7e145c536c1f16ad307d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2418 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-17 r/2126 chore(tazjin/rlox): Move other modules under treewalk::Vincent Ambo1-9/+0
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 r/2123 refactor(tazjin/rlox): Move entrypoints into interpretersVincent Ambo1-44/+4
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 r/2120 refactor(tazjin/rlox): Move treewalk interpreter into subdirectoryVincent Ambo1-5/+4
Change-Id: I9163f75db5a1ff75e1b1f81bad78fd9d8ddb104a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2409 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2021-01-17 r/2118 refactor(tazjin/rlox): Call resolver from interpreterVincent Ambo1-2/+1
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-16 r/2113 feat(tazjin/rlox): Implement variable depth resolverVincent Ambo1-11/+8
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-14 r/2107 refactor(tazjin/rlox): Let scanner tokens own their lexemeVincent Ambo1-4/+5
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 r/2104 refactor(tazjin/rlox): Thread lifetimes through interpreterVincent Ambo1-5/+4
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 r/2097 refactor(tazjin/rlox): Constructor for interpreter with globalsVincent Ambo1-2/+2
Change-Id: Id8242c22500c8e2781cc656d3faabb28d9bdf091 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2383 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-12-31 r/2032 refactor(tazjin/rlox): Retain interpreter state in REPLVincent Ambo1-2/+27
Change-Id: Id60760e241ad0e45871b48e499f58e9831d57316 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2298 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
2020-11-30 r/1966 feat(tazjin/rlox): Bootstrap recursive-descent parser for LoxVincent Ambo1-0/+1
... mostly some AST boilerplate and a first top-level rule, plus boilerplate similar to that set up in the Scanner. Change-Id: I605d1de23c47a3b3702ab4f62cd3371bc3988c7d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2194 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-11-28 r/1952 fix(tazjin/rlox): Clear previous line in REPL modeVincent Ambo1-0/+1
Change-Id: I8acc5b0d07b2c656f9bba76a6ddac6b9088ea563 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2189 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-11-23 r/1914 feat(tazjin/rlox): Implement single-character scanningVincent Ambo1-0/+2
... still not that interesting, but at this point slightly divergent from the book: The book embraces mutability for interpreter state, initially for tracking whether an error condition has occured. I avoid this by instead defining an error type and collecting the error values, to be handled later on. Notes: So far nothing special, but this is just the beginning of the book. I like the style it is written in and it has pointed to some interesting resources, such as a 1965 paper titled "The Next 700 Languages". Change-Id: I030b38438fec9eb55372bf547af225138908230a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2144 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-11-23 r/1913 feat(tazjin/rlox): Add basic program structureVincent Ambo1-10/+27
... as well as a Nix derivation, because why not. Change-Id: Iaf2591ab72676fe0732c3f807b3aa0cff13fb4ef Reviewed-on: https://cl.tvl.fyi/c/depot/+/2143 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
2020-11-23 r/1912 feat(tazjin/rlox): Bootstrap programVincent Ambo1-0/+23
This is going to be the first of two interpreters from "Crafting Interpreters". Change-Id: I354ddd2357444648d0245f35d92176dd176525d8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2142 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI