Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (provide add-active-token def-active-token process-string)
- (struct activeToken(tokenString function))
- (define activeTokenList '())
- (define (string-after-newline str)
- (println "STRING AFTER NEWLINE")
- (match (regexp-match-positions "\n" str)
- ((list (cons start end)) (substring str end))
- (else "")))
- (define (add-active-token token func)
- (let* ([a (activeToken token func)])
- (set! activeTokenList (cons a activeTokenList)))
- )
- (add-active-token ";;" string-after-newline)
- (add-active-token "//" string-after-newline)
- (define-syntax-rule (def-active-token string (args) body)
- (println "bb"))
- (def-active-token ";;" (str)
- (or (for/or ((c (in-string str))
- (i (in-naturals)))
- (and (char=? c #\newline)
- (substring str (+ i 1))))
- ""))
- (define (process-string string)
- ;(println "PROCESS")
- ;(println string)
- (for ([token activeTokenList])
- (match (regexp-match-positions (activeToken-tokenString token) string)
- ((list (cons start end))
- ; (set! string (string-append (substring string 0 start) ((activeToken-function token) (substring string end)))))
- (set! string (string-append (substring string 0 start) ((activeToken-function token) (substring string end))))
- (process-string string))
- ;(println ((activeToken-function token) string)))
- (else ""))
- )
- (string-append "" string)
- )
- (process-string "jal\n//l\n//kk")
- (for ([i activeTokenList]) (print i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement