• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
              • Atj-input-processing
              • Atj-java-pretty-printer
                • Jexpr-rank
                  • Jexpr-rank-fix
                  • Jexpr-rank-case
                    • Jexpr-rankp
                    • Jexpr-rank-equiv
                    • Jexpr-rank-kind
                    • Jexpr-rank-unary
                    • Jexpr-rank-shift
                    • Jexpr-rank-relational
                    • Jexpr-rank-primary
                    • Jexpr-rank-postfix
                    • Jexpr-rank-multiplicative
                    • Jexpr-rank-inclusive-or
                    • Jexpr-rank-expression
                    • Jexpr-rank-exclusive-or
                    • Jexpr-rank-equality
                    • Jexpr-rank-conditional-or
                    • Jexpr-rank-conditional-and
                    • Jexpr-rank-conditional
                    • Jexpr-rank-assignment
                    • Jexpr-rank-and
                    • Jexpr-rank-additive
                  • Print-jexprs
                  • Print-jchar
                  • Print-jstatems+jblocks
                  • Print-jclasses+jcmembers
                  • Jbinop-expected-ranks
                  • Jexpr->rank
                  • Jexpr-rank-<=
                  • Print-jexpr
                  • Print-optional-integer-type-suffix
                  • Print-octdig/uscore-list
                  • Print-oct-integer-literal
                  • Print-jcunit
                  • Print-hexdig/uscore-list
                  • Print-hex-integer-literal
                  • Print-decdig/uscore-list
                  • Print-dec-integer-literal
                  • Print-bindig/uscore-list
                  • Print-bin-integer-literal
                  • Print-integer-literal
                  • Print-octdig/uscore
                  • Print-jmethod
                  • Print-jfield
                  • Print-hexdig/uscore
                  • Print-decdig/uscore
                  • Print-bindig/uscore
                  • Print-jclass-list
                  • Print-jlocvar
                  • Print-jliteral
                  • Print-jcinitializer
                  • Print-jline
                  • Print-jimports
                  • Print-jchars
                  • Print-comma-sep
                  • Print-jimport
                  • Print-jbinop
                  • Print-primitive-type
                  • Print-jparam-list
                  • Print-jlines-to-channel
                  • Jexpr-rank-index
                  • Atj-indent
                  • Print-to-jfile
                  • Print-jparam
                  • Print-jaccess
                  • Print-oct-digit
                  • Print-junop
                  • Print-jtype
                  • Print-jresult
                  • Print-hex-digit
                  • Print-dec-digit
                  • Print-bin-digit
                  • Print-jline-blank
                • Atj-code-generation
                • Atj-java-primitives
                • Atj-java-primitive-arrays
                • Atj-type-macros
                • Atj-java-syntax-operations
                • Atj-fn
                • Atj-library-extensions
                • Atj-java-input-types
                • Atj-test-structures
                • Aij-notions
                • Atj-macro-definition
              • Atj-tutorial
            • Aij
            • Language
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Jexpr-rank

    Jexpr-rank-case

    Case macro for the different kinds of jexpr-rank structures.

    This is an ACL2::fty sum-type case macro, typically introduced by fty::defflexsum or fty::deftagsum. It allows you to safely check the type of a jexpr-rank structure, or to split into cases based on its type.

    Short Form

    In its short form, jexpr-rank-case allows you to safely check the type of a jexpr-rank structure. For example:

    (jexpr-rank-case x :expression)

    is essentially just a safer alternative to writing:

    (equal (jexpr-rank-kind x) :expression)

    Why is using jexpr-rank-case safer? When we directly inspect the kind with equal, there is no static checking being done to ensure that, e.g., :expression is a valid kind of jexpr-rank structure. That means there is nothing to save you if, later, you change the kind keyword for this type from :expression to something else. It also means you get no help if you just make a typo when writing the :expression symbol. Over the course of developing VL, we found that such issues were very frequent sources of errors!

    Long Form

    In its longer form, jexpr-rank-case allows you to split into cases based on the kind of structure you are looking at. A typical example would be:

    (jexpr-rank-case x
      :expression ...
      :assignment ...
      :conditional ...
      :conditional-or ...
      :conditional-and ...
      :inclusive-or ...
      :exclusive-or ...
      :and ...
      :equality ...
      :relational ...
      :shift ...
      :additive ...
      :multiplicative ...
      :unary ...
      :postfix ...
      :primary ...)

    It is also possible to consolidate ``uninteresting'' cases using :otherwise.

    For convenience, the case macro automatically binds the fields of x for you, as appropriate for each case. That is, in the :expression case, you can use fty::defprod-style foo.bar style accessors for x without having to explicitly add a expression b* binder.