• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • ACL2
    • Macro-libraries
    • 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-mark-as-explicit-parens

    Annotate an expression as having explicit parentheses.

    Signature
    (vl-mark-as-explicit-parens x) → new-x
    Arguments
    x — Guard (vl-expr-p x).
    Returns
    new-x — Type (vl-expr-p new-x), given the guard.

    For some kinds of linting checks, we may want to know whether the original expression had any parens, e.g., we might want to warn the user if they have typed

    a & b < c

    Because this gets parsed as a & (b < c), which seems strange and may catch the user by surprise. On the other hand, if they've typed

    a & (b < c)

    Then, as strange as this is, it seems to be what they want, and we probably don't want to complain about it.

    But these expressions will be identical after parsing unless we somehow remember where explicit parens were. To facilitate this, we set the VL_EXPLICIT_PARENS attribute on non-atoms that have explicit parens.

    Note that we don't bother to set VL_EXPLICIT_PARENS on atoms, e.g., the following really are still parsed equivalently:

    (a) & b      vs.    a & b

    This is possibly unfortunate, but atoms don't have attributes so what else would we do?

    Definitions and Theorems

    Function: vl-mark-as-explicit-parens

    (defun vl-mark-as-explicit-parens (x)
      (declare (xargs :guard (vl-expr-p x)))
      (let ((__function__ 'vl-mark-as-explicit-parens))
        (declare (ignorable __function__))
        (b* (((when (vl-fast-atom-p x)) x)
             (atts (vl-nonatom->atts x))
             (atts (acons "VL_EXPLICIT_PARENS" nil atts)))
          (change-vl-nonatom x :atts atts))))

    Theorem: vl-expr-p-of-vl-mark-as-explicit-parens

    (defthm vl-expr-p-of-vl-mark-as-explicit-parens
      (implies (and (vl-expr-p x))
               (b* ((new-x (vl-mark-as-explicit-parens x)))
                 (vl-expr-p new-x)))
      :rule-classes :rewrite)