• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • 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
        • Transformations
        • Language
          • Abstract-syntax
          • Dynamic-semantics
          • Concrete-syntax
            • Lexer
            • Parser
              • Parse-keyword
              • Parse-variable-declaration
              • Parse-symbol
              • Parse-literal
              • Parse-identifier
              • Hex-chars-and-uscores-to-hex-string-rest-element-list
              • Parse-assignment-statement
                • Parse-identifier-and-open-paren
                • Parse-*-comma-identifier
                • Parse-*-.-identifier
                • Parse-continue-statement
                • Parse-*-comma-path
                • Parse-path
                • Parse-leave-statement
                • Parse-break-statement
                • Cst2ast-hex-string
                • Cst2ast-string-literal-content
                • Cst2ast-escape-sequence
                • Cst2ast-string-literal-contents
                • Cst2ast-quoted-printable
                • Parse-yul
                • Cst2ast-string-literal
                • Parse-yul-bytes
                • Cst2ast-hex-number
                • Cst2ast-uhhhh
                • Cst2ast-literal-kind
                • Cst2ast-decimal-number
                • Cst2ast-xhh
                • Cst2ast-single-char
                • Cst2ast-boolean
                • Parse-*-case-clause
                • Looks-like-hex-string-fringe
                • Cst2ast-hex-digit-char-list
                • Parse-*-statement
                • Parse-*-comma-expression
                • Parse-switch-statement
                • Parse-if-statement
                • Parse-for-statement
                • Parse-expression
                • Parse-case-clause
                • Parse-fundef
                • Parse-function-call
                • Parse-block
                • *single-quote-tree-list*
                • *double-quote-tree-list*
                • *yul-keywords*
                • *single-quoted-content-rulenames*
                • *list-leafterm-x*
                • *list-leafterm-u*
                • *list-leafterm-92*
                • *double-quoted-content-rulenames*
                • *yul-symbols*
              • Grammar-old
              • Grammar
              • Tokenizer
            • Static-soundness
            • Static-semantics
            • Errors
          • Yul-json
        • 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
    • Parser

    Parse-assignment-statement

    Attempts to eat an assignment statement and build a statement AST node of kind :assign-single or :assign-multiple.

    Signature
    (parse-assignment-statement tokens) 
      → 
    (mv result-ast tokens-after-statement)
    Arguments
    tokens — Guard (abnf::tree-listp tokens).
    Returns
    result-ast — Type (statement-resultp result-ast).
    tokens-after-statement — Type (abnf::tree-listp tokens-after-statement).

    Definitions and Theorems

    Function: parse-assignment-statement

    (defun parse-assignment-statement (tokens)
     (declare (xargs :guard (abnf::tree-listp tokens)))
     (let ((__function__ 'parse-assignment-statement))
      (declare (ignorable __function__))
      (b*
       (((mv path-ast tokens-after-path)
         (parse-path tokens))
        ((when (reserrp path-ast))
         (mv (reserrf (cons "no assignment statement here" tokens))
             nil))
        ((mv additional-paths
             tokens-after-additional-paths)
         (parse-*-comma-path tokens-after-path))
        (tokens-after-assignment-symbol
             (parse-symbol ":=" tokens-after-additional-paths))
        ((when (reserrp tokens-after-assignment-symbol))
         (mv (reserrf (cons "assignment statement requires ':='"
                            tokens))
             nil))
        ((mv init-ast tokens-after-init-form)
         (if (null additional-paths)
             (parse-expression tokens-after-assignment-symbol)
           (parse-function-call tokens-after-assignment-symbol)))
        ((when (reserrp init-ast))
         (mv
          (reserrf (cons "assignment statement does not finish properly"
                         tokens))
          nil)))
       (mv (if (null additional-paths)
               (make-statement-assign-single :target path-ast
                                             :value init-ast)
             (make-statement-assign-multi
                  :targets (cons path-ast additional-paths)
                  :value init-ast))
           tokens-after-init-form))))

    Theorem: statement-resultp-of-parse-assignment-statement.result-ast

    (defthm statement-resultp-of-parse-assignment-statement.result-ast
      (b* (((mv ?result-ast ?tokens-after-statement)
            (parse-assignment-statement tokens)))
        (statement-resultp result-ast))
      :rule-classes :rewrite)

    Theorem: tree-listp-of-parse-assignment-statement.tokens-after-statement

    (defthm
        tree-listp-of-parse-assignment-statement.tokens-after-statement
      (b* (((mv ?result-ast ?tokens-after-statement)
            (parse-assignment-statement tokens)))
        (abnf::tree-listp tokens-after-statement))
      :rule-classes :rewrite)

    Theorem: len-of-parse-assignment-statement-<

    (defthm len-of-parse-assignment-statement-<
      (b* (((mv ?result-ast ?tokens-after-statement)
            (parse-assignment-statement tokens)))
        (implies (not (reserrp result-ast))
                 (< (len tokens-after-statement)
                    (len tokens))))
      :rule-classes :linear)