+"------------------------------------------------------------------------------
+" Global Config Variables
+"------------------------------------------------------------------------------
+let g:ProjectPath = getcwd()
+let g:TestSrcPath = g:ProjectPath . "/tests"
+let g:CTagsFile = g:ProjectPath . "/tags"
+
+"------------------------------------------------------------------------------
+" Global Function Definitions
+"------------------------------------------------------------------------------
+" Connect to the Correct CTags File
+function! ConnectCTags()
+ execute("set tags=" . g:CTagsFile)
+endfunction
+
+" Update the CTags File
+function! RefreshCTags()
+ if strlen(g:CTagsFile)
+ execute('silent ! ctags -R *')
+ endif
+endfunction
+
+"------------------------------------------------------------------------------
+" Project Specific Key Mappings
+"------------------------------------------------------------------------------
+map <silent> <F2> <F3>
+map <silent> <F3> <ESC>:call RefreshCTags()<CR>
+map <silent> <F6> <ESC>:execute("find " . g:TestSrcPath . "/**/test_" . expand("%:t:r") . ".scm")<CR>
+map <silent> <F10> <ESC>:make<CR>
+
+"------------------------------------------------------------------------------
+" Connect To CTags
+"------------------------------------------------------------------------------
+call ConnectCTags()
+
(define (dlang/tokenize in)
(let ((ch (buf-lookahead! in 1)))
- (cond
- ; End of Input reached
- ((eof-object? ch) ch)
-
- ; Whitespace
- ((char-whitespace? ch)
- (dlang/whitespace in))
-
- ; Comment
- ((char=? ch #\#)
- (dlang/comment in))
-
- ; Number
- ((or
- (and (char=? ch #\-) (char-numeric? (buf-lookahead! in 2)))
- (char-numeric? ch))
- (dlang/number in))
-
- ; Character
- ((char=? ch #\') (dlang/character in))
-
- ; String
- ((char=? ch #\") (dlang/string in))
-
- ; Symbol
- ((char=? ch #\$) (dlang/symbol in))
-
- ; Parentheses
- ((char=? ch #\()
- (token 'lpar (string (buf-consume! in))))
- ((char=? ch #\))
- (token 'rpar (string (buf-consume! in))))
-
- ; Id
- (else
- (dlang/id in)))))
+ (define tok
+ (cond
+ ; End of Input reached
+ ((eof-object? ch) ch)
+
+ ; Whitespace
+ ((char-whitespace? ch)
+ (dlang/whitespace in))
+
+ ; Comment
+ ((char=? ch #\#)
+ (dlang/comment in))
+
+ ; Number
+ ((or
+ (and (char=? ch #\-) (char-numeric? (buf-lookahead! in 2)))
+ (char-numeric? ch))
+ (dlang/number in))
+
+ ; Character
+ ((char=? ch #\') (dlang/character in))
+
+ ; String
+ ((char=? ch #\") (dlang/string in))
+
+ ; Symbol
+ ((char=? ch #\$) (dlang/symbol in))
+
+ ; Punctuation and Parens
+ ((char=? ch #\()
+ (token 'lpar (string (buf-consume! in))))
+ ((char=? ch #\))
+ (token 'rpar (string (buf-consume! in))))
+ ((char=? ch #\,)
+ (token 'comma (string (buf-consume! in))))
+ ((char=? ch #\;)
+ (token 'term (string (buf-consume! in))))
+
+ ; Id
+ (else
+ (dlang/id in))))
+ (if (and (not (eof-object? tok))
+ (equal? "end" (token-text tok)))
+ (token-type-set! tok 'term))
+ tok))
(define (dlang/whitespace in)
(while (char-whitespace? (buf-lookahead! in 1))
(equal? 'rpar (token-type result))
(equal? ")" (token-text result))))))
+(def-test "dlang/tokenize should recognize a comma"
+ (call-with-input-string ","
+ (lambda (input)
+ (define buffer (buf input read-char))
+ (define result (dlang/tokenize buffer))
+ (and (token? result)
+ (equal? 'comma (token-type result))
+ (equal? "," (token-text result))))))
+
+(def-test "dlang/tokenize should recognize a semicolon"
+ (call-with-input-string ";"
+ (lambda (input)
+ (define buffer (buf input read-char))
+ (define result (dlang/tokenize buffer))
+ (and (token? result)
+ (equal? 'term (token-type result))
+ (equal? ";" (token-text result))))))
+
+(def-test "dlang/tokenize should recognize the end keyword"
+ (call-with-input-string "end"
+ (lambda (input)
+ (define buffer (buf input read-char))
+ (define result (dlang/tokenize buffer))
+ (and (token? result)
+ (equal? 'term (token-type result))
+ (equal? "end" (token-text result))))))
+
; dlang/whitespace
;------------------------------------------------------------------------------
(def-test "dlang/whitespace should recognize and consume whitespace"