Skip to content

Commit 4c43a2b

Browse files
committed
Parser tests pass!
1 parent 14d9eca commit 4c43a2b

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

takolib/src/interpreter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ impl Ctx<'_> {
271271
| Symbol::LogicalOrAssign
272272
| Symbol::ModuloAssign => todo!("Support assignment"),
273273
Symbol::Group => todo!("Support Group"),
274-
Symbol::Escape => panic!("Support Escape"), // TODO: Nah
275274
Symbol::Comma => panic!("Support Comma"), // TODO: Nah
276275
Symbol::Ident => panic!("Support Ident"), // TODO: Nah
277276
_ => panic!("Others????"), // TODO: Nah

takolib/src/parser/lexer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ mod tests {
675675
| Symbol::MultiCommentOpen
676676
| Symbol::MultiCommentClose
677677
| Symbol::Group
678-
| Symbol::Escape
679678
) {
680679
// Special case
681680
continue;

takolib/src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn make_tables() -> Result<ParserConfigTable, ()> {
267267
rules: config,
268268
precedences: vec![
269269
Comma, Sequence, Assign, Arrow,
270-
DoubleArrow, Add, Sub, Div, Mul, Exp, HasType,
270+
DoubleArrow, Add, Sub, Div, Mul, Exp, Sub /*Neg*/, HasType,
271271
Eqs, NotEqs, Lt, LtEqs, Gt, GtEqs,
272272
Sigma, Lambda, Forall, Pi, Exists,
273273
CloseParen, // TODO: Add all

takolib/src/parser/tokens.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ pub enum Symbol {
9393
Spread,
9494

9595
// Ignore symbols
96-
Escape,
9796
Group,
9897
Shebang, // TODO: Consider using direct comparisons? = senum!("/*"),
9998
Comment,
@@ -206,7 +205,7 @@ pub fn classify_char(ch: char) -> CharacterType {
206205
'}' => CloseCurly,
207206
'[' => OpenBracket,
208207
']' => CloseBracket,
209-
'\\' => Escape, // Escape?
208+
'\\' => Group, // Escape?
210209
'λ' => Lambda,
211210
'Π' => Pi,
212211
'Σ' => Sigma,
@@ -326,6 +325,15 @@ impl std::str::FromStr for Symbol {
326325
"}" => CloseCurly,
327326
"[" => OpenBracket,
328327
"]" => CloseBracket,
328+
"\\" => Group,
329+
"," => Comma,
330+
"an identifier" => Ident,
331+
"a number" => NumberLit,
332+
"a color" => ColorLit,
333+
"a string literal" => StringLit,
334+
"the start of a format string literal" => FmtStringLitStart,
335+
"the middle of a format string literal" => FmtStringLitMid,
336+
"the end of a format string literal" => FmtStringLitEnd,
329337
_ => return Err(()),
330338
};
331339
Ok(t)
@@ -409,8 +417,7 @@ impl From<&Symbol> for &str {
409417
Symbol::CloseCurly => "}",
410418
Symbol::OpenBracket => "[",
411419
Symbol::CloseBracket => "]",
412-
Symbol::Escape => "\\",
413-
Symbol::Group => " ", // Group is not a expressable character.
420+
Symbol::Group => "\\",
414421
}
415422
}
416423
}

0 commit comments

Comments
 (0)