Skip to content

Implementation of Earley's algorithm for context-free grammars

Notifications You must be signed in to change notification settings

JungleTryne/EarleyAlgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Earley parsing algorithm

With given context-free grammar the class is to accept or reject the given word.

How to use the class?

#include <iostream>
#include <Earley.h>

int main() {
    std::istream_iterator<std::string> input(std::cin);

    Grammar grammar = ParseGrammar(input); //gets input iterator in order to fetch the grammar
    Earley earleyHandler{std::move(grammar)}; //grammar handler using Earley algorithm 
    
    ...

    std::string word = "abacaba";
    bool accepted = earleyHandler.accept(word); // <-- here you see if the word accepted by the grammar

    return 0;
}

Description

The complexity of algorithm is O(n^4)

How to build

./build_and_install.sh && ./EarleyTest

About

Implementation of Earley's algorithm for context-free grammars

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published