• 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
  • Lexing-and-parsing

Parser-interface

API functions for parsing Leo programs.

This section defines convenient functions (whose names start with parse-from-) for parsing Leo programs from:

  • a list of Unicode code points
  • a list of UTF-8 bytes
  • an ACL2 string (in UTF-8)
  • a file

By "parsing", we mean lexing, tokenization, and parsing, with the result being a CST (concrete syntax tree) for a Leo file, and optionally the sequence of lexeme CSTs (see below).

Additionally, we define functions for parsing specific Leo constructs from strings: file, statement, expression, and token. These can be used for the <leo>/tests/parser namespaces Parse, ParseExpression, ParseStatement, and Token, where <leo> is the GitHub repo of the Leo compiler. See parse-fragment-to-CST. For simply checking if a given string can be fully parsed, we define predicates xxx-parses? for the same set of supported rulenames.

The API functions whose names end in + also return the full sequence of lexemes from the lexer. This can be valuable for checking correctness, for proving theorems, and for locating specific tokens within the input.

Subtopics

Parse-from-file-at-path+
Parse a Leo file at a path.
Tokens-to-cst
Parse list of tokens for a supported grammar rule name.
Parse-fragment-to-cst+
Parse source string for a supported grammar rule name.
Lexemes-to-cst+
Tokenize and parse list of lexemes for a supported grammar rule name.
Parse-from-string+
Parse UTF-8 ACL2 string into a CST.
Parse-from-codepoints+
Parse Unicode code points into a CST.
Parse-fragment-to-cst
Parse source string for a supported grammar rule name.
Parse-from-bytes+
Parse UTF-8 bytes into a CST.
Parse-from-string
Parse UTF-8 ACL2 string into a CST.
Parse-from-file-at-path
Parse a Leo file at a path.
Token-parses?
Checks if the given string can be parsed to a Leo token CST.
Statement-parses?
Checks if the given string can be parsed to a Leo statement CST.
Expression-parses?
Checks if the given string can be parsed to a Leo expression CST.
File-parses?
Checks if the given string can be parsed to a Leo file CST.
Token-parses-same-fringe?
Checks if the given string can be parsed to a Leo token CST.
Expression-parses-same-fringe?
Checks if the given string can be parsed to a Leo expression CST.
Statement-parses-same-fringe?
Checks if the given string can be parsed to a Leo statement CST.
Parse-from-codepoints
Parse Unicode code points into a CST.
File-parses-same-fringe?
Checks if the given string can be parsed to a Leo file CST.
Parse-from-bytes
Parse UTF-8 bytes into a CST.