tpt-telos-parser 0.2.0

Lexer, parser and AST for the tpt-telos language
Documentation
  • Coverage
  • 24.11%
    61 out of 253 items documented6 out of 56 items with examples
  • Size
  • Source code size: 106.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • tpt-solutions/tpt-telos
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PhillipC05

tpt-telos-parser

Lexer, parser, and AST for the tpt-telos language.

Part of the tpt-telos compiler workspace.

Overview

tpt-telos-parser is the first stage of the tpt-telos pipeline. It takes raw .telos source text and produces a typed AST (Vec<Module>) consumed by every downstream crate. The implementation is a hand-written lexer and recursive-descent parser with no external parser-generator dependencies. All AST node types are re-exported at the crate root for convenience.

The authoritative grammar lives at src/grammar.ebnf.

Usage

use tpt_telos_parser::parse;

let src = r#"
    module Wallet {
        func deposit(balance: int, amount: int) -> int
            requires amount > 0
            ensures  result == balance + amount
        { balance + amount }
    }
"#;

let modules = parse(src).expect("parse error");
println!("{} module(s) parsed", modules.len());

Key types

Type Description
Module Top-level unit; holds a name, attributes, invariants, and functions
Func Function definition with contracts (requires/ensures) and an optional body
Expr / Stmt Expression and statement nodes
Attribute @boundary(...) / @state(...) / @eject(...) metadata
ParseError Structured error with source location

License

Licensed under either of MIT or Apache-2.0 at your option.