• 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
        • Sin
          • Strin-p
          • Sin$c
        • Matching-functions
        • Def-sin-progress
      • Tshell
      • Unsound-eval
      • Hacker
      • ACL2s-interface
      • Startup-banner
      • Command-line
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Clex

Sin

Abstract ACL2::stobj for a string input stream.

The sin ("string input") stobj allows you to efficiently, easily process strings in a stream-like, sequential fashion, while remembering the line and column number you are currently at and (if applicable) the name of the file that the input came from.

This abstraction is especially useful for writing lexers or parsers, which typically involve scanning through the string from the front, and breaking it apart into individual tokens. Practically speaking, any lexer or parser that will actually be used needs to be able to provide location information to help its user track down errors.

Logically, the sin stobj is viewed as a strin-p structure. which is an ordinary defaggregate with a character list, line number, column number, and filename. In the execution, the character list is replaced with a string and an index into that string, and destructive updates are used to keep memory usage down.

Definition: sin

(defabsstobj sin
  :foundation sin$c
  :recognizer (sinp :logic strin-p :exec sin$cp)
  :creator (create-sin :logic empty-strin
                       :exec create-sin$c)
  :corr-fn sin$corr
  :exports ((sin-init :logic strin-init
                      :exec sin$c-init
                      :protect t)
            (sin-line :logic strin-get-line$inline
                      :exec sin$c-get-line$inline)
            (sin-col :logic strin-get-col$inline
                     :exec sin$c-get-col$inline)
            (sin-file :logic strin-get-file$inline
                      :exec sin$c-get-file$inline)
            (sin-endp :logic strin-endp
                      :exec sin$c-endp$inline)
            (sin-len :logic strin-len
                     :exec sin$c-len$inline)
            (sin-car :logic strin-car
                     :exec sin$c-car$inline)
            (sin-nth :logic strin-nth
                     :exec sin$c-nth$inline)
            (sin-firstn :logic strin-firstn
                        :exec sin$c-firstn)
            (sin-cdr :logic strin-cdr
                     :exec sin$c-cdr
                     :protect t)
            (sin-nthcdr :logic strin-nthcdr
                        :exec sin$c-nthcdr
                        :protect t)
            (sin-matches-p :logic strin-matches-p
                           :exec sin$c-matches-p)
            (sin-imatches-p :logic strin-imatches-p
                            :exec sin$c-imatches-p)
            (sin-count-charset :logic strin-count-charset
                               :exec sin$c-count-charset)
            (sin-find :logic strin-find
                      :exec sin$c-find)))

Subtopics

Strin-p
Logical representation of the current state of a string input stream.
Sin$c
Concrete string input stream ACL2::stobj.