From 05136fdd25bf065f81ed20f74d402592a7c6e8f2 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 16 Apr 2024 15:38:24 +0630 Subject: Fixed examples for changes in lexer Name assigned to %CONST is the next symbol in stream, not the symbol attached to it. --- asm/lexer.cpp | 2 +- examples/factorial.asm | 2 +- examples/fib.asm | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/asm/lexer.cpp b/asm/lexer.cpp index 991e551..e2efdfe 100644 --- a/asm/lexer.cpp +++ b/asm/lexer.cpp @@ -50,7 +50,7 @@ pair tokenise_symbol(string_view &source, size_t &column, token_t t{}; - if (initial_match(sym, "%CONST")) + if (sym == "%CONST") { t.type = token_type_t::PP_CONST; } diff --git a/examples/factorial.asm b/examples/factorial.asm index 54fc956..c4257e4 100644 --- a/examples/factorial.asm +++ b/examples/factorial.asm @@ -6,7 +6,7 @@ ;; 65 which means that past 20! results are truncated and therefore ;; the program produces inaccurate factorials. - %const(limit) 20 %end + %const limit 20 %end ;; Setup entrypoint global main diff --git a/examples/fib.asm b/examples/fib.asm index 0a9e969..7f4c360 100644 --- a/examples/fib.asm +++ b/examples/fib.asm @@ -5,26 +5,26 @@ ;;; stack version. ;; Constants - %const(limit) 93 %end + %const limit 93 %end - %const(increment_i) + %const increment_i push.reg.word 2 push.word 1 plus.word mov.word 2 %end - %const(print_i) + %const print_i push.reg.word 2 print.word %end - %const(print_reg_0) + %const print_reg_0 push.reg.word 0 print.word %end - %const(print_reg_1) + %const print_reg_1 push.reg.word 1 print.word %end -- cgit v1.2.3-13-gbd6f