poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] ras: allow splitting long lines with \


From: Jose E. Marchesi
Subject: [COMMITTED] ras: allow splitting long lines with \
Date: Sun, 02 Jan 2022 19:54:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)


2022-01-02  Jose E. Marchesi  <jemarch@gnu.org>

        * libpoke/ras: New rule to join continuation lines separated with
        \.
        * libpoke/pkl-gen.pks (struct_field_extractor): Split long lines.
        (struct_mapper): Likewise.
        (deint_extract_field_value): Likewise.
        (struct_deintegrator): Likewise.
---
 ChangeLog           |  9 +++++++++
 libpoke/pkl-gen.pks | 12 ++++++++----
 libpoke/ras         | 18 ++++++++++++++++++
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a1d54bb6..24aa5401 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2022-01-02  Jose E. Marchesi  <jemarch@gnu.org>
 
+       * libpoke/ras: New rule to join continuation lines separated with
+       \.
+       * libpoke/pkl-gen.pks (struct_field_extractor): Split long lines.
+       (struct_mapper): Likewise.
+       (deint_extract_field_value): Likewise.
+       (struct_deintegrator): Likewise.
+
+2022-01-02  Jose E. Marchesi  <jemarch@gnu.org>
+
        * libpoke/pkl-gen.pks (field_location_str): New macro.
        (check_struct_field_constraint): Use field_location_str.
        (struct_field_mapper): Add location error message when EOF is
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index 784bf2b4..b4cac576 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -646,7 +646,8 @@
 ;;; `vars_registered' is a size_t that contains the number
 ;;; of field-variables registered so far.
 
-        .macro struct_field_extractor @struct_type @field @struct_itype 
@field_type #ivalw #fieldw
+        .macro struct_field_extractor @struct_type @field @struct_itype \
+                                      @field_type #ivalw #fieldw
         nrot                            ; STRICT IVAL BOFF SBOFF
         ;; Calculate the amount of bits that we have to right-shift
         ;; IVAL in order to extract the portion of the value
@@ -886,7 +887,8 @@
         swap                     ; ...[EBOFF ENAME EVAL] STRICT NEBOFF
         pushvar $boff
         pushvar $ivalue          ; ...[EBOFF ENAME EVAL] STRICT NEBOFF OFF IVAL
-        .e struct_field_extractor @type_struct, @field, @struct_itype, 
@field_type, #ivalw, #fieldw
+        .e struct_field_extractor @type_struct, @field, @struct_itype, 
@field_type, \
+                                  #ivalw, #fieldw
                                  ; ...[EBOFF ENAME EVAL] NEBOFF
  .c   }
  .c   else
@@ -1752,7 +1754,8 @@
 
         .macro deint_extract_field_value @uint64_type @itype @field_type 
#bit_offset
         .let @field_type = PKL_AST_STRUCT_TYPE_FIELD_TYPE (@field)
-        .let @field_int_type = PKL_AST_TYPE_CODE (@field_type) == 
PKL_TYPE_OFFSET ? PKL_AST_TYPE_O_BASE_TYPE (@field_type) : @field_type
+        .let @field_int_type = PKL_AST_TYPE_CODE (@field_type) == 
PKL_TYPE_OFFSET ? \
+                               PKL_AST_TYPE_O_BASE_TYPE (@field_type) : 
@field_type
  .c     size_t field_type_size = PKL_AST_TYPE_I_SIZE (@field_int_type);
  .c     size_t itype_bits = PKL_AST_TYPE_I_SIZE (@itype);
         ;; Field extraction:
@@ -1877,7 +1880,8 @@
         .let #bit_offset = pvm_make_int (bit_offset, 32)
         ;; Extract the value for this field from IVAL
         pushvar $ival           ; SCT IVAL
-        .e deint_extract_field_value @uint64_type, @itype, @field_type, 
#bit_offset
+        .e deint_extract_field_value @uint64_type, @itype, @field_type, \
+                                     #bit_offset
                                 ; SCT CVAL
         .let #index = pvm_make_ulong (i, 64)
         push #index             ; SCT CVAL IDX
diff --git a/libpoke/ras b/libpoke/ras
index 4e0cee35..2e674e17 100755
--- a/libpoke/ras
+++ b/libpoke/ras
@@ -102,6 +102,15 @@
 # the function into a pvm_program, and install it into a PVM closure
 # value that is assigned to CLOSURE.
 #
+# Splitting Long Lines
+# --------------------
+#
+# Logical long lines can be splitted into several physical lines by
+# finishing them with the \ character.  This is an example:
+#
+#   .macro struct_field_extractor @struct_type @field @struct_itype \
+#                                 @field_type #ivalw #fieldw
+#
 # Expanding Macros
 # ----------------
 #
@@ -600,6 +609,15 @@ BEGIN {
 
 ## Miscellaneous rules
 
+# Allow splitting lines with \
+/\\$/ {
+    while ($0 ~ /\\$/)
+    {
+      getline record;
+      $0 = substr($0 , 0, length ($0) - 1) record;
+    }
+}
+
 # Keep blank lines (to improve readability)
 /^[ \t]*$/ {
     if (current_entity == "")
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]