From 6ab36fc48924062da618e7467bbbeb83aab828a1 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sat, 1 Jul 2023 00:26:32 -0600 Subject: [PATCH] Added some throwing stubs to parser --- Parser.cs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Parser.cs b/Parser.cs index 480525b..92399aa 100644 --- a/Parser.cs +++ b/Parser.cs @@ -184,7 +184,7 @@ class Parser Expr elseCase = expression(); return new If { Condition = condition, Then = thenCase, Else = elseCase }; case TokenType.When: - throw new NotImplementedException(); + throw new NotImplementedException("TODO when"); } return primary(); @@ -207,6 +207,7 @@ class Parser private Expr primary() { Expr expr = operand(); + if (match(TokenType.Period)) { Name? ident = name(); @@ -216,14 +217,17 @@ class Parser } return new Selector { Left = expr, FieldName = ident }; } + if (match(TokenType.LBracket)) { throw new NotImplementedException("TODO index"); } + if (match(TokenType.LParen)) { throw new NotImplementedException("TODO apply"); } + return expr; } @@ -247,6 +251,35 @@ class Parser return new Grouping { Expression = expr }; } + Expr? expr; + if ((expr = record()) != null) + { + return expr; + } + if ((expr = variant()) != null) + { + return expr; + } + if ((expr = list()) != null) + { + return expr; + } + throw error(peek(), "Expect expression."); } + + private Expr? list() + { + throw new NotImplementedException("TODO list"); + } + + private Expr? variant() + { + throw new NotImplementedException("TODO variant"); + } + + private Expr? record() + { + throw new NotImplementedException("TODO record"); + } }