commit ae913586600b344c7e3a0fe32e9e64a934bc677c
parent 3063304c62cabf23655a1d25ff35ccd4956cf365
Author: Andres Navarro <canavarro82@gmail.com>
Date: Fri, 25 Nov 2011 17:24:24 -0300
Refactor: Added new files kchar.[ch] to host the char predicates. Cleaned up kgchars.h
Diffstat:
7 files changed, 47 insertions(+), 76 deletions(-)
diff --git a/TODO b/TODO
@@ -23,7 +23,7 @@
** $unless (r7rs)
** $string-for-each (r7rs)
** $vector-for-each (r7rs)
-** $bytevector-for-each (r7rs)
+** $bytevector-for-each
** $case (r7rs)
** $case-lambda (r7rs)
** $case-vau (r7rs)
diff --git a/src/Makefile b/src/Makefile
@@ -36,7 +36,7 @@ CORE_O= kobject.o ktoken.o kpair.o kstring.o ksymbol.o kread.o \
kcontinuation.o koperative.o kapplicative.o keval.o krepl.o \
kencapsulation.o kpromise.o kport.o kinteger.o krational.o \
kreal.o ktable.o kgc.o imath.o imrat.o kbytevector.o kvector.o \
- kground.o kghelpers.o kgbooleans.o kgeqp.o kgequalp.o \
+ kchar.o kground.o kghelpers.o kgbooleans.o kgeqp.o kgequalp.o \
kgsymbols.o kgcontrol.o kgpairs_lists.o kgpair_mut.o kgenvironments.o \
kgenv_mut.o kgcombiners.o kgcontinuations.o kgencapsulations.o \
kgpromises.o kgkd_vars.o kgks_vars.o kgports.o kgchars.o kgnumbers.o \
@@ -121,6 +121,7 @@ kbytevector.o: kbytevector.c kbytevector.h kobject.h klimits.h klisp.h \
klispconf.h kstate.h ktoken.h kmem.h kgc.h kstring.h
kcontinuation.o: kcontinuation.c kcontinuation.h kobject.h klimits.h \
klisp.h klispconf.h kstate.h ktoken.h kmem.h kgc.h
+kchar.o: kchar.c kchar.h kobject.h klimits.h klisp.h klispconf.h kstate.h
kencapsulation.o: kencapsulation.c kobject.h klimits.h klisp.h \
klispconf.h kmem.h kstate.h ktoken.h kencapsulation.h kpair.h kgc.h
kenvironment.o: kenvironment.c kenvironment.h kobject.h klimits.h klisp.h \
@@ -189,7 +190,8 @@ kghelpers.o: kghelpers.c kghelpers.h kstate.h klimits.h klisp.h kobject.h \
imath.h
kgchars.o: kgchars.c kstate.h klimits.h klisp.h kobject.h klispconf.h \
ktoken.h kmem.h kapplicative.h koperative.h kcontinuation.h kerror.h \
- kpair.h kgc.h kghelpers.h kenvironment.h ksymbol.h kstring.h kgchars.h
+ kpair.h kgc.h kchar.h kghelpers.h kenvironment.h ksymbol.h kstring.h \
+ kgchars.h
kgkd_vars.o: kgkd_vars.c kstate.h klimits.h klisp.h kobject.h klispconf.h \
ktoken.h kmem.h kpair.h kgc.h kcontinuation.h koperative.h \
kapplicative.h kenvironment.h kerror.h kghelpers.h ksymbol.h kstring.h \
@@ -231,7 +233,7 @@ kground.o: kground.c kstate.h klimits.h klisp.h kobject.h klispconf.h \
kgerrors.h kgffi.h ktable.h keval.h krepl.h
kgstrings.o: kgstrings.c kstate.h klimits.h klisp.h kobject.h klispconf.h \
ktoken.h kmem.h kapplicative.h koperative.h kcontinuation.h kerror.h \
- kpair.h kgc.h ksymbol.h kstring.h kghelpers.h kenvironment.h kgchars.h \
+ kpair.h kgc.h ksymbol.h kstring.h kghelpers.h kenvironment.h \
kgstrings.h kgnumbers.h
kgsymbols.o: kgsymbols.c kstate.h klimits.h klisp.h kobject.h klispconf.h \
ktoken.h kmem.h kcontinuation.h kpair.h kgc.h kstring.h ksymbol.h \
diff --git a/src/kchar.c b/src/kchar.c
@@ -0,0 +1,17 @@
+/*
+** kchar.c
+** Kernel Characters
+** See Copyright Notice in klisp.h
+*/
+
+#include <ctype.h>
+#include <stdbool.h>
+
+#include "kobject.h"
+
+bool kcharp(TValue tv) { return ttischar(tv); }
+bool kchar_alphabeticp(TValue ch) { return isalpha(chvalue(ch)) != 0; }
+bool kchar_numericp(TValue ch) { return isdigit(chvalue(ch)) != 0; }
+bool kchar_whitespacep(TValue ch) { return isspace(chvalue(ch)) != 0; }
+bool kchar_upper_casep(TValue ch) { return isupper(chvalue(ch)) != 0; }
+bool kchar_lower_casep(TValue ch) { return islower(chvalue(ch)) != 0; }
diff --git a/src/kchar.h b/src/kchar.h
@@ -0,0 +1,22 @@
+/*
+** kchar.h
+** Kernel Characters
+** See Copyright Notice in klisp.h
+*/
+
+#ifndef kchar_h
+#define kchar_h
+
+#include <stdbool.h>
+
+#include "kobject.h"
+#include "kstate.h"
+
+bool kcharp(TValue tv);
+bool kchar_alphabeticp(TValue ch);
+bool kchar_numericp(TValue ch);
+bool kchar_whitespacep(TValue ch);
+bool kchar_upper_casep(TValue ch);
+bool kchar_lower_casep(TValue ch);
+
+#endif
diff --git a/src/kgchars.c b/src/kgchars.c
@@ -17,6 +17,7 @@
#include "koperative.h"
#include "kcontinuation.h"
#include "kerror.h"
+#include "kchar.h"
#include "kghelpers.h"
#include "kgchars.h"
@@ -30,14 +31,6 @@
/* 14.1.3? char-upper-case?, char-lower-case? */
/* use ftyped_predp */
-/* Helpers for typed predicates */
-bool kcharp(TValue tv) { return ttischar(tv); }
-bool kchar_alphabeticp(TValue ch) { return isalpha(chvalue(ch)) != 0; }
-bool kchar_numericp(TValue ch) { return isdigit(chvalue(ch)) != 0; }
-bool kchar_whitespacep(TValue ch) { return isspace(chvalue(ch)) != 0; }
-bool kchar_upper_casep(TValue ch) { return isupper(chvalue(ch)) != 0; }
-bool kchar_lower_casep(TValue ch) { return islower(chvalue(ch)) != 0; }
-
/* 14.1.4? char->integer, integer->char */
void kchar_to_integer(klisp_State *K)
{
diff --git a/src/kgchars.h b/src/kgchars.h
@@ -7,70 +7,7 @@
#ifndef kgchars_h
#define kgchars_h
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "kobject.h"
-#include "klisp.h"
#include "kstate.h"
-#include "kghelpers.h"
-
-/* 14.1.1? char? */
-/* uses typep */
-
-/* 14.1.2? char-alphabetic?, char-numeric?, char-whitespace? */
-/* use ftyped_predp */
-
-/* 14.1.3? char-upper-case?, char-lower-case? */
-/* use ftyped_predp */
-
-/* Helpers for typed predicates */
-/* XXX: this should probably be in a file kchar.h but there is no real need for
- that file yet */
-bool kcharp(TValue tv);
-bool kchar_alphabeticp(TValue ch);
-bool kchar_numericp(TValue ch);
-bool kchar_whitespacep(TValue ch);
-bool kchar_upper_casep(TValue ch);
-bool kchar_lower_casep(TValue ch);
-
-/* 14.1.4? char->integer, integer->char */
-void kchar_to_integer(klisp_State *K);
-void kinteger_to_char(klisp_State *K);
-
-/* 14.1.4? char-upcase, char-downcase */
-void kchar_upcase(klisp_State *K);
-void kchar_downcase(klisp_State *K);
-
-/* 14.2.1? char=? */
-/* uses ftyped_bpredp */
-
-/* 14.2.2? char<?, char<=?, char>?, char>=? */
-/* use ftyped_bpredp */
-
-/* 14.2.3? char-ci=? */
-/* uses ftyped_bpredp */
-
-/* 14.2.4? char-ci<?, char-ci<=?, char-ci>?, char-ci>=? */
-/* use ftyped_bpredp */
-
-/* Helpers for typed binary predicates */
-/* XXX: this should probably be in a file kchar.h but there is no real need for
- that file yet */
-bool kchar_eqp(TValue ch1, TValue ch2);
-bool kchar_ltp(TValue ch1, TValue ch2);
-bool kchar_lep(TValue ch1, TValue ch2);
-bool kchar_gtp(TValue ch1, TValue ch2);
-bool kchar_gep(TValue ch1, TValue ch2);
-
-bool kchar_ci_eqp(TValue ch1, TValue ch2);
-bool kchar_ci_ltp(TValue ch1, TValue ch2);
-bool kchar_ci_lep(TValue ch1, TValue ch2);
-bool kchar_ci_gtp(TValue ch1, TValue ch2);
-bool kchar_ci_gep(TValue ch1, TValue ch2);
/* init ground */
void kinit_chars_ground_env(klisp_State *K);
diff --git a/src/kgstrings.c b/src/kgstrings.c
@@ -19,10 +19,10 @@
#include "kcontinuation.h"
#include "kerror.h"
#include "ksymbol.h"
+#include "kchar.h"
#include "kstring.h"
#include "kghelpers.h"
-#include "kgchars.h" /* for kcharp */
#include "kgstrings.h"
#include "kgnumbers.h" /* for keintegerp & knegativep */