All Projects → palle-k → Covfefe

palle-k / Covfefe

Licence: MIT License
A parser for nondeterministic context free languages

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Covfefe

language-grammars
Syntax highlighting for ABNF/BNF/EBNF, Yacc, and other language-related languages.
Stars: ✭ 14 (-71.43%)
Mutual labels:  ebnf, abnf, backus-naur-form
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (+128.57%)
Mutual labels:  parsing, parser-library, parser-framework
abnf parsec
ABNF in, parser out
Stars: ✭ 42 (-14.29%)
Mutual labels:  parsing, parser-generator, abnf
Participle
A parser library for Go
Stars: ✭ 2,302 (+4597.96%)
Mutual labels:  parser-library, ebnf, parser-framework
Lark
Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
Stars: ✭ 2,916 (+5851.02%)
Mutual labels:  parser-library, earley, cyk
Kgt
BNF wrangling and railroad diagrams
Stars: ✭ 312 (+536.73%)
Mutual labels:  parsing, parser-library, syntax-tree
Nearley
📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
Stars: ✭ 3,089 (+6204.08%)
Mutual labels:  parsing, earley-algorithm, earley-parser
YaccConstructor
Platform for parser generators and other grammarware research and development. GLL, RNGLR, graph parsing algorithms, and many others are included.
Stars: ✭ 36 (-26.53%)
Mutual labels:  parsing, parser-generator, ebnf
kiuatan
A parser library for Pony.
Stars: ✭ 15 (-69.39%)
Mutual labels:  parser-library, parser-generator
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (+342.86%)
Mutual labels:  parsing, syntax-tree
metal
A Java library for parsing binary data formats, using declarative descriptions.
Stars: ✭ 13 (-73.47%)
Mutual labels:  parsing, parser-library
nimly
Lexer Generator and Parser Generator as a Library in Nim.
Stars: ✭ 113 (+130.61%)
Mutual labels:  parser-generator, ebnf
dropincc.java
A small and easy to use parser generator. Specify your grammar in pure java and compile dynamically. Especially suitable for DSL creation in java.
Stars: ✭ 90 (+83.67%)
Mutual labels:  parser-generator, ebnf
Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (+4432.65%)
Mutual labels:  parsing, syntax-tree
RBNF
This project's lifetime has ended. The successor is https://github.com/thautwarm/frontend-for-free which is WIP. You can check lark-parser project which is a good alt.
Stars: ✭ 39 (-20.41%)
Mutual labels:  parser-generator, ebnf
GreynirPackage
The Greynir NLP parser for Icelandic, packaged for PyPI
Stars: ✭ 49 (+0%)
Mutual labels:  parsing, earley
pe
Fastest general-purpose parsing library for Python with a familiar API
Stars: ✭ 21 (-57.14%)
Mutual labels:  parsing, parser-generator
ebnf
EBNF parser and generic parser generator for Ruby.
Stars: ✭ 101 (+106.12%)
Mutual labels:  parser-generator, ebnf
Concrete-Syntax-Tree
Concrete Syntax Trees represent s-expressions with source information
Stars: ✭ 48 (-2.04%)
Mutual labels:  parsing, syntax-tree
copper
An integrated context-aware scanner and parser generator
Stars: ✭ 14 (-71.43%)
Mutual labels:  parsing, parser-generator

Covfefe

Build Status docs CocoaPods CocoaPods license

Covfefe is a parser framework for languages generated by any (deterministic or nondeterministic) context free grammar. It implements the Earley and CYK algorithm.

Usage

Swift Package Dependency in Xcode

  1. Go to "File" > "Swift Packages" > "Add Package Dependency..."
  2. Enter "https://github.com/palle-k/Covfefe.git" as the repository URL.
  3. Select "Version", "Up to next major", "0.6.1" < "1.0.0"
  4. Add Covfefe to your desired target.

Swift Package Manager

This framework can be imported as a Swift Package by adding it as a dependency to the Package.swift file:

.package(url: "https://github.com/palle-k/Covfefe.git", from: "0.6.1")

CocoaPods

Alternatively, it can be added as a dependency via CocoaPods (iOS, tvOS, watchOS and macOS).

target 'Your-App-Name' do
  use_frameworks!
  pod 'Covfefe', '~> 0.6.1'
end

Example

Grammars can be specified in a superset of EBNF or a superset of BNF, which adopts some features of EBNF (documented here). Alternatively, ABNF is supported.

let grammarString = """
expression       = binary-operation | brackets | unary-operation | number | variable;
brackets         = '(', expression, ')';
binary-operation = expression, binary-operator, expression;
binary-operator  = '+' | '-' | '*' | '/';
unary-operation  = unary-operator, expression;
unary-operator   = '+' | '-';
number           = {digit};
digit            = '0' ... '9';
variable         = {letter};
letter           = 'A' ... 'Z' | 'a' ... 'z';
""" 
let grammar = try Grammar(ebnf: grammarString, start: "expression")

This grammar describes simple mathematical expressions consisting of unary and binary operations and parentheses. A syntax tree can be generated, which describes how a given word was derived from the grammar above:

let parser = EarleyParser(grammar: grammar)

let syntaxTree = try parser.syntaxTree(for: "(a+b)*(-c)")

Example Syntax Tree

For a more complete example, i.e. how to evaluate syntax tree, check out ExpressionSolver.

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].