Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Close #3. Change word? and word* to accept alphanumeric characters. C…

…hange tests to match.
  • Loading branch information...
commit eaafdd4e0d9b236a8513daba9ec19e5751431223 1 parent 486d503
@Ramarren authored
Showing with 9 additions and 5 deletions.
  1. +2 −2 greedy.lisp
  2. +6 −2 test-parsers.lisp
  3. +1 −1  token-parsers.lisp
View
4 greedy.lisp
@@ -119,8 +119,8 @@ non-recursively and has better memory performance."
:accept-empty accept-empty))
(def-cached-parser word*
- "Parser: accept a string of alphabetic characters"
- (gather-if* #'alpha-char-p :result-type 'string))
+ "Parser: accept a string of alphanumeric characters"
+ (gather-if* #'alphanumericp :result-type 'string))
(defun nat* (&optional (radix 10))
"Non-backtracking parser: accept natural number, consuming as many digits as possible"
View
8 test-parsers.lisp
@@ -37,8 +37,12 @@
(" " ","))
(defparsertest test-word? (word?)
- ("abc" "abc" )
- (" " "123"))
+ ("abc" "abc" "123" "123" "abc!def" "abc")
+ (" " ";,!"))
+
+(defparsertest test-word* (word*)
+ ("abc" "abc" "123" "123" "abc!def" "abc")
+ (" " ";,!"))
(defparsertest test-string? (string? (list #\a #\b #\c) :result-type 'list)
("abc" (list #\a #\b #\c) "abcd" (list #\a #\b #\c))
View
2  token-parsers.lisp
@@ -33,7 +33,7 @@
(def-cached-parser word?
"Parser: accept a string of alphabetic characters"
- (between? (letter?) 1 nil 'string))
+ (between? (alphanum?) 1 nil 'string))
;; naive implementation using monadic combinators, unfortunately rather slow
;; (defun int? ()
Please sign in to comment.
Something went wrong with that request. Please try again.