feat(tazjin/rlox): Implement parsing up to unary expressions
... with the exception of parenthesised expressions, because error threading is not implemented yet. Change-Id: I8d455d85e647548d5b71cbfd3d078f4970dab7fb Reviewed-on: https://cl.tvl.fyi/c/depot/+/2232 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
a8371b01df
commit
5fcff11eae
2 changed files with 109 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::errors::{Error, ErrorKind};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum TokenKind {
|
||||
// Single-character tokens.
|
||||
LeftParen,
|
||||
|
|
@ -29,22 +29,22 @@ pub enum TokenKind {
|
|||
Identifier(String),
|
||||
String(String),
|
||||
Number(f64),
|
||||
True,
|
||||
False,
|
||||
Nil,
|
||||
|
||||
// Keywords.
|
||||
And,
|
||||
Class,
|
||||
Else,
|
||||
False,
|
||||
Fun,
|
||||
For,
|
||||
If,
|
||||
Nil,
|
||||
Or,
|
||||
Print,
|
||||
Return,
|
||||
Super,
|
||||
This,
|
||||
True,
|
||||
Var,
|
||||
While,
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ pub enum TokenKind {
|
|||
Eof,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Token<'a> {
|
||||
pub kind: TokenKind,
|
||||
pub lexeme: &'a [char],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue