• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Std/io
      • Oslib
      • Bridge
      • Clex
        • Example-lexer
          • Token-p
          • Lex-punctuation
          • Lex-id/keyword
          • Lex-string
            • Lex-whitespace
            • Lex-comment
            • Lex1
            • Lex-main
            • Lex*
            • Tokenlist-p
            • Letter-char-p
            • Idtail-char-p
            • Whitespace-char-p
            • Number-char-p
            • Tokentype-p
            • Lex*-exec
            • Newline-string
          • Sin
          • Matching-functions
          • Def-sin-progress
        • Tshell
        • Unsound-eval
        • Hacker
        • ACL2s-interface
        • Startup-banner
        • Command-line
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Example-lexer

    Lex-string

    Complete wrapper: lex an ACL2 string.

    Signature
    (lex-string contents &key (filename '"")) → (mv errmsg tokens)
    Arguments
    contents — What to lex, typically the contents of the file.
        Guard (stringp contents).
    filename — The name of the file, used only for better error messages.
        Guard (stringp filename).
    Returns
    errmsg — nil on success, or an error message (as a string) on failure.
        Type (or (stringp errmsg) (not errmsg)).
    tokens — Type (tokenlist-p tokens).

    This just takes care of creating a local sin to use, then calls lex-main to do the real work.

    Definitions and Theorems

    Function: lex-string-fn

    (defun lex-string-fn (contents filename)
      (declare (xargs :guard (and (stringp contents)
                                  (stringp filename))))
      (let ((__function__ 'lex-string))
        (declare (ignorable __function__))
        (with-local-stobj
             sin
             (mv-let (errmsg tokens sin)
                     (b* ((sin (sin-init contents filename sin)))
                       (lex-main sin))
               (mv errmsg tokens)))))

    Theorem: return-type-of-lex-string.errmsg

    (defthm return-type-of-lex-string.errmsg
      (b* (((mv ?errmsg ?tokens)
            (lex-string-fn contents filename)))
        (or (stringp errmsg) (not errmsg)))
      :rule-classes :type-prescription)

    Theorem: tokenlist-p-of-lex-string.tokens

    (defthm tokenlist-p-of-lex-string.tokens
      (b* (((mv ?errmsg ?tokens)
            (lex-string-fn contents filename)))
        (tokenlist-p tokens))
      :rule-classes :rewrite)

    Theorem: tokenlist-all-text-of-lex-string

    (defthm tokenlist-all-text-of-lex-string
      (b* (((mv errmsg tokens)
            (lex-string contents
                        :filename filename)))
        (implies (not errmsg)
                 (equal (tokenlist-all-text tokens)
                        (if (stringp contents) contents "")))))