Browse files

!parse-bool

  • Loading branch information...
1 parent 7519da0 commit a9e51d7f070c2f58d8ff7ef6ad10600e627e6411 @sile committed May 6, 2012
Showing with 15 additions and 2 deletions.
  1. BIN plc/stdlib/parser.bc
  2. +10 −2 plc/stdlib/parser.lisp
  3. +5 −0 plvm/include/psil/vm/Native.hh
View
BIN plc/stdlib/parser.bc
Binary file not shown.
View
12 plc/stdlib/parser.lisp
@@ -74,17 +74,25 @@
(read-char in) ; eat #\)
(!parse-list-impl in)))
+ (define !parse-boolean-or-char (lambda (in)
+ (read-char in) ; eat #\#
+ (case (read-char in)
+ ((#\\) (!parse-char in))
+ ((#\t) #t)
+ ((#\f) #f)
+ (else (undef)))))
+
(define !parse-port (lambda (in)
(!skip-whitespace in)
(let ((ch (peek-char in)))
(case (!char-type ch)
- ((@eof) 1)
+ ((@eof) (undef))
((@comment) (!skip-comment-line in) (!parse-port in))
((@string) (!parse-string in))
((@list) (!parse-list in))
((@quote) (!parse-quote in))
((@symbol) (!parse-symbol in))
- ((@boolean-or-char) 8)
+ ((@boolean-or-char) (!parse-boolean-or-char in))
((@maybe-number) 9)))))
(define !parse-file (lambda (filepath)
View
5 plvm/include/psil/vm/Native.hh
@@ -240,6 +240,10 @@ namespace psil {
push(env, head);
}
+ static void _undef(Environment& env, uint1 arity) {
+ push(env, Undef::make());
+ }
+
static void _is_eqv(Environment& env, uint1 arity) {
Object* x = pop(env);
Object* y = pop(env);
@@ -335,6 +339,7 @@ namespace psil {
reg("STRING-REF", _string_ref);
reg("STRING-SET!", _string_set);
reg("STRING->SYMBOL", _string_to_symbol);
+ reg("UNDEF", _undef);
regval("STDIN", &Port::STDIN);
regval("STDOUT", &Port::STDOUT);

0 comments on commit a9e51d7

Please sign in to comment.