aboutsummaryrefslogtreecommitdiff
path: root/src/cljcc/util.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/cljcc/util.clj')
-rw-r--r--src/cljcc/util.clj23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cljcc/util.clj b/src/cljcc/util.clj
index 6c6c88e..d3b2ea4 100644
--- a/src/cljcc/util.clj
+++ b/src/cljcc/util.clj
@@ -30,3 +30,26 @@
(log/info msg)
(log/error msg))
(System/exit status))
+
+(defn letter? [^Character ch]
+ (or (= \_ ch)
+ (Character/isLetter ch)))
+
+(defn letter-digit? [^Character ch]
+ (or (= \_ ch)
+ (Character/isLetterOrDigit ch)))
+
+(defn digit? [^Character ch]
+ (Character/isDigit ch))
+
+(defn newline? [ch]
+ (= \newline ch))
+
+(defn whitespace? [^Character ch]
+ (Character/isWhitespace ch))
+
+(defn read-number [str]
+ (try
+ (Double/parseDouble str)
+ (catch Exception e
+ (throw (ex-info "Lexer error. Malformed number." {:message (.getMessage e)})))))