-
Notifications
You must be signed in to change notification settings - Fork 123
/
bbp-lang.rkt
81 lines (76 loc) · 1.83 KB
/
bbp-lang.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#lang racket/base
(require "bbp-parser.rkt")
(require brag/support)
(require (for-syntax racket/base syntax/parse))
(define (read-syntax path port)
(define parse-tree (parse path (make-tokenizer port)))
(define module-datum `(module bbp-mod "bbp-expander.rkt"
,parse-tree))
(datum->syntax #f module-datum))
(provide read-syntax)
(define-lex-abbrev
mtypes
(:or
"PC"
"BPC"
"IPC"
"NPC"
"SPC"
"NTPC"
"STPC"
"TTPC"
"TTPCLB"
"TTPCEB"
"TPCLB"
"TPCEB"
"UPC"
"BTC"
"BPC"
"ChC"
"DBC"
"DAC"
"HAC"
"LAC"
"SAC"
"MC"
"NGC"
"NGCDA"
"NGCSA"
"BC"
"SBC"
"LBC"
"NBC"
"SS"
"BC"
"BP"
"LBC"
"NBC"
"SBC"
)) ; this is infuriating check a macro
(define-lex-abbrev layer (:or "L1" "L2" "L23" "L3" "L4" "L5" "L6"))
(define-lex-abbrev init (:or "b" "c" "d"))
(define-lex-abbrev sust (:or "NAC" "AC" "STUT" "IR"))
(define-lex-abbrev species (:or "Rat" "Mouse"))
(define-lex-abbrev region (:or "S1"))
(define-lex-abbrev projection (:or "L1P" "L3P" "L4P")) ; not wokring :/
(define (make-tokenizer port)
(define (next-token)
(define bbp-lexer
(lexer
[(eof) eof]
[layer (token 'LAYER lexeme)]
[mtypes (token 'M-TYPE lexeme)]
[init (token 'INIT lexeme)]
[sust (token 'SUST lexeme)]
[species (token 'SPECIES lexeme)]
[region (token 'REGION lexeme)]
[projection (token 'PROJECTION lexeme)] ; a problem
["_" (token 'UNDERSCORE)]
))
(bbp-lexer port))
next-token)
(apply-tokenizer-maker make-tokenizer "L1_PC")
(parse-to-datum (apply-tokenizer-maker make-tokenizer "L1_PC"))
(parse-to-datum (apply-tokenizer-maker make-tokenizer "L23_PC"))
(parse-to-datum (apply-tokenizer-maker make-tokenizer "PC"))
(parse-to-datum (apply-tokenizer-maker make-tokenizer "Rat_S1_L4_PC_cAC_L3P"))