klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

kchar.c (1567B)


      1 /*
      2 ** kchar.c
      3 ** Kernel Characters
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 #include <ctype.h>
      8 #include <stdbool.h>
      9 
     10 #include "kobject.h"
     11 
     12 bool kcharp(TValue tv) { return ttischar(tv); }
     13 bool kchar_alphabeticp(TValue ch) { return isalpha(chvalue(ch)) != 0; }
     14 bool kchar_numericp(TValue ch)    { return isdigit(chvalue(ch)) != 0; }
     15 bool kchar_whitespacep(TValue ch) { return isspace(chvalue(ch)) != 0; }
     16 bool kchar_upper_casep(TValue ch) { return isupper(chvalue(ch)) != 0; }
     17 bool kchar_lower_casep(TValue ch) { return islower(chvalue(ch)) != 0; }
     18 bool kchar_title_casep(TValue ch) { return false; } /* only ASCII */
     19 
     20 /* Helpers for binary typed predicates */
     21 bool kchar_eqp(TValue ch1, TValue ch2) { return chvalue(ch1) == chvalue(ch2); }
     22 bool kchar_ltp(TValue ch1, TValue ch2) { return chvalue(ch1) <  chvalue(ch2); }
     23 bool kchar_lep(TValue ch1, TValue ch2) { return chvalue(ch1) <= chvalue(ch2); }
     24 bool kchar_gtp(TValue ch1, TValue ch2) { return chvalue(ch1) >  chvalue(ch2); }
     25 bool kchar_gep(TValue ch1, TValue ch2) { return chvalue(ch1) >= chvalue(ch2); }
     26 
     27 bool kchar_ci_eqp(TValue ch1, TValue ch2)
     28 { return tolower(chvalue(ch1)) == tolower(chvalue(ch2)); }
     29 
     30 bool kchar_ci_ltp(TValue ch1, TValue ch2)
     31 { return tolower(chvalue(ch1)) <  tolower(chvalue(ch2)); }
     32 
     33 bool kchar_ci_lep(TValue ch1, TValue ch2)
     34 { return tolower(chvalue(ch1)) <= tolower(chvalue(ch2)); }
     35 
     36 bool kchar_ci_gtp(TValue ch1, TValue ch2)
     37 { return tolower(chvalue(ch1)) > tolower(chvalue(ch2)); }
     38 
     39 bool kchar_ci_gep(TValue ch1, TValue ch2)
     40 { return tolower(chvalue(ch1)) >= tolower(chvalue(ch2)); }
     41