hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit dd6568fed0473f15e9ff4e387ddab4b8a8476fc7
parent 859d762b0577d3b3434a8c203a84c69244910609
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu,  8 Apr 2021 11:43:43 -0400

hare::parse: remove expression classes

Diffstat:
Mhare/parse/decl.ha | 2+-
Mhare/parse/expr.ha | 6+++---
Mhare/parse/exprclass.ha | 20++++++--------------
3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha @@ -58,7 +58,7 @@ fn decl_global( _type.flags |= ast::type_flags::CONST; }; want_btoken(lexer, btoken::EQUAL)?; - let init = simple_expression(lexer)?; + let init = expression(lexer)?; let btok = try_btoken(lexer, btoken::COMMA)?; append(decl, ast::decl_global { is_const = tok == btoken::DEF, diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha @@ -111,7 +111,7 @@ fn plain_expression(lexer: *lex::lexer) (ast::expr | error) = { btoken::LBRACKET => abort(), // TODO: Array literal btoken::STRUCT => abort(), // TODO: Struct literal btoken::LPAREN => { - let ex = complex_expression(lexer); + let ex = expression(lexer); return switch (want_btoken(lexer, btoken::RPAREN, btoken::COMMA)?) { btoken::RPAREN => ex, @@ -261,9 +261,9 @@ fn expression_list(lexer: *lex::lexer) (ast::expr | error) = { more = false; control_statement(lexer)?; }, - * => scope_expression(lexer)?, + * => expression(lexer)?, }, - * => scope_expression(lexer)?, + * => expression(lexer)?, }; append(items, alloc(item)); want_btoken(lexer, btoken::SEMICOLON)?; diff --git a/hare/parse/exprclass.ha b/hare/parse/exprclass.ha @@ -3,10 +3,10 @@ use hare::lex::{btoken}; use hare::lex; use io; -// Parses a complex-expression. -export fn complex_expression(lexer: *lex::lexer) (ast::expr | error) = { - // TODO: if, for, switch, match - return simple_expression(lexer); +// Parses an expression. +export fn expression(lexer: *lex::lexer) (ast::expr | error) = { + // TODO: if, for, switch, match, etc + return binarithm(lexer, void, 0); }; // Parses a compound-expression. @@ -20,21 +20,13 @@ export fn compound_expression(lexer: *lex::lexer) (ast::expr | error) = { lex::unlex(lexer, tok); let tok = match (tok.0) { tok: btoken => tok, - * => return complex_expression(lexer), + * => return expression(lexer), }; return switch (tok) { btoken::LBRACE => expression_list(lexer), btoken::BREAK, btoken::CONTINUE, btoken::RETURN => control_statement(lexer), - * => complex_expression(lexer), + * => expression(lexer), }; }; - -fn scope_expression(lexer: *lex::lexer) (ast::expr | error) = { - return simple_expression(lexer); // TODO -}; - -// Parses a simple-expression. -export fn simple_expression(lexer: *lex::lexer) (ast::expr | error) = - binarithm(lexer, void, 0);