[GODCC][COMMITTED] Use nestable comments

Jose E. Marchesi jemarch@gnu.org
Sun May 18 16:11:57 GMT 2025



---
 src/argp.a68          | 12 ++++-----
 src/ce.a68            | 42 ++++++++++++++---------------
 src/godcc-compile.a68 | 20 +++++++-------
 src/godcc-format.a68  | 20 +++++++-------
 src/godcc-list.a68    |  4 +--
 src/godcc.a68         | 16 +++++------
 src/http.a68          | 54 ++++++++++++++++++-------------------
 src/json.a68          | 62 +++++++++++++++++++++----------------------
 src/utils.a68         | 12 ++++-----
 9 files changed, 119 insertions(+), 123 deletions(-)

diff --git a/src/argp.a68 b/src/argp.a68
index 5de5e53..9eee181 100644
--- a/src/argp.a68
+++ b/src/argp.a68
@@ -1,4 +1,4 @@
-# argp.a68 - argp-like command line parser
+{ argp.a68 - argp-like command line parser
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,9 +14,9 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
-# Each option can specify a name and a long name.  The name is a
+{ Each option can specify a name and a long name.  The name is a
   single character, and " " denotes the option has no short
   name.  The long name is a string, and the empty string ""
   denotes the option has no long name.
@@ -47,7 +47,7 @@
   Handlers for both option and no-option arguments shall yield a
   boolean.  If it is FALSE then parsing stops once the handler
   returns.  Otherwise parsing continues.
-#
+}
 
 mode ArgOpt = struct (char name, string long_name,
                       bool arg_required, proc(string)bool handler);
@@ -83,7 +83,7 @@ begin
          elif found_dash_dash OR (UPB arg >= 1 andth arg[1] /= "-")
          then continue := no_opt_handler (i + 1, arg)
          elif UPB arg > 1 andth arg[2] = "-"
-         then # Long option.  It may have an argument.  #
+         then { Long option.  It may have an argument.  }
               int eqidx = char_in_string (arg, "=");
               string optname = (eqidx > 0 | arg[3:eqidx - 1] | arg[3:]),
               optarg = (eqidx > 0 AND UPB arg >= (eqidx + 1) | arg[eqidx + 1:]);
@@ -92,7 +92,7 @@ begin
               if (arg_required of opt) AND optarg = ""
               then error_handler ("option --" + arg + " requires an argument") fi;
               continue := (handler of opt) (optarg)
-         else # This is one or more short options.  #
+         else { This is one or more short options.  }
               for j to UPB arg[2:]
               do ArgOpt opt = getopt ("-", arg[j + 1]);
                  if arg_required of opt
diff --git a/src/ce.a68 b/src/ce.a68
index c65b9ec..d5c47b5 100644
--- a/src/ce.a68
+++ b/src/ce.a68
@@ -1,4 +1,4 @@
-# ce.a68 - Communication with a Compiler Explorer instance.
+{ ce.a68 - Communication with a Compiler Explorer instance.
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,25 +14,24 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 pr include "json.a68" pr
 pr include "http.a68" pr
 
-# The following variables should be set by the user of this library to
+{ The following variables should be set by the user of this library to
   whatever host and port to use when talking to a Compiler Explorer
-  instance.  #
+  instance.  }
 
 string ce_host;
 int ce_port;
 
-# Communication with Compiler Explorer is performed via a
-  socket.
-#
+{ Communication with Compiler Explorer is performed via a
+  socket.  }
 
 int ce_socket := -1;
 
-# Connect to the CE instance.  #
+{ Connect to the CE instance.  }
 
 proc ce_connect = void:
 begin (ce_socket > -1 | error ("socket already open"));
@@ -41,7 +40,7 @@ begin (ce_socket > -1 | error ("socket already open"));
       fi
 end;
 
-# Disconnect from the CE instance.  #
+{ Disconnect from the CE instance.  }
 
 proc ce_disconnect = void:
 begin (ce_socket = -1 | error ("socket not open"));
@@ -50,7 +49,7 @@ begin (ce_socket = -1 | error ("socket not open"));
       ce_socket := -1
 end;
 
-# Perform a GET operation in the CE instance, and return a JSON value
+{ Perform a GET operation in the CE instance, and return a JSON value
   containing the result of the operation.
 
   WHAT is a string identifying the operation, which results in an
@@ -61,8 +60,7 @@ end;
 
   See the Compiler Explorer documentation for a list of supported
   operations, and the form of JSON returned for the particular
-  operations.
-#
+  operations.  }
 
 proc ce_get_json = (string what) JSON_Val:
 begin JSON_Val val;
@@ -74,11 +72,11 @@ begin JSON_Val val;
                  ("user-agent", "curl/7.74.0"),
                  ("content-type", "application/json"),
                  ("Accept", "application/json")),
-                response, false # fragmented  #);
+                response, false { fragmented  });
       val
 end;
 
-# Perform a POST operation in the CE instance, sending the given VAL,
+{ Perform a POST operation in the CE instance, sending the given VAL,
   and return a JSON value containing the result of the operation.
 
   WHAT is a string identifying the operation, which results in an
@@ -90,7 +88,7 @@ end;
   See the Compiler Explorer documentation for a list of supported
   operations, and the form of JSON returned for the particular
   operations.
-#
+}
 
 proc ce_post_json = (string what, JSON_Val val) JSON_Val:
 begin JSON_Val out_val;
@@ -104,11 +102,11 @@ begin JSON_Val out_val;
                   ("content-type", "application/json"),
                   ("Accept", "application/json")),
                  json_to_string (val),
-                 inh, false # fragmented  #);
+                 inh, false { fragmented  });
       out_val
 end;
 
-# Perform a GET operation in the CE instance.
+{ Perform a GET operation in the CE instance.
 
   WHAT is a string identifying the operation, which results in an
   /api/WHAT path.
@@ -118,7 +116,7 @@ end;
 
   This procedure shall only be invoked between calls to ce_connect and
   ce_disconnect.
-#
+}
 
 proc ce_get_text = (string what,
                     proc(int,int,int)void response) void:
@@ -126,9 +124,9 @@ proc ce_get_text = (string what,
              (("Host", "godbolt.org"),
               ("user-agent", "curl/7.74.0"),
               ("Accept", "text/*")),
-             response, true # fragmented  #);
+             response, true { fragmented  });
 
-# Perform a POST operation in the CE instance.
+{ Perform a POST operation in the CE instance.
 
   WHAT is a string identifying the operation, which results in an
   /api/WHAT path.
@@ -142,7 +140,7 @@ proc ce_get_text = (string what,
   See the Compiler Explorer documentation for a list of supported
   operations, and the form of JSON returned for the particular
   operations.
-#
+}
 
 proc ce_post_text = (string what,
                      union(string,proc(ref bool)string) contents,
@@ -151,4 +149,4 @@ proc ce_post_text = (string what,
               (("Host", "godbolt.org"),
                ("user-agent", "curl/7.74.0"),
                ("Accept", "text/*")),
-              contents, response, true # fragmented  #);
+              contents, response, true { fragmented  });
diff --git a/src/godcc-compile.a68 b/src/godcc-compile.a68
index d9aece6..04a61b1 100644
--- a/src/godcc-compile.a68
+++ b/src/godcc-compile.a68
@@ -1,4 +1,4 @@
-# godcc-compile.a68 - godcc compile sub-command.
+{ godcc-compile.a68 - godcc compile sub-command.
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,11 +14,11 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 proc godcc_compile = (int pos) void:
 begin
-      # Try to infer the default for the compiler from the progname.  #
+      { Try to infer the default for the compiler from the progname.  }
       string compiler;
       begin string progname = argv (1);
             int dash = char_in_string (progname, "-");
@@ -27,7 +27,7 @@ begin
             fi
       end;
 
-      # Parse command-line options for the sub-command.  #
+      { Parse command-line options for the sub-command.  }
       string src_file := "-", out_file := "-", comp_opts;
       argp (pos, []ArgOpt (("c", "compiler", true,
                             (string arg) bool: (compiler := arg; true)),
@@ -45,30 +45,30 @@ begin
             error);
       (compiler = "" | error ("please specify a compiler with -c|--compiler"));
 
-      # Form the URI appending options if necessary.  #
+      { Form the URI appending options if necessary.  }
       string uri := "compiler/" + compiler + "/compile";
       if comp_opts /= ""
       then uri +:= "?options=" + http_escape_url (comp_opts) fi;
 
-      # Open the input and output files.  #
+      { Open the input and output files.  }
       int in_fd := (src_file = "-" | 0 | fopen_checked (src_file, file_o_rdonly));
       int out_fd := (out_file = "-" | 1 | fcreate_checked (out_file, 8r644));
 
-      # Query the server, printing the response.  #
+      { Query the server, printing the response.  }
       ce_connect;
       ce_post_text (uri,
-                    # contents  #
+                    { contents  }
                     (ref bool done) string:
                        begin ref string line = fgets (in_fd, 0);
                              done := UPB line = 0;
                              line
                        end,
-                    # response  #
+                    { response  }
                     (int e, n, fd) void:
                        (n > 0 | puts (fgets (fd, n))));
       ce_disconnect;
 
-      # Close files whenever required.  #
+      { Close files whenever required.  }
       (in_fd /= 1 | fclose_checked (src_file, in_fd));
       (out_fd /= 1 | fclose_checked (out_file, out_fd))
 end;
diff --git a/src/godcc-format.a68 b/src/godcc-format.a68
index 10faf98..0285add 100644
--- a/src/godcc-format.a68
+++ b/src/godcc-format.a68
@@ -1,4 +1,4 @@
-# godcc-format.a68 - godcc format sub-command.
+{ godcc-format.a68 - godcc format sub-command.
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,19 +14,19 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 proc godcc_format = (int pos) void:
 begin
       string style, src_file, out_file;
 
-      # Some defaults.  #
+      { Some defaults.  }
       int tab_width := 4;
       bool use_spaces := false;
       string formatter := "clangformat";
       src_file := out_file := "-";
 
-      # Parse command-line options for the sub-command.  #
+      { Parse command-line options for the sub-command.  }
       argp (pos, []ArgOpt (("o", "", true,
                             (string arg) bool: (out_file := arg; true)),
                            ("f", "formatter", true,
@@ -45,31 +45,31 @@ begin
                 true),
             error);
 
-      # Determine the formatting style to use.  #
+      { Determine the formatting style to use.  }
       style := (style = ""
                 | (formatter = "clangformat" | "GNU")
                 | style);
 
-      # Open the input file and read its contents.  #
+      { Open the input file and read its contents.  }
       ref string src = read_from_file (src_file);
 
-      # Prepare the JSON query.  #
+      { Prepare the JSON query.  }
       JSON_Val cmd := json_new_obj;
       cmd->"source" := json_escape_string (src);
       cmd->"base" := style;
       cmd->"useSpaces" := use_spaces;
       cmd->"tabWidth" := tab_width;
 
-      # Query the server.  #
+      { Query the server.  }
       ce_connect;
       JSON_Val res := ce_post_json ("format/" + formatter, cmd);
       ce_disconnect;
 
-      # Process the response.  #
+      { Process the response.  }
       string answer = json_str (res->"answer");
       int exit_status = json_int (res->"exit");
       (exit_status /= 0 | error (answer));
 
-      # Write the formatted code to the output file.  #
+      { Write the formatted code to the output file.  }
       write_to_file (out_file, answer)
 end;
diff --git a/src/godcc-list.a68 b/src/godcc-list.a68
index 849212b..c17537e 100644
--- a/src/godcc-list.a68
+++ b/src/godcc-list.a68
@@ -1,4 +1,4 @@
-# godcc-list.a68 - godcc list sub-command.
+{ godcc-list.a68 - godcc list sub-command.
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,7 +14,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 proc godcc_list = (int pos) void:
 begin
diff --git a/src/godcc.a68 b/src/godcc.a68
index 2e93592..0fdce65 100644
--- a/src/godcc.a68
+++ b/src/godcc.a68
@@ -1,4 +1,4 @@
-# godcc - A command-line front-end to Compiler Explorer.
+{ godcc - A command-line front-end to Compiler Explorer.
   Because the web is lame and sucks so much it hurts.
 
   Copyright (C) 2025 Jose E. Marchesi
@@ -15,11 +15,11 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 begin string godcc_version = "1.0";
       
-      # Include some facilities.  #
+      { Include some facilities.  }
 
       pr include "utils.a68" pr
       pr include "argp.a68" pr
@@ -31,13 +31,13 @@ begin string godcc_version = "1.0";
       pr include "godcc-compile.a68" pr
       pr include "godcc-format.a68" pr
       
-      # Configuration.  #
+      { Configuration.  }
 
       ce_host := getenv ("GODCC_CEHOST");
       ce_port := atoi (getenv ("GODCC_CEPORT"), 10);
       json_error := error;
 
-      # Diagnostics.  #
+      { Diagnostics.  }
 
       bool be_quiet := false;
 
@@ -53,7 +53,7 @@ begin string godcc_version = "1.0";
       proc errorno = (string msg) void:
          (error (msg + ": " + strerror (errno)));
 
-      # A few checked operations to keep code clean.  #
+      { A few checked operations to keep code clean.  }
 
       proc fopen_checked = (string path, bits flags) int:
          (int res = fopen (path, flags);
@@ -75,7 +75,7 @@ begin string godcc_version = "1.0";
          (long long int res = fsize (fd);
           (res = - long long 1 | errorno ("getting size of file " + path); skip | res));
 
-      # --help and --version  #
+      { --help and --version  }
 
       proc do_help = (string arg) bool:
       begin puts ("\
@@ -117,7 +117,7 @@ Report bugs to: jemarch@gnu.org'n");
             false
       end;
 
-      # Main program.  #
+      { Main program.  }
 
       argp (2, []ArgOpt ((" ", "help", false, do_help),
                          (" ", "version", false, do_version),
diff --git a/src/http.a68 b/src/http.a68
index e603931..df9c7e4 100644
--- a/src/http.a68
+++ b/src/http.a68
@@ -1,4 +1,4 @@
-# http.a68 - HTTP support
+{ http.a68 - HTTP support
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,20 +14,20 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
-# An HTTP header contains a set of properties encoded in the form of
+{ An HTTP header contains a set of properties encoded in the form of
   pair of strings, that describe the encoding of the data sent and
   received to/from an HTTP server, identify the client, and other
   purposes.
 
   For each header, N is the name and V is the value.  The HTTP
   protocol defines the set of meaningful headers.
-#
+}
 
 mode HTTP_Hdr = struct (string n, v);
 
-# Perform a GET request to a web server.
+{ Perform a GET request to a web server.
 
   SOCKET is an open file descriptor that communicates with the web
   server.
@@ -47,26 +47,26 @@ mode HTTP_Hdr = struct (string n, v);
 
   If FRAGMENTED is false, then the request response will be notified
   to the caller via a single call to the callback procedure H.
-#
+}
 
 proc http_get = (int socket, string uri,
                  []struct (string n, v) headers,
                  proc(int,int,int)void response,
                  bool fragmented) void:
-begin # Prepare the header to send.  #
+begin { Prepare the header to send.  }
       string msg := "GET " + uri + " HTTP/1.1'r'n";
       for i to UPB headers
       do msg +:= (n of headers[i]) + ": " + (v of headers[i]);
          msg +:= "'r'n"
       od;
       msg +:= "'r'n";
-      # Send it.  #
+      { Send it.  }
       fputs (socket, msg);
-      # Collect answer from server.  #
+      { Collect answer from server.  }
       http_process_response (socket, response, fragmented)
 end;
 
-# Perform a POST request to a web server.
+{ Perform a POST request to a web server.
 
   SOCKET is an open file descriptor that communicates with the web
   server.
@@ -94,25 +94,25 @@ end;
 
   If FRAGMENTED is false, then the request response will be notified
   to the caller via a single call to the callback procedure H.
-#
+}
 
 proc http_post = (int socket, string uri,
                   []struct (string n, v) headers,
                   union(string,proc(ref bool)string) contents,
                   proc(int,int,int)void response,
                   bool fragmented) void:
-begin # Mount the HTTP header from the user-provided headers.  #
+begin { Mount the HTTP header from the user-provided headers.  }
       string hdr := "POST " + uri + " HTTP/1.1'r'n";
       for i to UPB headers
       do hdr +:= (n of headers[i]) + ": " + (v of headers[i]);
          hdr +:= "'r'n"
       od;
-      # Let server know how contents will be transmitted.  #
+      { Let server know how contents will be transmitted.  }
       hdr +:= ((contents
                 | (string s): "Content-Length: " + itoa (UPB s, 10)
                 | "Transfer-Encoding: chunked")
                + "'r'n");
-      # Send the header and the contents to the server.  #
+      { Send the header and the contents to the server.  }
       fputs (socket, hdr);
       fputs (socket, "'r'n");
       case contents
@@ -121,31 +121,31 @@ begin # Mount the HTTP header from the user-provided headers.  #
             begin while bool done;
                         string some_content = cb (done);
                         NOT done
-                  do # Send chunk.  #
+                  do { Send chunk.  }
                      fputs (socket, itoa (UPB some_content, 16));
                      fputs (socket, "'r'n");
                      fputs (socket, some_content);
                      fputs (socket, "'r'n")
                   od;
-                  # Send last, empty chunk and trailer empty line.  #
+                  { Send last, empty chunk and trailer empty line.  }
                   fputs (socket, "0'r'n");
                   fputs (socket, "'r'n")
             end
       esac;
-      # Collect answer from server.  #
+      { Collect answer from server.  }
       http_process_response (socket, response, fragmented)
 end;
 
-# Collect data from an HTTP server in SOCKET once a GET or POST
+{ Collect data from an HTTP server in SOCKET once a GET or POST
   request has been sent to the server, parse its header and call back
   to H so it will process the whole response.  FRAGMENTED determines
   whether the response is handled with several calls to H, or just one
-  call. #
+  call. }
 
 proc http_process_response = (int socket,
                               proc(int,int,int)void h,
                               bool fragmented) void:
-begin # First the header.  #
+begin { First the header.  }
       int content_length := 0, bool read_chunks := false;
       while string line := fgets (socket, 0);
             line /= "'r'n"
@@ -155,31 +155,31 @@ begin # First the header.  #
          then read_chunks := true
          fi
       od;
-      # Then the data.  #
+      { Then the data.  }
       if read_chunks
       then while string line = fgets (socket, 0);
                  int size = atoi (line, 16);
                  h ((size = 0 | 0 | -1), size, socket);
-                 fgetc (socket); fgetc (socket); # 'r'n  #
+                 fgetc (socket); fgetc (socket); { 'r'n }
                  size /= 0
            do ~ od;
            h (0, 0, socket)
       else if content_length = 0
            then error ("couldn''t find Content-Length header in response") fi;
            if fragmented
-           then # Call the handler to process the data in chunks.
-                  Eighty is arbitrary, roughly a line size.  #
+           then { Call the handler to process the data in chunks.
+                  Eighty is arbitrary, roughly a line size.  }
                 for i to content_length % 80
                 do h (content_length - i * 80, 80, socket) od;
                 h (0, content_length %* 80, socket)
-           else # Call the handler to process the data in one go.  #
+           else { Call the handler to process the data in one go.  }
                 h (0, content_length, socket)
            fi
       fi
 end;
 
-# Return a string with the given string URL encoded in HTTP URL
-  encoding.  #
+{ Return a string with the given string URL encoded in HTTP URL
+  encoding.  }
 
 proc http_escape_url = (string url) string:
 begin string res, char sharp = REPR 35;
diff --git a/src/json.a68 b/src/json.a68
index 2498c32..68356ef 100644
--- a/src/json.a68
+++ b/src/json.a68
@@ -1,4 +1,4 @@
-# json.a68 - JSON support
+{ json.a68 - JSON support.
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -7,16 +7,16 @@
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
 
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
 
   You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+  along with this program.  If not, see
+  <http://www.gnu.org/licenses/>.  }
 
-# JSON values.
+{ JSON values.
 
   Numbers and boolean values are handled as obvious.
   The "null" JSON value is expressed as an empty union.
@@ -25,8 +25,7 @@
   JSON values.
 
   JSON objects are unordered collections of fields, which are
-  name/value pairs.
-#
+  name/value pairs.  }
 
 mode JSON_Val = union (void,bool,int,string,ref JSON_Arr,ref JSON_Obj),
      JSON_Arr = struct (ref JSON_Elm elements),
@@ -34,26 +33,26 @@ mode JSON_Val = union (void,bool,int,string,ref JSON_Arr,ref JSON_Obj),
      JSON_Elm = struct (JSON_Val value, ref JSON_Elm next),
      JSON_Fld = struct (JSON_Val name, value, ref JSON_Fld next);
 
-# Nihils.  #
+{ Nihils.  }
 
 ref JSON_Val json_no_val = nil;
 ref JSON_Elm json_no_elm = nil;
 ref JSON_Fld json_no_fld = nil;
 
-# The following procedures are intended to be used as initialization
-  values for JSON_Val variable initializations or ascriptions.  #
+{ The following procedures are intended to be used as initialization
+  values for JSON_Val variable initializations or ascriptions.  }
 
 proc json_new_obj = JSON_Val: heap JSON_Obj;
 proc json_new_arr = JSON_Val: heap JSON_Arr;
 
-# Error handling procedure.
+{ Error handling procedure.
 
   The default version aborts with an assert, but users of this library
-  can set it to handler of their own.  #
+  can set it to handler of their own.  }
 
 proc(string)void json_error := (string msg) void: (assert (false));
 
-# The operator -> gets a JSON value, which must be an object, and a
+{ The operator -> gets a JSON value, which must be an object, and a
   field name, and returns a name referring to the field of that name
   stored in the object.  If there is no such a field, one is created
   with associated value "empty".
@@ -69,7 +68,7 @@ proc(string)void json_error := (string msg) void: (assert (false));
   register_address (obj->"address");
 
   If the given JSON value is not an object then this procedure calls
-  the json error handling routine.  #
+  the json error handling routine.  }
 
 prio -> = 9;
 op -> = (JSON_Val v, string fname) ref JSON_Val:
@@ -83,8 +82,8 @@ op -> = (JSON_Val v, string fname) ref JSON_Val:
                   fi
                od;
                if field :=: json_no_fld
-               then # Create a new field with a new "null" element and
-                      link to the object.  #
+               then { Create a new field with a new "null" element and
+                      link to the object.  }
                     field := heap JSON_Fld := (fname, empty, fields of o);
                     ref ref JSON_Fld (fields of o) := field
                fi;
@@ -94,7 +93,7 @@ op -> = (JSON_Val v, string fname) ref JSON_Val:
        skip
    esac;
 
-# Return a string with the written form of the given JSON value.  #
+{ Return a string with the written form of the given JSON value.  }
 
 proc json_to_string = (JSON_Val val) string:
    case val
@@ -120,18 +119,17 @@ proc json_to_string = (JSON_Val val) string:
                                res) + "}"
    esac;
 
-# Parse a JSON object reading at most MAXCHARS characters read from
+{ Parse a JSON object reading at most MAXCHARS characters read from
   the file descriptor FD.
 
   In case of a parse error the callback ERROR is invoked with a
   description of the problem passed as an argument, and this procedure
-  returns immediately.
-#
+  returns immediately.  }
 
 proc json_from_fd = (int maxchars, int fd,
                      proc(string)void error) JSON_Val:
 begin
-      # Simple stream of characters with EOF and error detection. #
+      { Simple stream of characters with EOF and error detection.  }
 
       char eof = invalid_char;
       char ungetch := eof, ch;
@@ -149,7 +147,7 @@ begin
       proc ungetchar = (char c) void:
          ungetch := c;
 
-      # A few utility routines.  #
+      { A few utility routines.  }
 
       proc expect = (string s) void:
          for i to UPB s
@@ -165,7 +163,7 @@ begin
          else json_error (msg + ", found ''" + ch + "''")
          fi;
 
-      # Parse a single JSON value.  #
+      { Parse a single JSON value.  }
 
       proc parse_value = (int charsleft) JSON_Val:
       begin
@@ -203,7 +201,7 @@ begin
                   do ungetchar (ch);
                      if i > 1 then ungetchar (ch); expect (",") fi;
                      JSON_Val val = parse_value (charsleft - usedchars);
-                     # Array elements should keep written order.  #
+                     { Array elements should keep written order.  }
                      elems := (elems :=: json_no_elm
                                | heap JSON_Elm := (val, nil)
                                | (ref JSON_Elm e := elems;
@@ -247,12 +245,12 @@ begin
       parse_value (maxchars)
 end;
 
-# Determine whether the given JSON value is the "null" value.  #
+{ Determine whether the given JSON value is the "null" value.  }
 
 proc json_is_null = (JSON_Val v) bool:
    (v | (void): true | false);
 
-# Extract algol 68 values from JSON values.  #
+{ Extract algol 68 values from JSON values.  }
 
 proc json_int = (JSON_Val v) int:
    (v | (int i): i | json_error ("expected integer in json str"); skip);
@@ -260,9 +258,9 @@ proc json_int = (JSON_Val v) int:
 proc json_str = (JSON_Val v) string:
    (v | (string s): s | json_error ("expected string in json str"); skip);
 
-# Invoke a callback H for each element in the given JSON array V.  The
+{ Invoke a callback H for each element in the given JSON array V.  The
   elements are traversed in order.  If V is not an array then this
-  procedure does nothing.  #
+  procedure does nothing.  }
 
 proc json_foreach_elem = (JSON_Val v, proc(ref JSON_Val)void h) void:
    case v
@@ -274,7 +272,7 @@ proc json_foreach_elem = (JSON_Val v, proc(ref JSON_Val)void h) void:
           od)
    esac;
 
-# Encode a given string STR as a JSON string literal.  #
+{ Encode a given string STR as a JSON string literal.  }
 
 proc json_escape_string = (string str) string:
 begin string res;
diff --git a/src/utils.a68 b/src/utils.a68
index 5e3a299..f7aa35a 100644
--- a/src/utils.a68
+++ b/src/utils.a68
@@ -1,4 +1,4 @@
-# utils.a68 - Utility routines
+{ utils.a68 - Utility routines
 
   Copyright (C) 2025 Jose E. Marchesi
 
@@ -14,7 +14,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
+}
 
 proc isdigit = (char c) bool:
    ABS c >= ABS "0" AND ABS c <= ABS "9";
@@ -63,7 +63,7 @@ begin int res := 0, bool found := false;
       res
 end;
 
-# Read the contents of the file at the given PATH and return them as a
+{ Read the contents of the file at the given PATH and return them as a
   string.
 
   If PATH is - then read contents from the standard input.  Error out
@@ -73,7 +73,7 @@ end;
     is because the contents of the file can be rather large.  The
     string is allocated on the heap.  The returned reference allows
     the caller to modify the string. }
-#
+}
 
 proc read_from_file = (string path) ref string:
 begin int fd = (path = "-" | 0 | fopen_checked (path, file_o_rdonly));
@@ -82,12 +82,12 @@ begin int fd = (path = "-" | 0 | fopen_checked (path, file_o_rdonly));
       fgets (fd, SHORTEN SHORTEN fsize_checked (path, fd))
 end;
 
-# Create an output file in PATH and write the contents of the given
+{ Create an output file in PATH and write the contents of the given
   string CONTENTS to it.
 
   If PATH is - then write to the standard output.  Error out if the
   file cannot be created or written to.
-#
+}
 
 proc write_to_file = (string path, string contents) void:
 begin int fd = (path = "-" | 1 | fcreate_checked (path, 8r644));
-- 
2.30.2



More information about the Algol68 mailing list