;;; -*-lisp-*- ;;; ;;; Parser contexts for scanners ;;; ;;; (c) 2009 Straylight/Edgeware ;;; ;;;----- Licensing notice --------------------------------------------------- ;;; ;;; 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 ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; SOD is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with SOD; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. (cl:in-package #:sod-parser) ;;;-------------------------------------------------------------------------- ;;; Basic scanner behaviour. ;; Basic scanners. (defmethod parser-step ((context scanner-context)) `(scanner-step ,(parser-scanner context))) (defmethod parser-at-eof-p ((context scanner-context)) `(scanner-at-eof-p ,(parser-scanner context))) (defmethod parser-capture-place ((context scanner-context)) `(scanner-capture-place ,(parser-scanner context))) (defmethod parser-restore-place ((context scanner-context) place) `(scanner-restore-place ,(parser-scanner context) ,place)) (defmethod parser-release-place ((context scanner-context) place) `(scanner-release-place ,(parser-scanner context) ,place)) ;; Character scanners. (defmethod parser-current-char ((context character-scanner-context)) `(scanner-current-char ,(parser-scanner context))) ;; Token scanners. (defmethod parser-token-type ((context token-scanner-context)) `(token-type ,(parser-scanner context))) (defmethod parser-token-value ((context token-scanner-context)) `(token-value ,(parser-scanner context))) ;;;-------------------------------------------------------------------------- ;;; Contexts for specific scanner classes. ;; String scanner. (defclass string-scanner-context (character-scanner-context) () (:documentation "Specialized parser context for scanning strings. Most notably, string positions don't need to be released, which means that the expanded code doesn't need to do install `unwind-protect' handlers.")) (defmethod parser-places-must-be-released-p ((context string-scanner-context)) nil) ;; List scanner. (defclass list-scanner-context (token-scanner-context) () (:documentation "Specialized scanner contexts for the list scanner.")) (defmethod parser-places-must-be-released-p ((context list-scanner-context)) nil) ;;;----- That's all, folks --------------------------------------------------