All Projects → corsis → XParsec

corsis / XParsec

Licence: other
extensible, type-and-source-polymorphic, non-linear applicative parser combinator library for F# 3.0 and 4.0

Programming Languages

F#
602 projects

Projects that are alternatives of or similar to XParsec

Pasukon
JavaScript practical parser generator library using combinators
Stars: ✭ 107 (+167.5%)
Mutual labels:  parser-combinators
Swiftparsec
A parser combinator library written in the Swift programming language.
Stars: ✭ 192 (+380%)
Mutual labels:  parser-combinators
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (+180%)
Mutual labels:  parser-combinators
Parze
A clean, efficient parser combinator
Stars: ✭ 113 (+182.5%)
Mutual labels:  parser-combinators
Combine
A parser combinator library for Elixir projects
Stars: ✭ 174 (+335%)
Mutual labels:  parser-combinators
Urlformat
Type safe url pattern matching without regular expressions and arguments type mismatches based on parser combinators.
Stars: ✭ 213 (+432.5%)
Mutual labels:  parser-combinators
Parsec.el
A parser combinator library for Emacs Lisp, similar to Haskell's Parsec library.
Stars: ✭ 98 (+145%)
Mutual labels:  parser-combinators
slopShell
the only php webshell you need.
Stars: ✭ 208 (+420%)
Mutual labels:  extensible
Fireward
A concise and readable language for Firestore security rules, similar to Firebase Bolt.
Stars: ✭ 174 (+335%)
Mutual labels:  parser-combinators
Funcparserlib
Recursive descent parsing library for Python based on functional combinators
Stars: ✭ 250 (+525%)
Mutual labels:  parser-combinators
Parsec.py
A universal Python parser combinator library inspired by Parsec library of Haskell.
Stars: ✭ 143 (+257.5%)
Mutual labels:  parser-combinators
Parseback
A Scala implementation of parsing with derivatives
Stars: ✭ 168 (+320%)
Mutual labels:  parser-combinators
Baby
Create models from a JSON file, even a Baby can do it.
Stars: ✭ 214 (+435%)
Mutual labels:  parser-combinators
Cppcmb
A generic C++17 parser-combinator library with a natural grammar notation.
Stars: ✭ 108 (+170%)
Mutual labels:  parser-combinators
flyteidl
Specification of the IR for Flyte workflows and tasks. Also Interfaces for all backend services. https://docs.flyte.org/projects/flyteidl/en/stable/
Stars: ✭ 27 (-32.5%)
Mutual labels:  extensible
Opal
Self-contained monadic parser combinators for OCaml
Stars: ✭ 105 (+162.5%)
Mutual labels:  parser-combinators
Goparsec
Parser combinator in Go. If there are any cross platform issues or backward compatibility issues, please reach out.
Stars: ✭ 198 (+395%)
Mutual labels:  parser-combinators
venusscript
A dynamic, interpreted, scripting language written in Java.
Stars: ✭ 17 (-57.5%)
Mutual labels:  extensible
Entia
Entia is a free, open-source, data-oriented, highly performant, parallelizable and extensible Entity-Component-System (ECS) framework written in C# especially for game development.
Stars: ✭ 28 (-30%)
Mutual labels:  extensible
Parsica
Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
Stars: ✭ 223 (+457.5%)
Mutual labels:  parser-combinators
Version 2 of this library is being built as part of a larger fundraising project.
  • Rename primitives for clarity
  • Comprehensive documentation
  • Generalized parser negation -
  • Steps in uint64 instead of int (to be used with very large data sets)
  • XParsec.fs (primitives; operators; combinators)
  • XParsec.Array.fs [parse any 1D source]
  • XParsec.Xml.Linq.fs [parse System.Xml.Linq trees]
  • XParsec.Fable.Html.fs (click last link) [parse browser DOM trees]
  • XParsec + PDF.js (tech demo) [parse PDF pages, PDF documents] docpar

Version 1 examples below.

XParsec works with any type, is very easy to extend, supports domain-specific non-linear navigation and is implemented in a single F# file with just ~100 source lines of code.

(FParsec only works with Chars and can only go forward on a one dimensional String.)

Example 1

XParsec.Xml is the first XParsec extension. It is implemented in just 14 source lines of code for the examples used below and provides complete freedom in navigating XML trees.

open XParsec
open XParsec.Xml

[<EntryPoint>]
let main _ =

  let test parse = printfn "%A" << reply << parse << E.source

  let root = E.Parse "<root><a><b><c><d font='Arial'></d></c></b></a></root>"

  //            domain-specific
  //              navigation
  //                  v
  let parser1 = many (child => name) .>. !@"font"
  //            ^           ^
  //         powerful     first-class
  //      combinators     extensibility

  // graceful choices
  let parser2 = (parent => name) </> (!*child >. !@"font")

  // graceful non-linear look-ahead (here = down in Xml)
  let parser3 = !!parser1 .>. (current => name)

  // brand-new non-linear look-back (here = up   in Xml)
  let S d,_   = E.source root |> (!*child >. current)
  let parser4 = !!(many (parent => name)) .>. (current => name)

  test parser1 root; test parser2 root; test parser3 root; test parser4 d; 0
S (["a"; "b"; "c"; "d"], "Arial")
S "Arial"
S ((["a"; "b"; "c"; "d"], "Arial"), "root")
S (["c"; "b"; "a"; "root"], "d")

Example 2

Recursion – handled with ease.

open XParsec
open XParsec.Xml

type Xobj  = I of int | L of Xobj list

[<EntryPoint>]
let main _ =

  let root = E.Parse "<list><int v='1'/><list><int v='2'/></list><int v='3'/></list>"

  let e,e' = future ()

  let int_ = !<>"int"  >. !@"v"      => (Int32.Parse >> I)
  let list = !<>"list" >. children e =>                 L

  do  e'  := int_ </> list

  test e root; 0
S (L [I 1; L [I 2]; I 3])

Browse

License

XParsec™ © 2012 – 2018 Cetin Sert

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

    * The names of contributors may not be used to endorse or promote
      products derived from this software without specific prior
      written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contact

corsis

cssign

[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].