I am creating a textarea which have intellisense like most of the IDEs. My approach is to use earley parser algorithm.
I am using the early-parser-js library.
Below is the grammer:
S -> NP VP
VP -> VP PP | V NP | V
PP -> P NP
NP -> Det N | N | Pn | Det A N | A NP
A -> Adv A | A A
Adv -> too | very | quite
Pn -> she | he
A -> fresh | tasty | silver
N -> fish | fork | apple
V -> eats
Det -> a | an | the
P -> with
Now, If I write "she" in textarea, my code should suggest next possible node like "eats", "fish", "fork" etc.
I acheived this using the below code