• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • X86isa
      • Sha-2
      • Yul
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Axe
      • Poseidon
      • Where-do-i-place-my-book
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
              • Compilation
              • Static-semantics
              • Concrete-syntax
                • Pretty-printer
                • Grammar
                • Lexing-and-parsing
                  • Lexer
                  • Parser
                  • Token-fringe
                  • Longest-lexp
                  • Parser-interface
                    • Parse-from-file-at-path+
                    • Tokens-to-cst
                    • Parse-fragment-to-cst+
                    • Lexemes-to-cst+
                    • Parse-from-string+
                    • Parse-from-codepoints+
                    • Parse-fragment-to-cst
                    • Parse-from-bytes+
                    • Parse-from-string
                    • Parse-from-file-at-path
                    • Token-parses?
                      • Statement-parses?
                      • Expression-parses?
                      • File-parses?
                      • Token-parses-same-fringe?
                      • Expression-parses-same-fringe?
                      • Statement-parses-same-fringe?
                      • Parse-from-codepoints
                      • File-parses-same-fringe?
                      • Parse-from-bytes
                    • Grammar-lexp
                    • Identifier-lexp
                    • Output-file-parsep
                    • Input-file-parsep
                    • File-lex-parse-p
                    • Filter-tokens
                    • Lexp
                    • File-parsep
                    • Input-parser
                    • Output-file-lex-parse-p
                    • Input-file-lex-parse-p
                    • Parser-abstractor-interface
                    • Identifier-abnf-stringp
                    • Symbol-abnf-stringp
                    • Keyword-abnf-stringp
                    • Output-parser
                    • Tokenizer
                  • Input-pretty-printer
                  • Output-pretty-printer
                  • Unicode-characters
                  • Concrete-syntax-trees
                  • Symbols
                  • Keywords
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Parser-interface

    Token-parses?

    Checks if the given string can be parsed to a Leo token CST.

    Signature
    (token-parses? token-string) → yes/no
    Arguments
    token-string — Guard (stringp token-string).
    Returns
    yes/no — Type (booleanp yes/no).

    Checks that the given string is lexed, tokenized, and parsed successfully and checks that the CST from parsing has the root rule name token.

    Does not check that the lexemes have the same fringe as the given string. For that you want token-parses-same-fringe?.

    Definitions and Theorems

    Function: token-parses?

    (defun token-parses? (token-string)
     (declare (xargs :guard (stringp token-string)))
     (let ((__function__ 'token-parses?))
      (declare (ignorable __function__))
      (b*
       ((tree? (parse-fragment-to-cst "token" token-string))
        ((unless (abnf::treep tree?)) nil)
        (rulename (abnf::check-tree-nonleaf? tree?))
        ((unless (stringp rulename)) nil)
        ((unless
            (member-equal rulename
                          '("keyword" "identifier" "atomic-literal"
                                      "numeral" "annotation" "symbol")))
         nil))
       (abnf-tree-with-root-p tree? rulename))))

    Theorem: booleanp-of-token-parses?

    (defthm booleanp-of-token-parses?
      (b* ((yes/no (token-parses? token-string)))
        (booleanp yes/no))
      :rule-classes :rewrite)