Commits

Anonymous committed ad529e5

New condition type LR-PARSE-ERROR-CONDITION
Keywords: package, condition, lr, error

* parser/fucc-decl.lisp (parse-error-condition, lr-parse-error-condition):
The LR-PARSE-ERROR-CONDITION with slot CONFIG is separated from
PARSE-ERROR-CONDITION.

* fucc-parser.lisp (parser-lr):
New class is used. Omitted previously initargs :TOKEN-ID and :DATA are
added.

* ERROR-RECOVERY:
Changes are documented.

* fucc-package.lisp (#:fucc):
Condition names are exported.

  • Participants
  • Parent commits 1bb0369

Comments (0)

Files changed (4)

doc/ERROR-RECOVERY

 reduce/reduce conflicts).  You can continue parsing with different
 restarts.  See Common Lisp HyperSpec, 9.1 Conditions.
 
-** Condition
+** Conditions
 
 *** FUCC:PARSE-ERROR-CONDITION
 Parsing error.
 **** Readers
 FUCC:ERROR-TOKEN-ID
 FUCC:ERROR-DATA
-FUCC:ERROR-CONFIG
 
-Token ID and data received from lexer, and parser configuration.
+Token ID and data received from lexer.
 
 **** Restarts
 FUCC:SKIP-TOKEN
   List consists of cons pairs (TOKEN . DATA).
 
 
+*** FUCC:LR-PARSE-ERROR-CONDITION
+Subclass of FUCC:PARSE-ERROR-CONDITION.
+
+**** Readers
+FUCC:ERROR-CONFIG
+  Configuration of LR-parser.
+
 *** FUCC:PARSE-CONFLICT-CONDITION
 Shift/reduce or reduce/reduce conflict.  Reader FUCC:POSSIBLE-ACTIONS
 returns list of conflicting actions.

parser/fucc-decl.lisp

 ;;;
 
 (define-condition parse-error-condition ()
-  ((config :initarg :config ;; Config is for LR only?
-           :reader error-config
-           :documentation "Runtime configuration of parser")
-   (token-id :initarg :token-id
+  ((token-id :initarg :token-id
              :reader error-token-id
              :documentation "ID of token that caused the error")
    (data :initarg :data
          :documentation "Semantic data associated with token"))
   (:documentation "General parsing error"))
 
+(define-condition lr-parse-error-condition
+    (parse-error-condition)
+  ((config :initarg :config
+           :reader error-config
+           :documentation "Runtime configuration of parser"))
+  (:documentation "LR-specific parser error"))
+
 (define-condition parse-conflict-condition (parse-error-condition)
   ((possible-actions :initform nil
                      :initarg :actions

parser/fucc-package.lisp

    #:use-token
    #:insert-token
    #:insert-token-list
+   #:parse-error-condition
+   #:lr-parse-error-condition
    #:*next-token*
    #:*next-data*))

parser/fucc-parser.lisp

                    (if (eq action-type 'reduce-action)
                        (parser-lr--reduce! config action parser atom-id data) ; Reduction
                        ;;  Or error handling
-                       (error 'parse-error-condition
+                       (error 'lr-parse-error-condition
+                              :token-id atom-id
+                              :data data
                               :config config))
                  ;; Restarts
                  (skip-token ()