commit 8a1b934aa1e0dc237f8005409afba12e347cd254
parent cfeb5e2a92f48a5ad900af1312d95c9c818c4980
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 16 Apr 2021 15:22:43 -0400
hare::parse: use const where appropriate
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha
@@ -3,9 +3,9 @@ use hare::lex::{ltok};
use hare::lex;
use fmt;
-// Parses a expression.
+// Parses an expression.
export fn expression(lexer: *lex::lexer) (ast::expr | error) = {
- let tok = match (peek(lexer, ltok::LBRACE, ltok::MATCH, ltok::SWITCH,
+ const tok = match (peek(lexer, ltok::LBRACE, ltok::MATCH, ltok::SWITCH,
ltok::IF, ltok::FOR, ltok::BREAK, ltok::CONTINUE,
ltok::RETURN, ltok::LET, ltok::CONST)?) {
void => return binarithm(lexer, void, 0),
@@ -65,13 +65,12 @@ fn binarithm(
};
fn builtin(lexer: *lex::lexer) (ast::expr | error) = {
- let tok = match (peek(lexer, ltok::ALLOC, ltok::APPEND, ltok::FREE,
+ const tok = match (peek(lexer, ltok::ALLOC, ltok::APPEND, ltok::FREE,
ltok::DELETE, ltok::ABORT, ltok::ASSERT, ltok::STATIC,
ltok::SIZE, ltok::LEN, ltok::OFFSET, ltok::DEFER)?) {
tok: lex::token => tok,
void => return postfix(lexer, void),
};
-
return switch (tok.0) {
ltok::ALLOC => abort(),
ltok::APPEND => abort(),
@@ -171,8 +170,8 @@ fn expression_list(lexer: *lex::lexer) (ast::expr | error) = {
want(lexer, ltok::LBRACE)?;
for (let more = true; more) {
- let tok = peek(lexer)? as lex::token;
- let item = switch (tok.0) {
+ const tok = peek(lexer)? as lex::token;
+ const item = switch (tok.0) {
ltok::RBRACE => break,
ltok::BREAK,
ltok::CONTINUE,