Initialize the parser state.
(init-parstate data version parstate) → parstate
This is the state when we start parsing a file. Given (the data of) a file to parse, and a C version, the initial parsing state consists of the data to parse, no read characters or tokens, no unread characters or tokens, and the initial file position. We also resize the arrays of characters and tokens to the number of data bytes, which is overkill but certainly sufficient (because we will never lex more characters or tokens than bytes); if this turns out to be too large, we will pick a different size, but then we may need to resize the array as needed while lexing and parsing.
Function:
(defun init-parstate (data version parstate) (declare (xargs :stobjs (parstate))) (declare (xargs :guard (and (byte-listp data) (c::versionp version)))) (b* ((parstate (update-parstate->bytes data parstate)) (parstate (update-parstate->position (position-init) parstate)) (parstate (update-parstate->chars-length (len data) parstate)) (parstate (update-parstate->chars-read 0 parstate)) (parstate (update-parstate->chars-unread 0 parstate)) (parstate (update-parstate->tokens-length (len data) parstate)) (parstate (update-parstate->tokens-read 0 parstate)) (parstate (update-parstate->tokens-unread 0 parstate)) (parstate (update-parstate->version version parstate)) (parstate (update-parstate->size (len data) parstate))) parstate))
Theorem:
(defthm parstatep-of-init-parstate (b* ((parstate (init-parstate data version parstate))) (parstatep parstate)) :rule-classes :rewrite)