summaryrefslogtreecommitdiff
path: root/modules/language/python/parser-tool.scm
blob: 75da4298445c88ed5a5258b24e2848ee76ba2143 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(define-module (language python parser-tool)
  #:use-module (ice-9 pretty-print)
  #:use-module (logic guile-log parsing scanner)
  #:use-module ((logic guile-log parser)
		#:select (setup-parser
			  f-nl f-nl!			  
			  *current-file-parsing*
			  make-file-reader file-next-line file-skip))
  #:use-module (logic guile-log)
  #:re-export (f-nl f-nl!)
  #:export (f-seq f-seq! f-or f-or! f-not f-not! f-true f-false f-cons f-cons*
		  f-list INDENT <p-lambda> f* ff* ff? f? ff+ f+
		  f-reg f-reg! f-tag f-tag! f-eof f-out f-and f-and!
		  mk-token p-freeze parse f-append
		  .. xx <p-cc>
		  f-pk))

;; Preliminary
(define do-print #f)
(define pp
  (case-lambda
    ((s x)
     (when do-print
       (pretty-print `(,s ,(syntax->datum x))))
     x)
    ((x)
     (when do-print
       (pretty-print (syntax->datum x)))
     x)))


(begin
  (define-guile-log-parser-tool (<p-lambda> (X XL N M INDENT)) <p-define> .. 
    xx <p-cc>)


  (make-guile-log-scanner-tools <p-lambda> <fail> <p-cc> <succeds> .. 
				(X XL N M INDENT)
				(c) (d)
				s-false s-true s-mk-seq s-mk-and s-mk-or)

  ;; Sets up a standar parser functionals with INDENT field added
  (setup-parser
   <p-define> <p-lambda> <fail> <p-cc> <succeds> .. xx
   X XL ((N 0) (M 0) (INDENT (list 0)))
   s-false s-true s-mk-seq s-mk-and s-mk-or))