• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Lexer
            • Lex-strings
            • Lex-identifiers
            • Vl-typo-uppercase-p
            • Vl-typo-number-p
            • Vl-typo-lowercase-p
            • Lex-numbers
            • Chartypes
            • Vl-lex
              • Vl-lex-token1
                • Vl-lex-token1-token/remainder-thms
              • Vl-lex-plain-alist
              • Vl-lex-plain
              • Vl-lex-token
              • Vl-lex-main
              • Vl-lex-main-exec
            • Defchar
            • 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
          • Vl-loadstate
          • Parser
          • Vl-load-merge-descriptions
          • Scope-of-defines
          • Vl-load-file
          • Vl-flush-out-descriptions
          • Vl-description
          • Vl-loadresult
          • Vl-read-file
          • Vl-find-basename/extension
          • Vl-find-file
          • Vl-read-files
          • Extended-characters
          • Vl-load
          • Vl-load-main
          • Vl-load-description
          • Vl-descriptions-left-to-load
          • Inject-warnings
          • Vl-load-descriptions
          • Vl-load-files
          • Vl-load-summary
          • Vl-collect-modules-from-descriptions
          • Vl-descriptionlist
        • Transforms
        • Lint
        • Mlib
        • Server
        • Kit
        • Printer
        • Esim-vl
        • Well-formedness
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Vl-lex

Vl-lex-token1

Try to parse a single token at the front of echars.

Signature
(vl-lex-token1 char1 echars st warnings) 
  → 
(mv token/nil remainder warnings)
Arguments
char1 — The first character in the stream. It helps a lot with guard verification to have this separate from echars.
    Guard (characterp char1).
echars — The characters we're lexing.
    Guard (and (vl-echarlist-p echars) (consp echars)).
st — Low-level configuration options.
    Guard (vl-lexstate-p st).
warnings — Guard (vl-warninglist-p warnings).
Returns
warnings — Type (vl-warninglist-p warnings).

Definitions and Theorems

Function: vl-lex-token1$inline

(defun vl-lex-token1$inline (char1 echars st warnings)
 (declare (xargs :guard (and (characterp char1)
                             (and (vl-echarlist-p echars)
                                  (consp echars))
                             (vl-lexstate-p st)
                             (vl-warninglist-p warnings))))
 (declare (xargs :guard (eql char1 (vl-echar->char (car echars)))))
 (let ((__function__ 'vl-lex-token1))
  (declare (ignorable __function__))
  (if
   (char<= char1 #\9)
   (b* (((when (vl-whitespace-p char1))
         (b* (((mv prefix remainder)
               (vl-read-while-whitespace echars)))
           (mv (make-vl-plaintoken :etext prefix
                                   :type :vl-ws)
               remainder (ok))))
        ((when (vl-decimal-digit-p char1))
         (vl-lex-number echars st warnings)))
    (case
     char1
     (#\! (vl-lex-plain-alist echars (vl-lexstate->bangops st)
                              warnings))
     (#\" (mv-let (tok rem)
                  (vl-lex-string echars st)
            (mv tok rem (ok))))
     (#\# (vl-lex-plain-alist echars (vl-lexstate->poundops st)
                              warnings))
     (#\$ (b* (((mv tok remainder)
                (vl-lex-system-identifier
                     echars (vl-lexstate->dollarops st))))
            (mv tok remainder (ok))))
     (#\% (vl-lex-plain-alist echars (vl-lexstate->remops st)
                              warnings))
     (#\& (vl-lex-plain-alist echars (vl-lexstate->andops st)
                              warnings))
     (#\' (b* (((mv tok remainder warnings)
                (vl-lex-number echars st warnings))
               ((when tok) (mv tok remainder warnings))
               ((unless (vl-lexstate->quotesp st))
                (mv nil remainder warnings)))
            (vl-lex-plain echars "'"
                          :vl-quote warnings)))
     (#\( (vl-lex-plain-alist echars
                              '(("(*" . :vl-beginattr)
                                ("(" . :vl-lparen))
                              warnings))
     (#\) (vl-lex-plain echars ")"
                        :vl-rparen warnings))
     (#\* (vl-lex-plain-alist echars (vl-lexstate->starops st)
                              warnings))
     (#\+ (vl-lex-plain-alist echars (vl-lexstate->plusops st)
                              warnings))
     (#\, (vl-lex-plain echars ","
                        :vl-comma warnings))
     (#\- (vl-lex-plain-alist echars (vl-lexstate->dashops st)
                              warnings))
     (#\. (vl-lex-plain-alist echars (vl-lexstate->dotops st)
                              warnings))
     (#\/
        (cond ((vl-matches-string-p "//" echars)
               (mv-let (tok rem)
                       (vl-lex-oneline-comment echars)
                 (mv tok rem (ok))))
              ((vl-matches-string-p "/*" echars)
               (mv-let (tok rem)
                       (vl-lex-block-comment echars)
                 (mv tok rem (ok))))
              (t (vl-lex-plain-alist echars (vl-lexstate->divops st)
                                     warnings))))
     (otherwise (mv nil echars (ok)))))
   (if (vl-simple-id-head-p char1)
       (mv-let (tok rem)
               (vl-lex-simple-identifier-or-keyword
                    echars (vl-lexstate->kwdtable st))
         (mv tok rem (ok)))
    (case char1
          (#\: (vl-lex-plain-alist echars (vl-lexstate->colonops st)
                                   warnings))
          (#\; (vl-lex-plain echars ";"
                             :vl-semi warnings))
          (#\< (vl-lex-plain-alist echars (vl-lexstate->lessops st)
                                   warnings))
          (#\= (vl-lex-plain-alist echars (vl-lexstate->eqops st)
                                   warnings))
          (#\> (vl-lex-plain-alist echars (vl-lexstate->gtops st)
                                   warnings))
          (#\? (vl-lex-plain echars "?"
                             :vl-qmark warnings))
          (#\@ (vl-lex-plain echars "@"
                             :vl-atsign warnings))
          (#\[ (vl-lex-plain echars "["
                             :vl-lbrack warnings))
          (#\\ (mv-let (tok rem)
                       (vl-lex-escaped-identifier echars)
                 (mv tok rem (ok))))
          (#\] (vl-lex-plain echars "]"
                             :vl-rbrack warnings))
          (#\^ (vl-lex-plain-alist echars (vl-lexstate->xorops st)
                                   warnings))
          (#\{ (vl-lex-plain echars "{"
                             :vl-lcurly warnings))
          (#\| (vl-lex-plain-alist echars (vl-lexstate->barops st)
                                   warnings))
          (#\} (vl-lex-plain echars "}"
                             :vl-rcurly warnings))
          (#\~ (vl-lex-plain-alist echars
                                   '(("~&" . :vl-nand)
                                     ("~|" . :vl-nor)
                                     ("~^" . :vl-xnor)
                                     ("~" . :vl-bitnot))
                                   warnings))
          (otherwise (mv nil echars (ok))))))))

Theorem: vl-warninglist-p-of-vl-lex-token1.warnings

(defthm vl-warninglist-p-of-vl-lex-token1.warnings
  (b* (((mv ?token/nil ?remainder ?warnings)
        (vl-lex-token1$inline char1 echars st warnings)))
    (vl-warninglist-p warnings))
  :rule-classes :rewrite)

Theorem: vl-token-p-of-vl-lex-token1

(defthm vl-token-p-of-vl-lex-token1
 (implies
  (and (force (vl-echarlist-p echars))
       (and (force (consp echars))
            (force (equal char1 (vl-echar->char (car echars))))
            (force (vl-lexstate-p st))))
  (equal
      (vl-token-p (mv-nth 0
                          (vl-lex-token1 char1 echars st warnings)))
      (if (mv-nth 0
                  (vl-lex-token1 char1 echars st warnings))
          t
        nil))))

Theorem: true-listp-of-vl-lex-token1

(defthm true-listp-of-vl-lex-token1
 (equal
      (true-listp (mv-nth 1
                          (vl-lex-token1 char1 echars st warnings)))
      (true-listp echars))
 :rule-classes
 ((:rewrite)
  (:type-prescription
    :corollary
    (implies
         (true-listp echars)
         (true-listp
              (mv-nth 1
                      (vl-lex-token1 char1 echars st warnings)))))))

Theorem: vl-echarlist-p-of-vl-lex-token1

(defthm vl-echarlist-p-of-vl-lex-token1
 (implies
      (force (vl-echarlist-p echars))
      (equal (vl-echarlist-p
                  (mv-nth 1
                          (vl-lex-token1 char1 echars st warnings)))
             t)))

Theorem: append-of-vl-lex-token1

(defthm append-of-vl-lex-token1
 (implies
  (and (mv-nth 0
               (vl-lex-token1 char1 echars st warnings))
       (force (vl-echarlist-p echars))
       (and (force (consp echars))
            (force (equal char1 (vl-echar->char (car echars))))
            (force (vl-lexstate-p st))))
  (equal
     (append (vl-token->etext
                  (mv-nth 0
                          (vl-lex-token1 char1 echars st warnings)))
             (mv-nth 1
                     (vl-lex-token1 char1 echars st warnings)))
     echars)))

Theorem: no-change-loser-of-vl-lex-token1

(defthm no-change-loser-of-vl-lex-token1
  (implies (not (mv-nth 0
                        (vl-lex-token1 char1 echars st warnings)))
           (equal (mv-nth 1
                          (vl-lex-token1 char1 echars st warnings))
                  echars)))

Theorem: acl2-count-of-vl-lex-token1-weak

(defthm acl2-count-of-vl-lex-token1-weak
  (<= (acl2-count (mv-nth 1
                          (vl-lex-token1 char1 echars st warnings)))
      (acl2-count echars))
  :rule-classes ((:rewrite) (:linear)))

Theorem: acl2-count-of-vl-lex-token1-strong

(defthm acl2-count-of-vl-lex-token1-strong
 (implies
   (and (mv-nth 0
                (vl-lex-token1 char1 echars st warnings))
        (force (equal char1 (vl-echar->char (car echars)))))
   (< (acl2-count (mv-nth 1
                          (vl-lex-token1 char1 echars st warnings)))
      (acl2-count echars)))
 :rule-classes ((:rewrite) (:linear)))

Subtopics

Vl-lex-token1-token/remainder-thms
Token and remainder theorems for vl-lex-token1, automatically generated by def-token/remainder-thms.