Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

algebraic-dev/parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parse.lean

It"s a protocol parser generator for Lean4 based on https://github.com/nodejs/llparse. It currently generates parsers in Lean and C. The Lean version is in most cases 2 times slower than the C version right now.

parser Http in Lean where
    def method : Nat
    def url : Nat × Nat

    node method where
        switch (store method beforeUrl)
            | "HEAD" => 0
            | "GET" => 1
            | "POST" => 2
            | "PUT" => 3
            | "DELETE" => 4
            | "OPTIONS" => 5
            | "CONNECT" => 6
            | "TRACE" => 7
            | "PATCH" => 8
        otherwise (error 0)

    node beforeUrl where
        is " " beforeUrl
        goto (start url url)

    node url where
        peek ' ' (end url http)
        otherwise url

    node http where
        is " HTTP/1.1\r\n\r\n" http
        otherwise (error 1)

About

🧩 | Parser generation for Lean 4.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages