• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • 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

    Parse-fragment-to-cst

    Parse source string for a supported grammar rule name.

    Signature
    (parse-fragment-to-cst rule-name source-code) → tree
    Arguments
    rule-name — Guard (stringp rule-name).
    source-code — Guard (stringp source-code).
    Returns
    tree — Type (abnf::tree-resultp tree).

    Supported grammar rule names are file, statement, expression, and token.

    If the given rule cannot be parsed or if there are tokens left over, then a reserr is returned.

    Since ACL2 strings are sequences of characters with codes from 0 to 255, source-code, when converted to codes, is required to be valid UTF-8.

    Definitions and Theorems

    Function: parse-fragment-to-cst

    (defun parse-fragment-to-cst (rule-name source-code)
      (declare (xargs :guard (and (stringp rule-name)
                                  (stringp source-code))))
      (let ((__function__ 'parse-fragment-to-cst))
        (declare (ignorable __function__))
        (b* (((mv cst ?lexemes)
              (parse-fragment-to-cst+ rule-name source-code)))
          cst)))

    Theorem: tree-resultp-of-parse-fragment-to-cst

    (defthm tree-resultp-of-parse-fragment-to-cst
      (b* ((tree (parse-fragment-to-cst rule-name source-code)))
        (abnf::tree-resultp tree))
      :rule-classes :rewrite)