Fix spelling of `Sensible' in all of the header comments.
[sod] / src / parser / scanner-context-impl.lisp
CommitLineData
dea4d055
MW
1;;; -*-lisp-*-
2;;;
3;;; Parser contexts for scanners
4;;;
5;;; (c) 2009 Straylight/Edgeware
6;;;
7
8;;;----- Licensing notice ---------------------------------------------------
9;;;
e0808c47 10;;; This file is part of the Sensible Object Design, an object system for C.
dea4d055
MW
11;;;
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.
16;;;
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.
21;;;
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.
25
26(cl:in-package #:sod-parser)
27
28;;;--------------------------------------------------------------------------
29;;; Basic scanner behaviour.
30
31;; Basic scanners.
32
33(defmethod parser-step ((context scanner-context))
34 `(scanner-step ,(parser-scanner context)))
35
36(defmethod parser-at-eof-p ((context scanner-context))
37 `(scanner-at-eof-p ,(parser-scanner context)))
38
39(defmethod parser-capture-place ((context scanner-context))
40 `(scanner-capture-place ,(parser-scanner context)))
41
42(defmethod parser-restore-place ((context scanner-context) place)
43 `(scanner-restore-place ,(parser-scanner context) ,place))
44
45(defmethod parser-release-place ((context scanner-context) place)
46 `(scanner-release-place ,(parser-scanner context) ,place))
47
48;; Character scanners.
49
50(defmethod parser-current-char ((context character-scanner-context))
51 `(scanner-current-char ,(parser-scanner context)))
52
53;; Token scanners.
54
55(defmethod parser-token-type ((context token-scanner-context))
56 `(token-type ,(parser-scanner context)))
57
58(defmethod parser-token-value ((context token-scanner-context))
59 `(token-value ,(parser-scanner context)))
60
61;;;--------------------------------------------------------------------------
62;;; Contexts for specific scanner classes.
63
64;; String scanner.
65
66(defclass string-scanner-context (character-scanner-context)
67 ()
68 (:documentation
69 "Specialized parser context for scanning strings.
70
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."))
73
74(defmethod parser-places-must-be-released-p
75 ((context string-scanner-context))
76 nil)
77
78;; List scanner.
79
80(defclass list-scanner-context (token-scanner-context)
81 ()
82 (:documentation
83 "Specialized scanner contexts for the list scanner."))
84
85(defmethod parser-places-must-be-released-p ((context list-scanner-context))
86 nil)
87
88;;;----- That's all, folks --------------------------------------------------