• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
        • Acre-internals
          • Regex
            • Regex-case
              • Regex-p
              • Regex-equiv
              • Regex-zerolength
              • Regex-repeat
              • Regex-group
              • Regex-charset
              • Regex-case-sens
              • Regex-kind
              • Regex-reverse-pref
              • Regex-no-backtrack
              • Regex-exact
              • Regex-disjunct
              • Regex-concat
              • Regex-backref
              • Regex-start
              • Regex-end
              • Regexlist
              • Regex-fix
              • Regex-count
            • Match-string-at
            • Matchstatelist-measure
            • Parse-primitive
            • Matches-remove-zero-length
            • Parse-repeatop
            • Parse-repeatbase
            • Matchstatelist-in-bounds
            • Parse-range
            • Parse-charset-set
            • Parse-charset-atom
            • Match-regex-locs
            • Parse-octal-charcode
            • Parse-k-backref
            • Parse-g-backref
            • Matchstatelist-all-have-backref
            • Parse-repeatmod
            • Parse-charset-elem
            • Parse-charset-aux
            • Parse-hex-charcode
            • Parse-charset
            • Matchstatelist-indices-lte
            • Matchstatelist-indices-gte
            • Match-exact
            • Matches-add-backref
            • Matchresult
            • Preproc-legible-aux
            • Maybe-backref
            • Match-charset
            • Undup-equiv
            • Find-substr
            • Maybe-backref-extract-substr
            • Matchstatelist-min-index
            • Matchstate-in-bounds
            • Match-add-backref
            • Undup
            • Backref-alist-in-bounds
            • Backref
            • Matchstate
            • Matchresult->matched-substr
            • Matchresult->captured-substr!
            • Matchresult->captured-substr
            • Maybe-backref-in-bounds
            • Matchmode
            • Backref-extract-substr
            • Charset-range
            • Matchstate-measure
            • Backref-in-bounds
            • Rev-keys
            • Parse-regex
            • Undup-exec
            • Get-charset
            • Regex-concat2
            • Preproc-legible
            • Matchresult-in-bounds
            • Regex-disjunct2
            • Backref-alist
            • Named-captures-bindings
            • Captures-bindings
            • Matchstatelist
            • Charset-char-regex
            • Repeatmod-p
          • Parse-and-match-regex
          • Match-regex
          • Parse
          • Matchresult->matchedp
          • Match
        • Milawa
        • Smtlink
        • Abnf
        • Vwsim
        • Isar
        • Wp-gen
        • Dimacs-reader
        • Pfcs
        • Legacy-defrstobj
        • Proof-checker-array
        • Soft
        • C
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Regex

    Regex-case

    Case macro for the different kinds of regex structures.

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

    Short Form

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

    (regex-case x :exact)

    is essentially just a safer alternative to writing:

    (equal (regex-kind x) :exact)

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

    Long Form

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

    (regex-case x
      :exact ...
      :repeat ...
      :concat ...
      :disjunct ...
      :charset ...
      :start ...
      :end ...
      :group ...
      :backref ...
      :reverse-pref ...
      :no-backtrack ...
      :case-sens ...
      :zerolength ...)

    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 :exact case, you can use defprod-style foo.bar style accessors for x without having to explicitly add a exact b* binder.