guile-user
[Top][All Lists]
Advanced

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

Nyacc patches for Mes to avoid bundling?


From: Jan Nieuwenhuizen
Subject: Nyacc patches for Mes to avoid bundling?
Date: Wed, 03 May 2017 19:59:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Hi Matt,

Mes is now packaged in Guix.  It bundles a modified copy of
Nyacc-0.76.5.  It would like to package Nyacc separately and
depend on that, however, Mes cannot use Nyacc as is, at the
moment because of three Mes problems

   1) Mes has no regex
   2) Mes has no proper module system, there is only one environment
   3) For Mes I like simple pmatch better than match

Attached are the patches Mes is using right now.  I intend to fix 2) at
a certain point but haven't planned that yet.  I have no plans for 1),
I'd rather not support regexps if I can get away with it.  3) is
probably not mandatory, but it helps being lightweight.

How do you feel about supporting such shortcomings of Mes?  I can
imagine that's not a great thing to do, however Mes carrying a copy
of Nyacc is also not fantastic?

Greetings,
janneke

>From 83d4ff74d23d0143ecf4fc50b78e7fb68b618d97 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sun, 26 Mar 2017 23:09:44 +0200
Subject: [PATCH 1/3] nyacc: Add simple split-cppdef for Mes.

* module/nyacc/lang/c99/body.scm: Add non-regexp split-cppdef for Mes.
---
 module/nyacc/lang/c99/body.scm | 43 +++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/module/nyacc/lang/c99/body.scm b/module/nyacc/lang/c99/body.scm
index 5ddcd291..42698bd9 100644
--- a/module/nyacc/lang/c99/body.scm
+++ b/module/nyacc/lang/c99/body.scm
@@ -51,25 +51,30 @@
 ;; "MAX(X,Y)=((X)>(Y)?(X):(Y))" => ("MAX" ("X" "Y") . "((X)>(Y)?(X):(Y))")
 ;; @end example
 ;; @end deffn
-(define split-cppdef
-  (let ((rx1 (make-regexp "^([A-Za-z0-9_]+)\\([^)]*\\)=(.*)$"))
-       (rx2 (make-regexp "^([A-Za-z0-9_]+)=(.*)$")))
-    (lambda (defstr)
-      (let* ((m1 (regexp-exec rx1 defstr))
-            (m2 (or m1 (regexp-exec rx2 defstr))))
-       (cond
-        ((regexp-exec rx1 defstr) =>
-         (lambda (m)
-           (let* ((s1 (match:substring m1 1))
-                  (s2 (match:substring m1 2))
-                  (s3 (match:substring m1 3)))
-             (cons s1 (cons s2 s3)))))
-        ((regexp-exec rx2 defstr) =>
-         (lambda (m)
-           (let* ((s1 (match:substring m2 1))
-                  (s2 (match:substring m2 2)))
-             (cons s1 s2))))
-        (else #f))))))
+(cond-expand
+ (guile
+  (define split-cppdef
+    (let ((rx1 (make-regexp "^([A-Za-z0-9_]+)\\([^)]*\\)=(.*)$"))
+          (rx2 (make-regexp "^([A-Za-z0-9_]+)=(.*)$")))
+      (lambda (defstr)
+        (let* ((m1 (regexp-exec rx1 defstr))
+               (m2 (or m1 (regexp-exec rx2 defstr))))
+          (cond
+           ((regexp-exec rx1 defstr) =>
+            (lambda (m)
+              (let* ((s1 (match:substring m1 1))
+                     (s2 (match:substring m1 2))
+                     (s3 (match:substring m1 3)))
+                (cons s1 (cons s2 s3)))))
+           ((regexp-exec rx2 defstr) =>
+            (lambda (m)
+              (let* ((s1 (match:substring m2 1))
+                     (s2 (match:substring m2 2)))
+                (cons s1 s2))))
+           (else #f)))))))
+ (mes
+  (define (split-cppdef s)
+    (apply cons (string-split s #\=)))))
 
 ;; @deffn Procedure make-cpi debug defines incdirs inchelp
 ;; @end deffn
-- 
2.12.2

>From 2d109664d39d6dac75e2b0a792d8b860a2afe171 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Tue, 28 Mar 2017 20:26:16 +0200
Subject: [PATCH 2/3] nyacc: prefix globals.

---
 module/nyacc/lang/c99/body.scm           |  4 ++--
 module/nyacc/lang/c99/cpp.scm            | 10 +++++-----
 module/nyacc/lang/c99/mach.d/c99act.scm  |  2 +-
 module/nyacc/lang/c99/mach.d/c99tab.scm  |  8 ++++----
 module/nyacc/lang/c99/mach.d/c99xact.scm |  2 +-
 module/nyacc/lang/c99/mach.d/c99xtab.scm |  8 ++++----
 module/nyacc/lang/c99/mach.d/cppact.scm  |  2 +-
 module/nyacc/lang/c99/mach.d/cpptab.scm  |  8 ++++----
 module/nyacc/lang/c99/mach.scm           | 26 +++++++++++++-------------
 module/nyacc/lang/c99/parser.scm         | 16 ++++++++--------
 module/nyacc/lang/c99/xparser.scm        | 16 ++++++++--------
 11 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/module/nyacc/lang/c99/body.scm b/module/nyacc/lang/c99/body.scm
index 42698bd9..e467d397 100644
--- a/module/nyacc/lang/c99/body.scm
+++ b/module/nyacc/lang/c99/body.scm
@@ -251,7 +251,7 @@
   ;; will end up in same mode...  so after
   ;; int x; // comment
   ;; the lexer will think we are not at BOL.
-  (let* ((match-table mtab)
+  (let* ((match-table c99-mtab)
         (read-ident read-c-ident)
         (read-comm read-c-comm)
         ;;
@@ -394,7 +394,7 @@
                 (cond
                  ((apply-helper file)) ; use helper
                  ((not path) (p-err "not found: ~S" file)) ; file not found
-                 ((with-input-from-file path run-parse) => ; include tree
+                 ((with-input-from-file path c99-parser-run-parse) => ; 
include tree
                   (lambda (tree) (for-each add-define (xp1 tree))))
                  (else (p-err "included from ~S" path)))))
              ((define) (add-define stmt))
diff --git a/module/nyacc/lang/c99/cpp.scm b/module/nyacc/lang/c99/cpp.scm
index 898bf619..f493b259 100644
--- a/module/nyacc/lang/c99/cpp.scm
+++ b/module/nyacc/lang/c99/cpp.scm
@@ -140,10 +140,10 @@
 (include-from-path "nyacc/lang/c99/mach.d/cpptab.scm")
 (include-from-path "nyacc/lang/c99/mach.d/cppact.scm")
 
-(define raw-parser
+(define cpp-raw-parser
   (make-lalr-parser
-   (list (cons 'len-v len-v) (cons 'pat-v pat-v) (cons 'rto-v rto-v)
-        (cons 'mtab mtab) (cons 'act-v act-v))))
+   (list (cons 'len-v cpp-len-v) (cons 'pat-v cpp-pat-v) (cons 'rto-v 
cpp-rto-v)
+        (cons 'mtab cpp-mtab) (cons 'act-v cpp-act-v))))
 
 (define (cpp-err fmt . args)
   (apply throw 'cpp-error fmt args))
@@ -169,7 +169,7 @@
 
 ;; generate a lexical analyzer per string
 (define gen-cpp-lexer
-  (make-lexer-generator mtab #:comm-skipper cpp-comm-skipper))
+  (make-lexer-generator cpp-mtab #:comm-skipper cpp-comm-skipper))
 
 ;; @deffn parse-cpp-expr text => tree
 ;; Given a string returns a cpp parse tree.  This is called by
@@ -181,7 +181,7 @@
    'nyacc-error
    (lambda ()
      (with-input-from-string text
-       (lambda () (raw-parser (gen-cpp-lexer)))))
+       (lambda () (cpp-raw-parser (gen-cpp-lexer)))))
    (lambda (key fmt . args)
      (apply throw 'cpp-error fmt args))))
 
diff --git a/module/nyacc/lang/c99/mach.d/c99act.scm 
b/module/nyacc/lang/c99/mach.d/c99act.scm
index b6398085..f2734ccd 100644
--- a/module/nyacc/lang/c99/mach.d/c99act.scm
+++ b/module/nyacc/lang/c99/mach.d/c99act.scm
@@ -6,7 +6,7 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define act-v
+(define c99-act-v
   (vector
    ;; $start => translation-unit
    (lambda ($1 . $rest) $1)
diff --git a/module/nyacc/lang/c99/mach.d/c99tab.scm 
b/module/nyacc/lang/c99/mach.d/c99tab.scm
index ecb45c6c..07f6eff6 100644
--- a/module/nyacc/lang/c99/mach.d/c99tab.scm
+++ b/module/nyacc/lang/c99/mach.d/c99tab.scm
@@ -6,7 +6,7 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define len-v
+(define c99-len-v
   #(1 1 1 1 3 1 4 4 3 3 3 2 2 6 7 1 3 1 3 2 1 1 2 2 2 2 4 1 1 1 1 1 1 1 4 1 
     3 3 3 1 3 3 1 3 3 1 3 3 3 3 1 3 3 1 3 1 3 1 3 1 3 1 3 1 5 1 3 1 1 1 1 1 1 
     1 1 1 1 1 1 3 1 5 3 0 1 2 1 2 1 2 1 2 1 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
@@ -17,7 +17,7 @@
     1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 0 2 1 1 1 1 1 5 1 4 3 1 2 0 
     1 1 1 1 1 1 1 2 1 1 1 1))
 
-(define pat-v
+(define c99-pat-v
   #(((103 . 1) (182 . 2) (95 . -281) (-1 . -281)) ((22 . 3) (28 . 4) (29 . 5
     ) (30 . 6) (31 . 7) (32 . 8) (33 . 9) (34 . 10) (35 . 11) (36 . 12) (38 . 
     13) (37 . 14) (40 . 15) (24 . 16) (25 . 17) (26 . 18) (27 . 19) (138 . 20)
@@ -762,7 +762,7 @@
     110 . 199) (111 . 200) (112 . 201) (113 . 202) (114 . 203) (115 . 204) (
     116 . 205) (109 . 489)) ((-1 . -268)) ((-1 . -265)) ((-1 . -269))))
 
-(define rto-v
+(define c99-rto-v
   #(#f 177 177 177 177 176 176 176 176 176 176 176 176 176 176 175 175 175 
     175 171 171 168 168 168 168 168 168 167 167 167 167 167 167 166 166 165 
     165 165 165 164 164 164 163 163 163 162 162 162 162 162 161 161 161 160 
@@ -781,7 +781,7 @@
     105 105 105 104 104 111 111 111 111 111 182 103 103 102 102 102 102 102 
     102 102 101 101 99 99 151 151 181 181 180 180 180 179 179 98 134 110 100))
 
-(define mtab
+(define c99-mtab
   '((cpp-pragma . 1) (cpp-stmt . 2) ($chlit . 3) ($float . 4) ($fixed . 5) (
     cpp-ident . 6) ($ident . 7) ($string . 8) ("return" . 9) ("break" . 10) (
     "continue" . 11) ("goto" . 12) ("for" . 13) ("do" . 14) ("while" . 15) (
diff --git a/module/nyacc/lang/c99/mach.d/c99xact.scm 
b/module/nyacc/lang/c99/mach.d/c99xact.scm
index f9c6e12f..0174e682 100644
--- a/module/nyacc/lang/c99/mach.d/c99xact.scm
+++ b/module/nyacc/lang/c99/mach.d/c99xact.scm
@@ -6,7 +6,7 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define act-v
+(define c99x-act-v
   (vector
    ;; $start => expression
    (lambda ($1 . $rest) $1)
diff --git a/module/nyacc/lang/c99/mach.d/c99xtab.scm 
b/module/nyacc/lang/c99/mach.d/c99xtab.scm
index 850ac23a..f8152eed 100644
--- a/module/nyacc/lang/c99/mach.d/c99xtab.scm
+++ b/module/nyacc/lang/c99/mach.d/c99xtab.scm
@@ -6,7 +6,7 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define len-v
+(define c99x-len-v
   #(1 1 1 1 3 1 4 4 3 3 3 2 2 6 7 1 3 1 3 2 1 1 2 2 2 2 4 1 1 1 1 1 1 1 4 1 
     3 3 3 1 3 3 1 3 3 1 3 3 3 3 1 3 3 1 3 1 3 1 3 1 3 1 3 1 5 1 3 1 1 1 1 1 1 
     1 1 1 1 1 1 3 1 5 3 0 1 2 1 2 1 2 1 2 1 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
@@ -17,7 +17,7 @@
     1 2 1 1 2 1 5 7 5 5 7 8 2 1 1 0 1 3 2 2 3 2 1 0 2 1 1 1 1 1 5 1 4 3 1 2 0 
     1 1 1 1 1 1 1 2 1 1 1 1))
 
-(define pat-v
+(define c99x-pat-v
   #(((166 . 1) (165 . 2) (164 . 3) (163 . 4) (162 . 5) (161 . 6) (160 . 7) (
     8 . 8) (3 . 9) (4 . 10) (5 . 11) (6 . 12) (7 . 13) (159 . 14) (158 . 15) (
     179 . 16) (180 . 17) (181 . 18) (157 . 19) (76 . 20) (77 . 21) (78 . 22) (
@@ -517,7 +517,7 @@
     . -239)) ((84 . -236) (83 . -236)) ((92 . -206) (83 . -206)) ((90 . 378))
     ((-1 . -187)) ((90 . 377)) ((-1 . -181)) ((-1 . -186)) ((-1 . -185))))
 
-(define rto-v
+(define c99x-rto-v
   #(#f 177 177 177 177 176 176 176 176 176 176 176 176 176 176 175 175 175 
     175 171 171 168 168 168 168 168 168 167 167 167 167 167 167 166 166 165 
     165 165 165 164 164 164 163 163 163 162 162 162 162 162 161 161 161 160 
@@ -536,7 +536,7 @@
     105 105 105 104 104 111 111 111 111 111 182 103 103 102 102 102 102 102 
     102 102 101 101 99 99 151 151 181 181 180 180 180 179 179 98 134 110 100))
 
-(define mtab
+(define c99x-mtab
   '((cpp-pragma . 1) (cpp-stmt . 2) ($chlit . 3) ($float . 4) ($fixed . 5) (
     cpp-ident . 6) ($ident . 7) ($string . 8) ("return" . 9) ("break" . 10) (
     "continue" . 11) ("goto" . 12) ("for" . 13) ("do" . 14) ("while" . 15) (
diff --git a/module/nyacc/lang/c99/mach.d/cppact.scm 
b/module/nyacc/lang/c99/mach.d/cppact.scm
index 2a448545..61b668dc 100644
--- a/module/nyacc/lang/c99/mach.d/cppact.scm
+++ b/module/nyacc/lang/c99/mach.d/cppact.scm
@@ -6,7 +6,7 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define act-v
+(define cpp-act-v
   (vector
    ;; $start => conditional-expression
    (lambda ($1 . $rest) $1)
diff --git a/module/nyacc/lang/c99/mach.d/cpptab.scm 
b/module/nyacc/lang/c99/mach.d/cpptab.scm
index 3e4c4461..270f676c 100644
--- a/module/nyacc/lang/c99/mach.d/cpptab.scm
+++ b/module/nyacc/lang/c99/mach.d/cpptab.scm
@@ -6,11 +6,11 @@
 ;; or any later version published by the Free Software Foundation.  See
 ;; the file COPYING included with the this distribution.
 
-(define len-v
+(define cpp-len-v
   #(1 1 5 1 3 1 3 1 3 1 3 1 3 1 3 3 1 3 3 3 3 1 3 3 1 3 3 1 3 3 3 1 2 2 2 2 
     2 2 1 2 2 1 1 1 4 2 3 1 3))
 
-(define pat-v
+(define cpp-pat-v
   #(((3 . 1) (4 . 2) (5 . 3) (6 . 4) (7 . 5) (37 . 6) (8 . 7) (9 . 8) (10 . 
     9) (11 . 10) (16 . 11) (15 . 12) (38 . 13) (39 . 14) (40 . 15) (41 . 16) (
     42 . 17) (43 . 18) (44 . 19) (45 . 20) (46 . 21) (47 . 22) (48 . 23) (49 
@@ -95,12 +95,12 @@
     . 19) (45 . 20) (46 . 21) (47 . 22) (48 . 23) (49 . 24) (50 . 82)) ((-1 . 
     -44)) ((2 . -48) (1 . -48)) ((2 . -2) (1 . -2) (35 . -2))))
 
-(define rto-v
+(define cpp-rto-v
   #(#f 50 50 49 49 48 48 47 47 46 46 45 45 44 44 44 43 43 43 43 43 42 42 42 
     41 41 41 40 40 40 40 39 39 39 39 39 39 39 38 38 38 37 37 37 37 37 37 36 36
     ))
 
-(define mtab
+(define cpp-mtab
   '(("," . 1) (")" . 2) ("(" . 3) ("defined" . 4) ($chlit . 5) ($fixed . 6) 
     ($ident . 7) ("--" . 8) ("++" . 9) ("~" . 10) ("!" . 11) ("%" . 12) ("/" 
     . 13) ("*" . 14) ("-" . 15) ("+" . 16) (">>" . 17) ("<<" . 18) (">=" . 19)
diff --git a/module/nyacc/lang/c99/mach.scm b/module/nyacc/lang/c99/mach.scm
index 7da13037..f20c1a04 100644
--- a/module/nyacc/lang/c99/mach.scm
+++ b/module/nyacc/lang/c99/mach.scm
@@ -672,22 +672,22 @@
 ;;; =====================================
 
 ;; The following are needed by the code in pbody.scm.
-(define len-v (assq-ref c99-mach 'len-v))
-(define pat-v (assq-ref c99-mach 'pat-v))
-(define rto-v (assq-ref c99-mach 'rto-v))
-(define mtab (assq-ref c99-mach 'mtab))
-(define act-v (vector-map
-              (lambda (ix f) (eval f (current-module)))
-              (vector-map (lambda (ix actn) (wrap-action actn))
-                          (assq-ref c99-mach 'act-v))))
+(define c99-mach-len-v (assq-ref c99-mach 'len-v))
+(define c99-mach-pat-v (assq-ref c99-mach 'pat-v))
+(define c99-mach-rto-v (assq-ref c99-mach 'rto-v))
+(define c99-mach-mtab (assq-ref c99-mach 'mtab))
+(define c99-mach-act-v (vector-map
+                        (lambda (ix f) (eval f (current-module)))
+                        (vector-map (lambda (ix actn) (wrap-action actn))
+                                    (assq-ref c99-mach 'act-v))))
 
 (include-from-path "nyacc/lang/c99/body.scm")
 
-(define raw-parser (make-lalr-parser c99-mach))
+(define c99-mach-raw-parser (make-lalr-parser c99-mach))
 
-(define (run-parse)
+(define (c99-mach-run-parse)
   (let ((info (fluid-ref *info*)))
-    (raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
+    (c99-mach-raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
 
 (define* (dev-parse-c99 #:key
                        (cpp-defs '())  ; CPP defines
@@ -703,8 +703,8 @@
        (with-fluid*
           *info* info
           (lambda ()
-            (raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
-                        #:debug debug)))))
+            (c99-mach-raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
+                                  #:debug debug)))))
    (lambda (key fmt . rest)
      (report-error fmt rest)
      #f)))
diff --git a/module/nyacc/lang/c99/parser.scm b/module/nyacc/lang/c99/parser.scm
index 532991b5..ade8b59d 100644
--- a/module/nyacc/lang/c99/parser.scm
+++ b/module/nyacc/lang/c99/parser.scm
@@ -38,11 +38,11 @@
 
 ;; Parse given a token generator.  Uses fluid @code{*info*}.
 ;; A little ugly wrt re-throw but
-(define raw-parser
+(define c99-raw-parser
   (let ((parser (make-lalr-parser
-                    (list (cons 'len-v len-v) (cons 'pat-v pat-v)
-                          (cons 'rto-v rto-v) (cons 'mtab mtab)
-                          (cons 'act-v act-v)))))
+                    (list (cons 'len-v c99-len-v) (cons 'pat-v c99-pat-v)
+                          (cons 'rto-v c99-rto-v) (cons 'mtab c99-mtab)
+                          (cons 'act-v c99-act-v)))))
     (lambda* (lexer #:key (debug #f))
       (catch
        'nyacc-error
@@ -53,9 +53,9 @@
         (throw 'c99-error "C99 parse error"))))))
 
 ;; This is used to parse included files at top level.
-(define (run-parse)
+(define (c99-parser-run-parse)
   (let ((info (fluid-ref *info*)))
-    (raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
+    (c99-raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
 
 ;; @deffn {Procedure} parse-c99 [#:cpp-defs def-a-list] [#:inc-dirs dir-list] \
 ;;               [#:mode ('code|'file)] [#:debug bool]
@@ -86,8 +86,8 @@
        (with-fluid*
           *info* info
           (lambda ()
-            (raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
-                        #:debug debug)))))
+            (c99-raw-parser (gen-c-lexer #:mode mode #:xdef? xdef?)
+                             #:debug debug)))))
    (lambda (key fmt . rest)
      (report-error fmt rest)
      #f)))
diff --git a/module/nyacc/lang/c99/xparser.scm 
b/module/nyacc/lang/c99/xparser.scm
index b30065e0..72ea1623 100644
--- a/module/nyacc/lang/c99/xparser.scm
+++ b/module/nyacc/lang/c99/xparser.scm
@@ -32,11 +32,11 @@
 (include-from-path "nyacc/lang/c99/mach.d/c99xact.scm")
 
 ;; Parse given a token generator.  Uses fluid @code{*info*}.
-(define raw-parser
+(define c99x-raw-parser
   (let ((parser (make-lalr-parser 
-                (list (cons 'len-v len-v) (cons 'pat-v pat-v)
-                      (cons 'rto-v rto-v) (cons 'mtab mtab)
-                      (cons 'act-v act-v)))))
+                (list (cons 'len-v c99x-len-v) (cons 'pat-v c99x-pat-v)
+                      (cons 'rto-v c99x-rto-v) (cons 'mtab c99x-mtab)
+                      (cons 'act-v c99x-act-v)))))
     (lambda* (lexer #:key (debug #f))
       (catch
        'nyacc-error
@@ -46,9 +46,9 @@
         (pop-input)                    ; not sure this is right
         (throw 'c99-error "C99 parse error"))))))
 
-(define (run-parse)
+(define (c99x-run-parse)
   (let ((info (fluid-ref *info*)))
-    (raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
+    (c99x-raw-parser (gen-c-lexer) #:debug (cpi-debug info))))
 
 ;; @item {Procedure} parse-c99x [#:cpp-defs defs] [#:debug bool]
 ;; This needs to be explained in some detail.
@@ -70,8 +70,8 @@
           (with-fluid*
               *info* info
               (lambda ()
-                (raw-parser (gen-c-lexer #:mode 'code #:xdef? xdef?)
-                            #:debug debug)))))
+                (c99x-raw-parser (gen-c-lexer #:mode 'code #:xdef? xdef?)
+                                  #:debug debug)))))
        (lambda (key fmt . rest)
         (report-error fmt rest)
         #f)))))
-- 
2.12.2

>From 47e3551772fe4181632d69f7d601035c73f2ee02 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sat, 1 Apr 2017 12:16:09 +0200
Subject: [PATCH 3/3] nyacc: Use pmatch rather than match for cpp.

* module/nyacc/lang/c99/cpp.scm (nyacc lang c99 cpp): Import (system
  base pmatch) rather than (ice-9 match).
  (rtokl->string): Rewrite using pmatch.
---
 module/nyacc/lang/c99/cpp.scm | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/module/nyacc/lang/c99/cpp.scm b/module/nyacc/lang/c99/cpp.scm
index f493b259..0de592ba 100644
--- a/module/nyacc/lang/c99/cpp.scm
+++ b/module/nyacc/lang/c99/cpp.scm
@@ -29,7 +29,7 @@
   #:use-module (nyacc lex)
   #:use-module (nyacc lang util)
   #:use-module (rnrs arithmetic bitwise)
-  #:use-module (ice-9 match)
+  #:use-module (system base pmatch)
   )
 
 (cond-expand
@@ -259,40 +259,40 @@
      ((null? tkl) (apply string-append (add-chl chl stl)))
      ((char? (car tkl)) (iter stl (cons (car tkl) chl) nxt (cdr tkl)))
      (else
-      (match tkl
-       ((('arg . arg) 'dhash (key . val) . rest)
+      (pmatch tkl
+       (((arg . ,arg) dhash (,key . ,val) . ,rest)
         (iter stl chl nxt
               (acons key (string-append val arg) (list-tail tkl 3))))
 
-       (((key . val) 'dhash ('arg . arg) . rest)
+       (((,key . ,val) dhash (arg . ,arg) . ,rest)
         (iter stl chl nxt
               (acons 'arg (string-append arg val) (list-tail tkl 3))))
 
-       ((('arg . arg) 'hash . rest)
+       (((arg . ,arg) hash . ,rest)
         (iter stl chl (string-append "\"" arg "\"") (list-tail tkl 2)))
 
-       ((('comm . val) . rest)
+       (((comm . ,val) . ,rest)
         (iter stl chl (string-append "/*" val " */") (cdr tkl)))
 
-       ((('ident . rval) ('ident . lval) . rest)
+       (((ident . ,rval) (ident . ,lval) . ,rest)
         (iter stl chl (string-append " " rval) (cdr tkl)))
 
-       ((('string . val) . rest)
+       (((string . ,val) . ,rest)
         (iter stl (cons #\" chl) val (cons #\" rest)))
 
-       ((('ident . val) . rest)
+       (((ident . ,val) . ,rest)
         (iter stl chl val rest))
 
-       ((('arg . val) . rest)
+       (((arg . ,val) . ,rest)
         (iter stl chl val rest))
 
-       ((('defined . val) . rest)
+       (((defined . ,val) . ,rest)
         (iter stl chl val rest))
 
-       (('space . rest)
+       ((space . ,rest)
         (iter stl (cons #\space chl) nxt rest))
 
-       ((asis . rest)
+       ((,asis . ,rest)
         (iter stl chl asis rest))
 
        (otherwise
-- 
2.12.2

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ®  http://AvatarAcademy.nl  

reply via email to

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