• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Vl-loadstate
          • Lexer
            • Lex-strings
            • Lex-identifiers
            • Vl-typo-uppercase-p
            • Vl-typo-number-p
            • Vl-typo-lowercase-p
            • Lex-numbers
            • Chartypes
            • Vl-lex
            • Defchar
              • Vl-read-while-ctype
              • Vl-ctype-p
              • Vl-ctype-list-p
            • Tokens
            • Lex-keywords
            • Lexstate
            • Make-test-tokens
            • Lexer-utils
            • Lex-comments
            • Vl-typo-uppercase-list-p
            • Vl-typo-lowercase-list-p
            • Vl-typo-number-list-p
          • Parser
          • Vl-load-merge-descriptions
          • Vl-find-basename/extension
          • Vl-load-file
          • Vl-loadresult
          • Scope-of-defines
          • Vl-find-file
          • Vl-flush-out-descriptions
          • Vl-description
          • Vl-read-file
          • Vl-includeskips-report-gather
          • Vl-load-main
          • Extended-characters
          • Vl-load
          • Vl-load-description
          • Vl-descriptions-left-to-load
          • Inject-warnings
          • Vl-preprocess-debug
          • Vl-write-preprocessor-debug-file
          • Vl-read-file-report-gather
          • Vl-load-descriptions
          • Vl-load-files
          • Translate-off
          • Vl-load-read-file-hook
          • Vl-read-file-report
          • Vl-loadstate-pad
          • Vl-load-summary
          • Vl-collect-modules-from-descriptions
          • Vl-loadstate->warnings
          • Vl-iskips-report
          • Vl-descriptionlist
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Lexer

Defchar

Introduce lexing utilites from a character recognizer.

Defchar is a macro for quickly introducing character classes and functions to read them.

General Form
(defchar basename criteria
  [:prefix prefix]
  [:pkg pkg]
  [:parents parents]
  [:short short]
  [:long long])
Example
(defchar whitespace
  (or (eql x #Space)
      (eql x #Tab)
      (eql x #Page)
      (eql x #Newline)))

The basename, prefix, and pkg are each symbols which influence the names of the new definitions and theorems we introduce. In particular,

  • The basename is the name of the main part of the new character type you are introducing.
  • The prefix is prepended to the symbol names we generate, and defaults to the symbol 'vl-. For instance, in the above example, the single-character recognizer will be named vl-whitespace-p.
  • The pkg is used to control what package the new functions and theorems are defined in. It defaults to 'VL::foo, so in the above example the symbols are introduced in the VL:: package.

Finally, the criteria is some term about the variable x. You may assume that x is an ordinary characterp, and specify what kinds of characters you want using functions such as eql and char<=.

Calling this macro introduces the following functions:

  • (PKG::PREFIX-BASENAME-P X), recognizes those characterps which satsify criteria,
  • (PKG::PREFIX-BASENAME-ECHAR-P X), recognizes those vl-echar-ps whose character satisfies criteria,
  • (PKG::PREFIX-BASENAME-LIST-P X), recognizes those character-listps where every character satisfies criteria,
  • (PKG::PREFIX-READ-WHILE-BASENAME ECHARS) splits echars into a prefix and remainder, where prefix is the longest leading list of characters that satisfy criteria.

It also introducs a number of theorems, enumerated in vl-read-while-ctype.

Subtopics

Vl-read-while-ctype
Match as many characters of some type as possible.
Vl-ctype-p
Generic stub for a character type recognizer.
Vl-ctype-list-p
(vl-ctype-list-p x) recognizes lists where every element satisfies vl-ctype-p.