;;;----- Licensing notice ---------------------------------------------------
;;;
-;;; This file is part of the Sensble Object Design, an object system for C.
+;;; This file is part of the Sensible Object Design, an object system for C.
;;;
;;; SOD is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
(once-only (string value winp consumedp)
(with-gensyms (my-value my-winp my-consumedp label what)
`(let ((,scanner (make-string-scanner ,string)))
+ (declare (ignorable ,scanner))
(multiple-value-bind (,my-value ,my-winp ,my-consumedp)
(with-parser-context
(character-scanner-context :scanner ,scanner)
;;;--------------------------------------------------------------------------
;;; Test expression parser.
-(defparse token (:context (context character-parser-context) parser)
- (with-gensyms (value)
- (expand-parser-spec context
- `(seq ((,value ,parser) :whitespace) ,value))))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defparse token (:context (context character-parser-context) parser)
+ (with-gensyms (value)
+ (expand-parser-spec context
+ `(seq ((,value ,parser) :whitespace) ,value)))))
(let ((add (binop "+" (x y 5) `(+ ,x ,y)))
(sub (binop "-" (x y 5) `(- ,x ,y)))
(seq (#\&) and)
(seq (#\|) or)))
(token (or (seq (#\() lp)
+ (seq (#\[) lb)
(seq (#\-) neg)
(seq (#\!) not)))
(token (or (seq (#\!) fact)
- (when nestedp (seq (#\)) rp))))))
+ (when nestedp
+ (or (seq (#\)) rp)
+ (seq (#\]) rb)))))))
(next (or :any (t :eof))))
(cons value next))))))
(assert-expr-parse "1 ** 2 ** 3" '((** 1 (** 2 3)) . :eof) t t)
(assert-expr-parse "1 + 2) * 3" '((+ 1 2) . #\)) t t)
(assert-expr-parse "1 + 2 * 3" '((+ 1 (* 2 3)) . :eof) t t)
-
(assert-expr-parse "! 1 + 2 = 3 | 6 - 3 /= 12/6"
'((or (not (= (+ 1 2) 3))
(/= (- 6 3) (/ 12 6)))