-
Notifications
You must be signed in to change notification settings - Fork 1
/
peg-gen-syntax-factory.rkt
49 lines (43 loc) · 1.35 KB
/
peg-gen-syntax-factory.rkt
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
47
48
49
#lang racket
(require racket/contract)
(provide (struct-out PEGFSyn)
defaultFactory)
(struct PEGFSyn
( mkEps
mkLit
mkVar
mkNot
mkKle
mkSeq
mkAlt
addRule
mkEmptyGrm
mkPEG
)
#:guard (struct-guard/c
(-> any/c)
(-> any/c any/c)
(-> any/c any/c)
(-> any/c any/c)
(-> any/c any/c)
(-> any/c any/c any/c)
(-> any/c any/c any/c)
(-> any/c any/c any/c any/c)
(-> any/c)
(-> any/c any/c (listof (cons/c any/c any/c)) any/c)
)
#:transparent)
(define defaultFactory
(PEGFSyn
(lambda () 'ϵ) ;mkEps
(lambda (x) x) ;mkLit
(lambda (x) x) ;mkVar
(lambda (e) (list '! e )) ;mkNot
(lambda (e) (list '* e )) ;mkKle
(lambda (x y) (list '• x y) ) ;mkSeq
(lambda (x y) (list '/ x y) ) ;mkAlt
(lambda (g nt e) (list nt e g) ) ;addRule
(lambda () '∅ ) ;mkEmptyGrm
(lambda (g start gamma) (list g start gamma) ) ;mkPEG
)
)