Coder Social home page Coder Social logo

theblunt's Introduction

logo

A a one-file recursive descent parser combinator library for F# and Fable.

NuGet Badge

Some Facts and Infos:

  • It's just another recursive descent parser combinator library
  • Focus on parsing string documents
  • The original ranges that lead to a parse result are retained
  • For sure not made for everything, but may work well for small to medium stuff
  • Performance
    • Making use of Spans
    • Making use of InlineIfLambda
    • No benchmarks available (yet)
  • You can use the CE syntax for many parsers
  • No dependencies
  • State: Far from complete. It's a "works for me" implementation used in Trulla Templates
  • Examples

theblunt's People

Contributors

schlenkr avatar

Stargazers

Garrett van Wageningen avatar PY Rivaille avatar Masashi Fujita avatar Angel D. Munoz avatar Juan Pablo Tarquino avatar Rowan avatar BD avatar Dejan Milicic avatar Dexter Ajoku avatar Pasquale De Rose avatar Andreas Ågren avatar  avatar Daniel Blendea avatar

Watchers

 avatar

Forkers

pierreyvesr

theblunt's Issues

Last string not added by psepBy1

Hey there, I gave this library a spin and it is very cool!

I was wondering how to implement a psepBy that includes the string after the last separator.
You can see a gist of what I've done here which is a port of a FParsec version I have here

Given the following string "templates"

let tpl = "/segment1/segment2/segment3/"
let tpl2 = "segment1/segment2/segment3"

The gist gives me the following output

// [Plain "segment1"; Plain "segment2"; Plain "segment3"; Plain ""]
// [Plain "segment1"; Plain "segment2"; Plain ""]
// Press any key to continue . . . 

I'm currently using sepBy1 and I'm not sure if this is intended or is a limitation, I'd expect in the second template to also include the segment3 string in the end.

Is this something that can be done with psepBy1 or any other existing parser right now as I'm not very familiar with parsing stuff at all 😆

EDIT: A simpler example would be this

let separator = pstr "/"

match run "/segment1/segment2/segment3/" (psepBy1 separator (pstringUntil separator)) with
| POk { range = range; result = result } ->
    printfn "%A" (result |> List.map _.result)
    // [""; "segment1"; "segment2"; "segment3"]
| PError err -> eprintfn "%s" err.message

match run "/segment1/segment2/segment3" (psepBy1 separator (pstringUntil separator)) with
| POk { range = range; result = result } ->
    printfn "%A" (result |> List.map _.result)
    // [""; "segment1"; "segment2"]
| PError err -> eprintfn "%s" err.message

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.