• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • Soft
        • C
          • Syntax-for-tools
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
            • Grammar
            • Integer-formats
            • Types
            • Portable-ascii-identifiers
              • Paident-char-listp
              • Paident-stringp
            • Values
            • Integer-operations
            • Computation-states
            • Object-designators
            • Operations
            • Errors
            • Tag-environments
            • Function-environments
            • Character-sets
            • Flexible-array-member-removal
            • Arithmetic-operations
            • Pointer-operations
            • Bytes
            • Keywords
            • Real-operations
            • Array-operations
            • Scalar-operations
            • Structure-operations
          • Representation
          • Transformation-tools
          • Insertion-sort
          • Pack
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • 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
  • Language

Portable-ascii-identifiers

Portable ASCII identifiers.

A portable ASCII identifier is a non-empty sequence of ASCII characters that:

  • Consists of only the 26 uppercase Latin letters, the 26 lowercase Latin letters, the 10 numeric digits, and the underscore.
  • Starts with a letter or underscore.
  • Differs from all the keywords.

The rationale behind this notion is the following.

[C17:6.4.2] allows the following characters in identifiers:

  1. The ten numeric digits (but not in the starting position).
  2. The 26 uppercase Latin letters, the 26 lowercase Latin letter, and the underscore.
  3. Some ranges of universal characters (some of which cannot occur in the starting position).
  4. Other implementation-defined characters.

The characters in (1) and (2) are part of the basic source character set. The characters in (3) are presumably not part of the basic source character set, because they are non-ASCII Unicode characters, while the basic source character set maps naturally to ASCII Unicode characters; we say `presumably' because [C17] does not seem to explicitly prohibit the use of non-ASCII Unicode characters in the basic source character set (although it seems odd to do that). The characters in (4) may or may not be part of the basic source character set; [C17] imposes no constraints on them.

Recall that [C17] does not require the basic source character set to consist of ASCII characters (see source-character-set). If it does consist of ASCII characters, then the characters in (1) and (2) above are ASCII, the characters in (3) are not ASCII, and the characters in (4) may or may not be ASCII.

In our formalization of C, we currently assume that source characters include ASCII characters and the basic source character set consists of ASCII characters. Our model of identifiers uses ACL2 strings, which are a superset of the ASCII characters.

Thus, in order for our identifiers to be both ASCII and portable, they must consist exclusively of characters from (1) and (2) above, without any characters from (3) or (4). If they included characters from (3), they would not be ASCII. If they included characters from (4), they would not be portable, because those additional characters may vary across implementations.

This leads to our definition of portably ASCII identifiers, which consists of ASCII letters and digits and underscore, with the first character not a digit. They must also be distinct from keywords [C17:6.4.2.1/4].

Subtopics

Paident-char-listp
Check if a list of ACL2 characters is not empty, consists only of ASCII letters, digits, and underscores, and does not start with a digit.
Paident-stringp
Check if an ACL2 string is a portable ASCII identifier.