• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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
            • Tokens
              • Vl-tokentype-p
              • Vl-inttoken-p
              • Vl-plaintoken-p
              • Vl-token->etext
              • Vl-token-p
              • Vl-idtoken-p
              • Vl-token->type
              • Vl-timetoken-p
              • Vl-stringtoken-p
              • Vl-sysidtoken-p
              • Vl-extinttoken-p
              • Vl-realtoken-p
              • Vl-kill-whitespace-and-comments
                • Vl-kill-whitespace-and-comments-core
              • Vl-tokenlist->etext
              • Vl-tokenlist-p
              • Vl-tokenlist->string-with-spaces
              • Vl-idtoken-list-p
              • Vl-tokentypelist-p
              • Vl-token->breakp
              • Vl-token->loc
              • Vl-plaintokentypelist-p
              • Vl-tokenlistlist-p
              • Vl-token->string
            • 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
  • Tokens
  • Vl-commentmap-p

Vl-kill-whitespace-and-comments

Prepare a token list for parsing by removing whitespace and comment tokens, and construct a comment map from any comment tokens.

Signature
(vl-kill-whitespace-and-comments tokens) 
  → 
(mv filtered-tokens comment-map)
Arguments
tokens — Token list to process.
    Guard (vl-tokenlist-p tokens).
Returns
filtered-tokens — A copy of tokens with comments and whitespace removed.
comment-map — A comment map generated from the comment tokens.

Definitions and Theorems

Function: vl-kill-whitespace-and-comments

(defun vl-kill-whitespace-and-comments (tokens)
 (declare (xargs :guard (vl-tokenlist-p tokens)))
 (let ((__function__ 'vl-kill-whitespace-and-comments))
  (declare (ignorable __function__))
  (mbe
   :logic
   (b*
    (((when (atom tokens)) (mv nil nil))
     ((mv tokens-rest cmap-rest)
      (vl-kill-whitespace-and-comments (cdr tokens)))
     (type (vl-token->type (car tokens)))
     (new-tokens (if (or (eq type :vl-ws)
                         (eq type :vl-comment))
                     tokens-rest
                   (cons (car tokens) tokens-rest)))
     (new-cmap
       (if
        (eq type :vl-comment)
        (cons (cons (change-vl-location (vl-token->loc (car tokens))
                                        :col 0)
                    (vl-token->string (car tokens)))
              cmap-rest)
        cmap-rest)))
    (mv new-tokens new-cmap))
   :exec
   (b* (((local-stobjs nrev nrev2)
         (mv tokens cmap nrev nrev2))
        ((mv nrev nrev2)
         (vl-kill-whitespace-and-comments-core tokens nrev nrev2))
        ((mv tokens nrev) (nrev-finish nrev))
        ((mv cmap nrev2) (nrev-finish nrev2)))
     (mv tokens cmap nrev nrev2)))))

Theorem: vl-kill-whitespace-and-comments-mvtypes-0

(defthm vl-kill-whitespace-and-comments-mvtypes-0
  (true-listp (mv-nth 0
                      (vl-kill-whitespace-and-comments tokens)))
  :rule-classes :type-prescription)

Theorem: vl-kill-whitespace-and-comments-mvtypes-1

(defthm vl-kill-whitespace-and-comments-mvtypes-1
  (true-listp (mv-nth 1
                      (vl-kill-whitespace-and-comments tokens)))
  :rule-classes :type-prescription)

Theorem: vl-tokenlist-p-of-vl-kill-whitespace-and-comments

(defthm vl-tokenlist-p-of-vl-kill-whitespace-and-comments
  (implies (force (vl-tokenlist-p tokens))
           (vl-tokenlist-p
                (mv-nth 0
                        (vl-kill-whitespace-and-comments tokens)))))

Theorem: vl-commentmap-p-of-vl-kill-whitespace-and-comments

(defthm vl-commentmap-p-of-vl-kill-whitespace-and-comments
  (implies (force (vl-tokenlist-p tokens))
           (vl-commentmap-p
                (mv-nth 1
                        (vl-kill-whitespace-and-comments tokens)))))

Subtopics

Vl-kill-whitespace-and-comments-core