1 | ;;;; slib-prec.scm -*-scheme-*- |
---|
2 | ;;;; Kon Lovett, Apr '20 |
---|
3 | ;;;; Kon Lovett, Apr '18 |
---|
4 | |
---|
5 | ;; Issues |
---|
6 | ;; |
---|
7 | ;; - needs a "surface notation" |
---|
8 | |
---|
9 | (module slib-prec |
---|
10 | |
---|
11 | (;export |
---|
12 | read-sexp-from-string) |
---|
13 | |
---|
14 | (import scheme) |
---|
15 | (import (chicken module)) |
---|
16 | (import (chicken base)) |
---|
17 | |
---|
18 | (import slib-prec-parse) |
---|
19 | (reexport slib-prec-parse) |
---|
20 | |
---|
21 | (import slib-prec-grammar) |
---|
22 | (reexport slib-prec-grammar) |
---|
23 | |
---|
24 | ;defgrammar doesn't define |
---|
25 | (import slib-basic-grammars) |
---|
26 | (import slib-standard-grammar) |
---|
27 | (import slib-tex-grammar) |
---|
28 | |
---|
29 | ;; |
---|
30 | |
---|
31 | (define (read-sexp-from-string str #!optional (grm (active-input-grammar)) (column 0)) |
---|
32 | (import (only (chicken port) with-input-from-string)) |
---|
33 | (with-input-from-string str (cut read-sexp grm column)) ) |
---|
34 | |
---|
35 | ;;; |
---|
36 | |
---|
37 | #| |
---|
38 | ;; |
---|
39 | |
---|
40 | (define (make-grammar src #!optional (base '())) |
---|
41 | (let* ( |
---|
42 | (imd (*parse-grammer-source 'make-grammar src base)) |
---|
43 | (grm (*eval-grammer-form 'make-grammar imd base)) ) |
---|
44 | (syntax-begin! base) |
---|
45 | (apply prec:define-grammar grm) |
---|
46 | (syntax-current) ) ) |
---|
47 | |
---|
48 | ; tok <kind> <args>... |
---|
49 | ; |
---|
50 | ; <kind> |
---|
51 | ; |
---|
52 | ; _f delim |
---|
53 | ; |
---|
54 | ; f nofix : sop |
---|
55 | ; |
---|
56 | ; f_f commentfix : stp match rule1 ... |
---|
57 | ; |
---|
58 | ; fx fy prefix : sop bp rule1 ... |
---|
59 | ; xf yf postfix : sop bp |
---|
60 | ; xfx xfy yfx yfy infix : sop lbp bp rule1 ... |
---|
61 | ; xfx xfy yfx yfy infix : sop lbp bp rule1 ... |
---|
62 | ; |
---|
63 | ; xfs nary : sop bp |
---|
64 | ; fs prestfix : sop bp rule1 ... |
---|
65 | ; |
---|
66 | ; fxf matchfix : sop sep match rule1 ... |
---|
67 | ; fyf inmatchfix : sop sep match lbp rule1 ... |
---|
68 | |
---|
69 | (define (*parse-grammer-source loc src base) |
---|
70 | (begin) ) |
---|
71 | |
---|
72 | (define (*eval-grammer-form loc imd base) |
---|
73 | (begin) ) |
---|
74 | |# |
---|
75 | |
---|
76 | ) ;slib-prec |
---|