Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

!parse-bool

  • Loading branch information...
commit a9e51d7f070c2f58d8ff7ef6ad10600e627e6411 1 parent 7519da0
Takeru Ohta authored
BIN  plc/stdlib/parser.bc
View
Binary file not shown
12 plc/stdlib/parser.lisp
View
@@ -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)
5 plvm/include/psil/vm/Native.hh
View
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.