about summary refs log tree commit diff stats
path: root/awk/rawk/rawk.awk
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/rawk.awk')
-rw-r--r--awk/rawk/rawk.awk34
1 files changed, 22 insertions, 12 deletions
diff --git a/awk/rawk/rawk.awk b/awk/rawk/rawk.awk
index 8180a7b..c4e2ff1 100644
--- a/awk/rawk/rawk.awk
+++ b/awk/rawk/rawk.awk
@@ -1,11 +1,19 @@
 #!/usr/bin/awk -f
+
+# rawk.awk
+
+# Author: @eli_oat
+# License: Public Domain
+# Lets make awk rawk
+
 # =============================================================================
-# rawk v2.0.0 - Multi-pass block-based compiler
+# Multi-pass compiler
 # =============================================================================
 # 
-# This compiler transforms rawk code into standard awk with smart standard 
-# library inclusion. It uses a multi-pass approach to overcome AWK's variable 
-# scoping limitations and ensure deterministic compilation.
+# This compiler transforms rawk code into standard awk and smartly includes only
+# those standard library functions you've actually used. It uses a multi-pass 
+# approach to overcome awk's variable scoping limitations and ensure 
+# deterministic compilation.
 #
 # COMPILATION PROCESS:
 #   Pass 1: Collect all input lines into memory
@@ -26,8 +34,10 @@ BEGIN {
     # INITIALIZATION: Set up data structures for multi-pass compilation
     # =============================================================================
     
+    RAWK_VERSION = "0.0.1"
+    
     # Arrays to store compilation state
-    delete lines                    # All input lines (Pass 1)
+    delete lines                   # All input lines (Pass 1)
     delete FUNCTION_NAMES          # User-defined function names (Pass 3)
     delete FUNCTION_ARGS           # User-defined function arguments (Pass 3)
     delete FUNCTION_BODIES         # User-defined function bodies (Pass 3)
@@ -307,7 +317,7 @@ END {
     # user-defined functions, and the main script body.
     
     # Output header with compilation metadata
-    print "# Generated by rawk v2.0.0"
+    print "# Generated with rawk v" RAWK_VERSION
     print "# Source: " ARGV[1]
     print ""
     
@@ -334,13 +344,13 @@ END {
     # This is the "smart inclusion" feature that only includes functions that are called
     for (func_name in USED_STDLIB_FUNCTIONS) {
         if (func_name == "assert") {
-            print "function assert(condition, message) { if (!condition) { print \"❌ Assertion failed: \" message > \"/dev/stderr\"; exit 1 } }"
+            print "function assert(condition, message) { if (!condition) { print \"Assertion failed: \" message > \"/dev/stderr\"; exit 1 } }"
         } else if (func_name == "expect_equal") {
-            print "function expect_equal(actual, expected, message) { if (actual != expected) { print \"❌ Expected \" expected \" but got \" actual \" - \" message > \"/dev/stderr\"; exit 1 } }"
+            print "function expect_equal(actual, expected, message) { if (actual != expected) { print \"Expected \" expected \" but got \" actual \" - \" message > \"/dev/stderr\"; exit 1 } }"
         } else if (func_name == "expect_true") {
-            print "function expect_true(condition, message) { if (!condition) { print \"❌ Expected true but got false - \" message > \"/dev/stderr\"; exit 1 } }"
+            print "function expect_true(condition, message) { if (!condition) { print \"Expected true but got false - \" message > \"/dev/stderr\"; exit 1 } }"
         } else if (func_name == "expect_false") {
-            print "function expect_false(condition, message) { if (condition) { print \"❌ Expected false but got true - \" message > \"/dev/stderr\"; exit 1 } }"
+            print "function expect_false(condition, message) { if (condition) { print \"Expected false but got true - \" message > \"/dev/stderr\"; exit 1 } }"
         } else if (func_name == "is_positive") {
             print "function is_positive(value) { return is_number(value) && value > 0 }"
         } else if (func_name == "is_negative") {
@@ -465,7 +475,7 @@ END {
     # DISPATCH FUNCTION: Dynamic function calling for functional programming
     # =============================================================================
     # The dispatch_call function enables functional programming utilities (map, reduce, etc.)
-    # to dynamically call user-defined functions by name. This is only included when needed.
+    # to dynamically call user-defined functions by name. This is only included when used.
     
     if ("map" in USED_STDLIB_FUNCTIONS || "reduce" in USED_STDLIB_FUNCTIONS || "filter" in USED_STDLIB_FUNCTIONS || "find" in USED_STDLIB_FUNCTIONS || "findIndex" in USED_STDLIB_FUNCTIONS || "flatMap" in USED_STDLIB_FUNCTIONS || "pipe" in USED_STDLIB_FUNCTIONS || "pipe_multi" in USED_STDLIB_FUNCTIONS) {
         print "# Dispatch function for functional programming"
@@ -521,7 +531,7 @@ END {
     # =============================================================================
     print ""
     print "# Rawk compilation summary:"
-    print "#   - Rawk Version: 2.0.0"
+    print "#   - Rawk Version: " RAWK_VERSION
     print "#   - Functions defined: " function_count
     print "#   - Source lines: " line_count
     print "#   - Standard library functions included: " length(USED_STDLIB_FUNCTIONS)