feat(tazjin/rlox): Bootstrap recursive-descent parser for Lox

... 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
This commit is contained in:
Vincent Ambo 2020-11-28 19:53:51 +01:00 committed by tazjin
parent 754edb4616
commit 349583d5a9
3 changed files with 107 additions and 5 deletions

View file

@ -1,6 +1,6 @@
use crate::errors::{Error, ErrorKind};
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum TokenKind {
// Single-character tokens.
LeftParen,
@ -54,10 +54,9 @@ pub enum TokenKind {
#[derive(Debug)]
pub struct Token<'a> {
kind: TokenKind,
lexeme: &'a [char],
// literal: Object, // TODO(tazjin): Uhh?
line: usize,
pub kind: TokenKind,
pub lexeme: &'a [char],
pub line: usize,
}
struct Scanner<'a> {