3 ;;; Parser contexts for scanners
5 ;;; (c) 2009 Straylight/Edgeware
8 ;;;----- Licensing notice ---------------------------------------------------
10 ;;; This file is part of the Sensble Object Design, an object system for C.
12 ;;; SOD is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
17 ;;; SOD is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with SOD; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 (cl:in-package #:sod-parser)
28 ;;;--------------------------------------------------------------------------
29 ;;; Basic scanner behaviour.
33 (defmethod parser-step ((context scanner-context))
34 `(scanner-step ,(parser-scanner context)))
36 (defmethod parser-at-eof-p ((context scanner-context))
37 `(scanner-at-eof-p ,(parser-scanner context)))
39 (defmethod parser-capture-place ((context scanner-context))
40 `(scanner-capture-place ,(parser-scanner context)))
42 (defmethod parser-restore-place ((context scanner-context) place)
43 `(scanner-restore-place ,(parser-scanner context) ,place))
45 (defmethod parser-release-place ((context scanner-context) place)
46 `(scanner-release-place ,(parser-scanner context) ,place))
48 ;; Character scanners.
50 (defmethod parser-current-char ((context character-scanner-context))
51 `(scanner-current-char ,(parser-scanner context)))
55 (defmethod parser-token-type ((context token-scanner-context))
56 `(token-type ,(parser-scanner context)))
58 (defmethod parser-token-value ((context token-scanner-context))
59 `(token-value ,(parser-scanner context)))
61 ;;;--------------------------------------------------------------------------
62 ;;; Contexts for specific scanner classes.
66 (defclass string-scanner-context (character-scanner-context)
69 "Specialized parser context for scanning strings.
71 Most notably, string positions don't need to be released, which means that
72 the expanded code doesn't need to do install `unwind-protect' handlers."))
74 (defmethod parser-places-must-be-released-p
75 ((context string-scanner-context))
80 (defclass list-scanner-context (token-scanner-context)
83 "Specialized scanner contexts for the list scanner."))
85 (defmethod parser-places-must-be-released-p ((context list-scanner-context))
88 ;;;----- That's all, folks --------------------------------------------------