Match basic, atomic kinds of
(vl-maybe-parse-base-primary &key (tokstream 'tokstream) (config 'config)) → (mv errmsg? value new-tokstream)
In SystemVerilog-2012, we have:
primary ::= primary_literal | 'this' | '$' | 'null' | ... other, more complex things ... primary_literal ::= number | time_literal | unbased_unsized_literal | string_literal number ::= integral_number | real_number integral_number ::= decimal_number | octal_number | binary_number | hex_number
This is very similar to the
primary ::= number | string | ... other, more complex things ... number ::= decimal_number | octal_number | binary_number | hex_number | real_number
We ignore the "other, more complex things" here, and just focus on the
simple primaries. Aside from some minor lexical differences at the tips which
are handled by the lexer (see for instance lex-strings and lex-numbers) the main difference here is that SystemVerilog adds time
literals, unbased unsized literals,
Function:
(defun vl-maybe-parse-base-primary-fn (tokstream config) (declare (xargs :stobjs (tokstream))) (declare (xargs :guard (vl-loadconfig-p config))) (declare (ignorable config)) (let ((__function__ 'vl-maybe-parse-base-primary)) (declare (ignorable __function__)) (seq tokstream (linestart := (vl-linestart-indent)) (when (vl-is-token? :vl-inttoken) (int := (vl-match)) (return (make-vl-literal :val (vl-make-guts-from-inttoken int) :atts (vl-extend-atts-with-linestart linestart nil)))) (when (vl-is-token? :vl-realtoken) (real := (vl-match)) (return (b* ((value (vl-echarlist->string (vl-realtoken->etext real)))) (make-vl-literal :val (make-vl-real :value value) :atts (vl-extend-atts-with-linestart linestart nil))))) (when (vl-is-token? :vl-stringtoken) (str := (vl-match)) (return (b* ((value (vl-stringtoken->expansion str))) (make-vl-literal :val (make-vl-string :value value) :atts (vl-extend-atts-with-linestart linestart nil))))) (when (eq (vl-loadconfig->edition config) :verilog-2005) (return nil)) (when (vl-is-token? :vl-extinttoken) (ext := (vl-match)) (return (b* ((value (vl-extinttoken->value ext))) (make-vl-literal :val (make-vl-extint :value value) :atts (vl-extend-atts-with-linestart linestart nil))))) (when (vl-is-token? :vl-timetoken) (time := (vl-match)) (return (b* (((vl-timetoken time) time)) (make-vl-literal :val (make-vl-time :quantity time.quantity :units time.units) :atts (vl-extend-atts-with-linestart linestart nil))))) (when (vl-is-token? :vl-kwd-null) (:= (vl-match)) (return (hons-copy (make-vl-special :key :vl-null :atts (vl-extend-atts-with-linestart linestart nil))))) (when (vl-is-token? :vl-$) (:= (vl-match)) (return (hons-copy (make-vl-special :key :vl-$ :atts (vl-extend-atts-with-linestart linestart nil))))) (return nil))))
Theorem:
(defthm vl-maybe-parse-base-primary-never-fails (not (mv-nth 0 (vl-maybe-parse-base-primary))))
Theorem:
(defthm vl-maybe-parse-base-primary-result (implies (and (not (mv-nth 0 (vl-maybe-parse-base-primary))) (and t)) (vl-maybe-expr-p (mv-nth 1 (vl-maybe-parse-base-primary)))))
Theorem:
(defthm vl-maybe-parse-base-primary-count-strong-on-value (and (<= (vl-tokstream-measure :tokstream (mv-nth 2 (vl-maybe-parse-base-primary))) (vl-tokstream-measure)) (implies (mv-nth 1 (vl-maybe-parse-base-primary)) (< (vl-tokstream-measure :tokstream (mv-nth 2 (vl-maybe-parse-base-primary))) (vl-tokstream-measure)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm tokens-nonempty-when-vl-maybe-parse-base-primary (b* (((mv ?errmsg val ?new-tokstream) (vl-maybe-parse-base-primary))) (implies val (consp (vl-tokstream->tokens)))))