Checks if the given string can be parsed to a Leo expression CST.
Checks that the given string is lexed, tokenized, and parsed successfully
and checks that the CST from parsing has the root rule name
Does not check that the lexemes have the same fringe as the given string. For that you want expression-parses-same-fringe?.
Function:
(defun expression-parses? (expression-string) (declare (xargs :guard (stringp expression-string))) (let ((__function__ 'expression-parses?)) (declare (ignorable __function__)) (b* ((tree? (parse-fragment-to-cst "expression" expression-string))) (and (abnf::treep tree?) (abnf-tree-with-root-p tree? "expression")))))
Theorem:
(defthm booleanp-of-expression-parses? (b* ((yes/no (expression-parses? expression-string))) (booleanp yes/no)) :rule-classes :rewrite)