• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
          • Syntax-for-tools
            • Formalized-subset
            • Mapping-to-language-definition
            • Input-files
            • Compilation-database
            • Printer
            • Output-files
            • Abstract-syntax-operations
            • Implementation-environments
            • Abstract-syntax
            • Concrete-syntax
            • Disambiguation
              • Disambiguator
                • Dimb-exprs/decls/stmts
                  • Dimb-dirdeclor
                  • Dimb-expr
                  • Dimb-amb-declor/absdeclor
                    • Dimb-amb-expr/tyname
                    • Dimb-declor
                    • Dimb-type-spec
                    • Dimb-param-declor
                    • Dimb-decl-spec
                    • Dimb-param-declon
                    • Dimb-amb-decl/stmt
                    • Dimb-initdeclor
                    • Dimb-stmt
                    • Dimb-comp-stmt
                    • Dimb-declor-option
                    • Dimb-enum-spec
                    • Dimb-decl
                    • Dimb-struct-declor
                    • Dimb-initdeclor-list
                    • Dimb-decl-spec-list
                    • Dimb-absdeclor
                    • Dimb-dirabsdeclor
                    • Dimb-align-spec
                    • Dimb-struni-spec
                    • Dimb-spec/qual-list
                    • Dimb-spec/qual
                    • Dimb-param-declon-list
                    • Dimb-enumer-list
                    • Dimb-enumer
                    • Dimb-dirabsdeclor-option
                    • Dimb-block-item
                    • Dimb-struct-declor-list
                    • Dimb-struct-declon-list
                    • Dimb-struct-declon
                    • Dimb-statassert
                    • Dimb-label
                    • Dimb-desiniter-list
                    • Dimb-desiniter
                    • Dimb-decl-list
                    • Dimb-const-expr-option
                    • Dimb-absdeclor-option
                    • Dimb-member-designor
                    • Dimb-initer-option
                    • Dimb-genassoc-list
                    • Dimb-genassoc
                    • Dimb-expr-option
                    • Dimb-expr-list
                    • Dimb-designor-list
                    • Dimb-designor
                    • Dimb-const-expr
                    • Dimb-block-item-list
                    • Dimb-tyname
                    • Dimb-initer
                  • Dimb-make/adjust-expr-cast
                  • Dimb-make/adjust-expr-binary
                  • Dimb-params-to-names
                  • Dimb-fundef
                  • Dimb-cast/call-to-call
                  • Dimb-transunit
                  • Dimb-dirdeclor
                  • Dimb-transunit-ensemble
                  • Dimb-make/adjust-expr-unary
                  • Dimb-expr
                  • Dimb-amb-declor/absdeclor
                    • Dimb-cast/call-to-cast
                    • Dimb-cast/addsub-to-cast
                    • Dimb-cast/addsub-to-addsub
                    • Dimb-add-ident
                    • Dimb-kind
                    • Dimb-amb-expr/tyname
                    • Dimb-cast/logand-to-logand
                    • Dimb-cast/and-to-cast
                    • Dimb-extdecl-list
                    • Dimb-cast/mul-to-cast
                    • Dimb-cast/logand-to-cast
                    • Dimb-extdecl
                    • Dimb-cast/mul-to-mul
                    • Dimb-cast/and-to-and
                    • Dimb-declor
                    • Dimb-kind-option
                    • Dimb-type-spec
                    • Dimb-add-ident-objfun-file-scope
                    • Dimb-make/adjust-expr-label-addr
                    • Dimb-param-declor
                    • Dimb-lookup-ident
                    • Dimb-decl-spec
                    • Dimb-add-idents-objfun
                    • Dimb-add-ident-objfun
                    • Dimb-param-declon
                    • Dimb-amb-decl/stmt
                    • Dimb-table
                    • Dimb-pop-scope
                    • Dimb-initdeclor
                    • Dimb-stmt
                    • Dimb-push-scope
                    • Dimb-comp-stmt
                    • Dimb-declor-option
                    • Dimb-enum-spec
                    • Dimb-decl
                    • Dimb-struct-declor
                    • Dimb-scope
                    • Dimb-initdeclor-list
                    • Dimb-decl-spec-list
                    • Dimb-absdeclor
                    • Dimb-dirabsdeclor
                    • Dimb-align-spec
                    • Dimb-struni-spec
                    • Dimb-init-table
                    • Dimb-spec/qual-list
                    • Dimb-spec/qual
                    • Irr-dimb-table
                    • Irr-dimb-kind
                    • Dimb-param-declon-list
                    • Dimb-enumer-list
                    • Dimb-enumer
                    • Dimb-dirabsdeclor-option
                    • Dimb-block-item
                    • Dimb-struct-declor-list
                    • Dimb-struct-declon-list
                    • Dimb-struct-declon
                    • Dimb-statassert
                    • Dimb-label
                    • Dimb-desiniter-list
                    • Dimb-desiniter
                    • Dimb-decl-list
                    • Dimb-const-expr-option
                    • Dimb-absdeclor-option
                    • Dimb-member-designor
                    • Dimb-initer-option
                    • Dimb-genassoc-list
                    • Dimb-genassoc
                    • Dimb-expr-option
                    • Dimb-expr-list
                    • Dimb-designor-list
                    • Dimb-designor
                    • Dimb-const-expr
                    • Dimb-block-item-list
                    • Dimb-tyname
                    • Dimb-initer
                  • Unambiguity
                • Validation
                • Gcc-builtins
                • Preprocessing
                • Parsing
              • Atc
              • Transformation-tools
              • Language
              • Representation
              • Insertion-sort
              • Pack
            • Soft
            • Bv
            • Imp-language
            • Ethereum
            • Event-macros
            • Java
            • Riscv
            • Bitcoin
            • Zcash
            • Yul
            • ACL2-programming-language
            • Prime-fields
            • Json
            • Syntheto
            • File-io-light
            • Cryptography
            • Number-theory
            • Axe
            • Lists-light
            • Builtins
            • Solidity
            • Helpers
            • Htclient
            • Typed-lists-light
            • Arithmetic-light
          • X86isa
          • Axe
          • Execloader
        • Math
        • Testing-utilities
      • Disambiguator
      • Dimb-exprs/decls/stmts

      Dimb-amb-declor/absdeclor

      Disambiguate an ambiguous declarator or abstract declarator.

      Signature
      (dimb-amb-declor/absdeclor declor/absdeclor table) 
        → 
      (mv erp declor-or-absdeclor ident? new-table)
      Arguments
      declor/absdeclor — Guard (amb-declor/absdeclor-p declor/absdeclor).
      table — Guard (dimb-tablep table).
      Returns
      erp — Type (maybe-msgp erp).
      declor-or-absdeclor — Type (declor/absdeclor-p declor-or-absdeclor).
      ident? — Type (ident-optionp ident?).
      new-table — Type (dimb-tablep new-table).

      An ambiguous declarator or abstract declarator is represented as a pair of a declarator and an abstract declarator (with the same concrete syntax appearance). We attempt to disambiguate both the declarator and the abstract declarator, independently from each other. If both fail, the code is invalid. If one of them succeeds while the other fails, we have a disambiguation. There are cases in which both can succeed, for instance in void f(int(x)); the (x) could be a parenthesized declarator for identifier x, but if a typedef for x is in scope, it could be also an abstract function declarator, where x is the type of the (inner) parameter. [C17:6.7.6.3/11] says that in this case the typedef interpretation takes priority. Thus, in general, if both attempted disambiguations (as declarator and as abstract declarator) succeed, we check if the identifier returned by the successful disambiguation as declarator denotes a typedef name: if the check succeeds, we keep the disambiguation as abstract declarator and discard the one as declarator. If instead the check fails, we return an error: we conjecture that this should only happen if the code is invalid, but this needs further investigation.

      If the ambiguous declarator or abstract declarator turns out to be a declarator, we also return the identifier it declares. If it turns out to be an abstract declarator instead, we return nil. So, in general, this function returns an optional identifier, besides the disambiguated declarator or abstract declarator.

      In the call of dimb-declor we pass nil as the fundefp flag, because if we are disambiguating a declarator or abstract declarator, it means that we are disambiguating a parameter declarator, and not the declarator of a defined function.