• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
          • Defdefparse-implementation
            • Defdefparse-event-generation
              • Defdefparse-gen-function-for-rulename
              • Defdefparse-gen-code-for-alternation
              • Defdefparse-gen-code-for-repetition
              • Defdefparse-gen-function-for-group
              • Defdefparse-function-spec
              • Defdefparse-gen-code-for-element
              • Defdefparse-gen-*-group-macro
              • Defdefparse-gen-function-for-option
              • Defdefparse-gen-option-macro
              • Defdefparse-gen-group-macro
              • Defdefparse-gen-function-for-repetition
              • Defdefparse-gen-code-for-concatenation
              • Defdefparse-gen-*-rulename-macro
              • Defdefparse-gen-rulename-macro
              • Defdefparse-gen-repetition-alist
                • Defdefparse-gen-option-alist
                • Defdefparse-gen-group-alist
                • Defdefparse-gen-everything
                • Defdefparse-gen-repetition-table-macro
                • Defdefparse-gen-option-table-macro
                • Defdefparse-gen-group-table-macro
                • Defdefparse-gen-function-for-spec
                • Defdefparse-gen-repetition-table
                • Defdefparse-gen-option-table
                • Defdefparse-gen-group-table
                • Defdefparse-reorder-alternation
                • Defdefparse-order-permutationp
                • Defdefparse-gen-repetition-table-name
                • Defdefparse-gen-option-table-name
                • Defdefparse-gen-group-table-name
                • Defdefparse-alt-symbol-alist
                • Defdefparse-rep-symbol-alist
              • Defdefparse-fn
              • Defdefparse-input-processing
              • Defdefparse-table
              • Defdefparse-macro-definition
          • Defgrammar
          • Tree-utilities
          • Notation
          • Grammar-parser
          • Meta-circular-validation
          • Parsing-primitives-defresult
          • Parsing-primitives-seq
          • Operations
          • Examples
          • Differences-with-paper
          • Constructor-utilities
          • Grammar-printer
          • Parsing-tools
        • Vwsim
        • Isar
        • Wp-gen
        • Dimacs-reader
        • Pfcs
        • Legacy-defrstobj
        • C
        • Proof-checker-array
        • Soft
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Ethereum
        • Leftist-trees
        • Java
        • Riscv
        • Taspi
        • Bitcoin
        • Zcash
        • Des
        • X86isa
        • Sha-2
        • Yul
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Defdefparse-event-generation

    Defdefparse-gen-repetition-alist

    Generate an alist from alternations to symbols, used for the table of repetition parsing functions.

    Signature
    (defdefparse-gen-repetition-alist args prefix) → alist
    Arguments
    args — Guard (true-listp args).
    prefix — Guard (common-lisp::symbolp prefix).
    Returns
    alist — Type (defdefparse-rep-symbol-alistp alist).

    This is used by the defparse-name-repetition-table macros generated by defdefparse.

    The args parameter of this ACL2 function consists of the arguments of the defparse-name-repetition-table, which must be an even number of alternating strings and symbols. Each adjacent string-symbol pair specifies an entry in the alist.

    The string of the entry must be parsable as an ABNF repetition, from which we obtain the repetition (in ABNF abstract syntax). The symbol of the entry is used to form a function name, together with the prefix given as input to defdefparse.

    Definitions and Theorems

    Function: defdefparse-gen-repetition-alist

    (defun defdefparse-gen-repetition-alist (args prefix)
     (declare (xargs :guard (and (true-listp args)
                                 (common-lisp::symbolp prefix))))
     (let ((__function__ 'defdefparse-gen-repetition-alist))
      (declare (ignorable __function__))
      (b*
       (((when (endp args)) nil)
        ((cons repetition args) args)
        ((when (endp args))
         (raise "Found an odd number of arguments."))
        ((cons sym args) args)
        ((unless (common-lisp::stringp repetition))
         (raise "The ~x0 argument must be a string."
                repetition))
        ((mv err tree rest)
         (parse-repetition (string=>nats repetition)))
        ((when err)
         (raise "Cannot parse repetition ~s0: ~@1."
                repetition err))
        ((unless (unsigned-byte-listp 8 rest))
         (raise
          "Internal error: ~
                    rest ~x0 not all consisting of unsigned 8-bit bytes."
          rest))
        ((when (consp rest))
         (raise "Extra parsing ~s0 in repetition ~s1."
                (nats=>string rest)
                repetition))
        (rep (abstract-repetition tree))
        ((unless (common-lisp::symbolp sym))
         (raise "The ~x0 argument must be a symbol."
                sym))
        (fn (packn-pos (list prefix '- sym) prefix))
        (alist (defdefparse-gen-repetition-alist args prefix))
        ((when (member-equal rep (strip-cars alist)))
         (raise "Duplicate repetition ~s0." repetition))
        ((when (member-eq fn (strip-cdrs alist)))
         (raise "Duplicate function ~x0." fn)))
       (acons rep fn alist))))

    Theorem: defdefparse-rep-symbol-alistp-of-defdefparse-gen-repetition-alist

    (defthm
      defdefparse-rep-symbol-alistp-of-defdefparse-gen-repetition-alist
      (b* ((alist (defdefparse-gen-repetition-alist args prefix)))
        (defdefparse-rep-symbol-alistp alist))
      :rule-classes :rewrite)