nyacc: prefix globals.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 28 Mar 2017 18:26:16 +0000 (20:26 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 28 Mar 2017 18:26:16 +0000 (20:26 +0200)
module/nyacc/lang/c99/body.scm
module/nyacc/lang/c99/cpp.scm
module/nyacc/lang/c99/mach.d/c99act.scm
module/nyacc/lang/c99/mach.d/c99tab.scm
module/nyacc/lang/c99/mach.d/c99xact.scm
module/nyacc/lang/c99/mach.d/c99xtab.scm
module/nyacc/lang/c99/mach.d/cppact.scm
module/nyacc/lang/c99/mach.d/cpptab.scm
module/nyacc/lang/c99/mach.scm
module/nyacc/lang/c99/parser.scm
module/nyacc/lang/c99/xparser.scm

index 42698bd939dfeef1cbd0754ac0e576902752d419..e467d3975062e458203d38db599c979b31c084d1 100644 (file)
   ;; 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)
         ;;
                 (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))
index 12c85d90f7006d0d71ade80bfb40530ec630581b..0de592bafd93e59c47f633e5afeebdcfcc660fbd 100644 (file)
 (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))
 
 ;; 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
    '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))))
 
index b63980851fbb222e17364856868cb163f24806a3..f2734ccdb947ee83a4d627a082ec790d00262c6f 100644 (file)
@@ -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)
index ecb45c6c5ca264e48fde5dcc994a11fc821f89bb..07f6eff67cabd63dd07200bb84393a1389b92acf 100644 (file)
@@ -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)
     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 
     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) (
index f9c6e12f7a0c3ce8be53c0b9d6a204f2530204b0..0174e682fff987f27f166ec55bebced8af780b82 100644 (file)
@@ -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)
index 850ac23a0c0797953f18575b7203e7ccd374d38c..f8152eed9d6f2dd3b7d827b5984605b270cd9a7d 100644 (file)
@@ -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) (
     . -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 
     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) (
index 2a44854588fdee0da9a0a7eb3f1b5941bb595520..61b668dca8e89b13ec297f10acfce76f6b1947e8 100644 (file)
@@ -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)
index 3e4c44612fd35f31c4f8da642ae9e31d70dc273e..270f676cd7fd98a9ea4ae6fd7852fbfbc32b4ef6 100644 (file)
@@ -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 
     . 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)
index 7da130376fe85e06d8bfa58faf44ba8fb30d8975..f20c1a046d435ef3633dc3365d6c47b512056102 100644 (file)
 ;;; =====================================
 
 ;; 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
        (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)))
index 532991b502730bc05e8086d037432a34823b968f..ade8b59d57b30dc349826d0edf5132eb33cd888f 100644 (file)
 
 ;; 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)))
index b30065e000cd876e39f7110ea84b6ab9f9ecfd01..72ea1623848ec9dca32174b570e88ac3a1a12188 100644 (file)
 (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)))))