Parse UTF-8 ACL2 string into a PFCS
(parse-from-string-to-cst pfcs-string) → tree
Lexes, tokenizes, and parses a PFCS system expressed
as a string of acl2 characters whose char-codes are UTF-8 bytes.
Returns a PFCS
If any step fails, returns a reserr. The parse consumes the entire string or a reserr is returned.
Since ACL2 strings are sequences of characters with codes from 0 to 255,
Function:
(defun parse-from-string-to-cst (pfcs-string) (declare (xargs :guard (stringp pfcs-string))) (let ((__function__ 'parse-from-string-to-cst)) (declare (ignorable __function__)) (b* ((tokens (tokenize-pfcs pfcs-string)) ((when (reserrp tokens)) tokens) ((mv top-object next-token rest-tokens) (parse-system tokens)) ((when (reserrp top-object)) top-object) ((unless (and (null next-token) (null rest-tokens))) (reserrf (list next-token rest-tokens)))) top-object)))
Theorem:
(defthm tree-resultp-of-parse-from-string-to-cst (b* ((tree (parse-from-string-to-cst pfcs-string))) (abnf::tree-resultp tree)) :rule-classes :rewrite)