diff options
| author | elioat <{ID}+{username}@users.noreply.github.com> | 2025-07-31 11:14:11 -0400 |
|---|---|---|
| committer | elioat <{ID}+{username}@users.noreply.github.com> | 2025-07-31 11:14:11 -0400 |
| commit | 74f055c27c95fac8b7894e647ef2beee4bf1846e (patch) | |
| tree | d3b4fd59d0777e1056b08f7cbab9062e1c34723f /awk | |
| parent | 40822b3e9c501d9057246bc28ba99b69a791e3b8 (diff) | |
| download | tour-74f055c27c95fac8b7894e647ef2beee4bf1846e.tar.gz | |
*
Diffstat (limited to 'awk')
| -rw-r--r-- | awk/rawk/rawk.awk | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/awk/rawk/rawk.awk b/awk/rawk/rawk.awk index 3fc734d..9f4d371 100644 --- a/awk/rawk/rawk.awk +++ b/awk/rawk/rawk.awk @@ -7,7 +7,7 @@ # Version: RAWK_VERSION = "0.0.1" -# Lets help awk rawk. +# Lets help awk rawk # # This script translates a `.rawk` source file into standard, portable awk code. # @@ -509,7 +509,7 @@ function parse_single_line_function(line, line_num) { return } - # Extract body (everything after -> until semicolon) + # Extract body. which we enforce as everything after -> until a semicolon if (match(line, /->[ \t]*(.+?);/)) { body = substr(line, RSTART + 2, RLENGTH - 3) # Remove -> and ; # Trim whitespace @@ -531,6 +531,8 @@ function parse_single_line_function(line, line_num) { } # Generate standard library functions +# FIXME: in the future, we should only generate the functions that are actually used +# TODO: track which functions are used/referenced function generate_standard_library() { print "# --- rawk Standard Library ---" print "# Dispatch mechanism for rawk functions" @@ -1262,7 +1264,7 @@ function generate_main_script() { } } -# Error reporting function +# TODO: think through ways to add more passes to enhance compiler error messages function report_error(message, line_num, line, suggestion) { print "❌ rawk compilation error: " message > "/dev/stderr" print " at line " line_num " in " FILENAME > "/dev/stderr" @@ -1275,7 +1277,6 @@ function report_error(message, line_num, line, suggestion) { errors++ } -# Warning reporting function function report_warning(message, line_num, line, suggestion) { print "⚠️ rawk compilation warning: " message > "/dev/stderr" print " at line " line_num " in " FILENAME > "/dev/stderr" @@ -1292,8 +1293,6 @@ function report_warning(message, line_num, line, suggestion) { END { source_lines = line_count - - # Generate standard library generate_standard_library() @@ -1303,7 +1302,7 @@ END { # Generate main script body generate_main_script() - # Print compilation summary + # Leave some rawk meta data behind within the compiled code print "# Rawk compilation summary:" print "# - Rawk Version: " RAWK_VERSION print "# - Functions defined: " functions_defined |