Read one object from an open
Signature: (read-object channel state-state) returns
This is a logic-mode function, but its logical definition is tricky; see logical-story-of-io. The main logical consequence is the updating of state.
Under the hood, we use the Lisp reader to try to read an object from the
Lisp input stream that is associated with
Ideally, the input stream contains well-formed S-expressions that are free
of "bad" objects like
But the input stream can also be malformed. For instance, we might
encounter malformed S-expressions without enough closing parens, or bad objects
like
Note that if the input contains plain symbols without explicit package name
prefixes, e.g.,
foo
Then the following book:
(in-package "ACL2") (include-book "std/util/bstar" :dir :system) (include-book "centaur/vl/portcullis" :dir :system) (make-event (b* (((mv ?err ?val state) (in-package "VL")) ((mv channel state) (open-input-channel "temp" :object state)) ((mv ?eofp obj state) (read-object channel state)) (state (close-input-channel channel state))) (value `(defconst *foo* ',obj))))
Defines
Theorem:
(defthm state-p1-of-read-object (implies (state-p1 state) (state-p1 (mv-nth 2 (read-object channel state)))))
Theorem:
(defthm open-input-channel-p1-of-read-object (implies (and (state-p1 state) (open-input-channel-p1 channel :object state)) (open-input-channel-p1 channel :object (mv-nth 2 (read-object channel state)))))