• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Lexer
          • Vl-loadstate
          • Parser
            • Parse-expressions
              • Vl-parse-parameter-value-assignment-hack
              • Vl-erange-p
              • Vl-mixed-binop-list-p
              • Vl-parse-very-simple-type
              • Vl-mark-as-explicit-parens
              • Vl-parse-0+-scope-prefixes
              • Vl-parse-0+-attribute-instances
              • Vl-parse-op
                • Vl-parse-hierarchical-identifier
                • Vl-parse-pva-tail
                • Vl-parse-expression-top
                • Vl-parse-any-sort-of-concatenation
                • Vl-build-indexing-nest
                • Vl-erangetypelist-p
                • Vl-build-range-select-with
                • Vl-build-range-select
                • Vl-parse-simple-type
                • Vl-expr-has-any-atts-p
                • Vl-left-associate-mixed-binop-list
                • Vl-tack-scopes-onto-hid
                • Vl-parse-op-alist-p
                • Vl-make-guts-from-inttoken
                • Vl-parse-range-expression
                • Vl-parse-slice-size
                • Vl-parse-concatenation
                • Vl-parse-stream-expression
                • Vl-parse-1+-stream-expressions-separated-by-commas
                • Vl-parse-stream-concatenation
                • Vl-parse-primary
                • Vl-parse-0+-bracketed-expressions
                • Vl-parse-system-function-call
                • Vl-parse-shift-expression-aux
                • Vl-parse-power-expression-aux
                • Vl-parse-mult-expression-aux
                • Vl-parse-mintypmax-expression
                • Vl-parse-logor-expression-aux
                • Vl-parse-logand-expression-aux
                • Vl-parse-indexed-id-2012
                • Vl-parse-indexed-id-2005
                • Vl-parse-equality-expression-aux
                • Vl-parse-equality-expression
                • Vl-parse-compare-expression-aux
                • Vl-parse-bitxor-expression-aux
                • Vl-parse-bitor-expression-aux
                • Vl-parse-bitand-expression-aux
                • Vl-parse-1+-open-value-ranges
                • Vl-parse-1+-keyval-expression-pairs
                • Vl-parse-unary-expression
                • Vl-parse-shift-expression
                • Vl-parse-qmark-expression
                • Vl-parse-primary-main
                • Vl-parse-primary-cast
                • Vl-parse-power-expression
                • Vl-parse-open-value-range
                • Vl-parse-nonprimary-cast
                • Vl-parse-mult-expression
                • Vl-parse-logor-expression
                • Vl-parse-logand-expression
                • Vl-parse-indexed-id
                • Vl-parse-impl-expression
                • Vl-parse-function-call
                • Vl-parse-expression
                • Vl-parse-compare-expression
                • Vl-parse-bitxor-expression
                • Vl-parse-bitor-expression
                • Vl-parse-bitand-expression
                • Vl-parse-assignment-pattern
                • Vl-parse-add-expression-aux
                • Vl-parse-add-expression
                • Vl-parse-1+-expressions-separated-by-commas
              • Parse-udps
              • Vl-genelements
              • Parse-paramdecls
              • Parse-blockitems
              • Parse-utils
              • Parse-insts
              • Parse-datatype
              • Parse-functions
              • Parse-datatypes
              • Parse-strengths
              • Vl-parse-genvar-declaration
              • Vl-parse
              • Parse-ports
              • Seq
              • Parse-packages
            • Vl-load-merge-descriptions
            • Scope-of-defines
            • Vl-load-file
            • Vl-flush-out-descriptions
            • Vl-description
            • Vl-loadresult
            • Vl-read-file
            • Vl-find-basename/extension
            • Vl-find-file
            • Vl-read-files
            • Extended-characters
            • Vl-load
            • Vl-load-main
            • Vl-load-description
            • Vl-descriptions-left-to-load
            • Inject-warnings
            • Vl-load-descriptions
            • Vl-load-files
            • Vl-load-summary
            • Vl-collect-modules-from-descriptions
            • Vl-descriptionlist
          • Transforms
          • Lint
          • Mlib
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Parse-expressions

    Vl-parse-op

    Compatible with seq. Match any of the tokens specified in this alist, and return the corresponding vl-op-p for it.

    Signature
    (vl-parse-op arity alist &key (tokstream 'tokstream) 
                 (config 'config)) 
     
      → 
    (mv errmsg? value new-tokstream)
    Arguments
    config — Guard (vl-loadconfig-p config).

    This helps to avoid many case splits throughout our operator parsing functions.

    Definitions and Theorems

    Function: vl-parse-op-fn

    (defun vl-parse-op-fn (arity alist tokstream config)
      (declare (xargs :stobjs (tokstream)))
      (declare (xargs :guard (vl-loadconfig-p config)))
      (declare (ignorable config))
      (declare (xargs :guard (and (maybe-natp arity)
                                  (vl-parse-op-alist-p arity alist))))
      (let ((__function__ 'vl-parse-op))
        (declare (ignorable __function__))
        (seq tokstream
             (when (or (atom (vl-tokstream->tokens))
                       (atom alist))
                   (return nil))
             (when (vl-is-token? (caar alist))
                   (:= (vl-match))
                   (return (cdar alist)))
             (return-raw (vl-parse-op arity (cdr alist))))))

    Theorem: vl-parse-op-never-fails

    (defthm vl-parse-op-never-fails
      (not (mv-nth 0 (vl-parse-op arity alist))))

    Theorem: vl-parse-op-result

    (defthm vl-parse-op-result
     (implies
          (and (not (mv-nth 0 (vl-parse-op arity alist)))
               (and (and (force (maybe-natp arity))
                         (force (vl-parse-op-alist-p arity alist)))))
          (and (equal (vl-op-p (mv-nth 1 (vl-parse-op arity alist)))
                      (if (mv-nth 1 (vl-parse-op arity alist))
                          t
                        nil))
               (equal (vl-op-arity (mv-nth 1 (vl-parse-op arity alist)))
                      (if (mv-nth 1 (vl-parse-op arity alist))
                          arity
                        (vl-op-arity nil))))))

    Theorem: vl-parse-op-count-strong-on-value

    (defthm vl-parse-op-count-strong-on-value
     (and
       (<= (vl-tokstream-measure
                :tokstream (mv-nth 2 (vl-parse-op arity alist)))
           (vl-tokstream-measure))
       (implies (mv-nth 1 (vl-parse-op arity alist))
                (< (vl-tokstream-measure
                        :tokstream (mv-nth 2 (vl-parse-op arity alist)))
                   (vl-tokstream-measure))))
     :rule-classes ((:rewrite) (:linear)))

    Theorem: vl-parse-op-when-atom

    (defthm vl-parse-op-when-atom
      (implies (atom (vl-tokstream->tokens))
               (not (mv-nth 1 (vl-parse-op arity alist)))))

    Theorem: vl-parse-op-eof-helper

    (defthm vl-parse-op-eof-helper
      (b* (((mv ?err ?val new-tokstream)
            (vl-parse-op arity alist
                         :tokstream tokstream)))
        (implies (consp (vl-tokstream->tokens :tokstream new-tokstream))
                 (consp (vl-tokstream->tokens))))
      :rule-classes
      ((:forward-chaining :trigger-terms ((vl-parse-op arity alist)))))