Questions tagged [earley-parser]

A type of parser that can parse all context-free languages, mainly used in computational linguistics.

26 questions
1
vote
1 answer

need some explanation in Earley algorithm

I would be very glad if someone can make clear for me example mentioned ono wikipedia: http://en.wikipedia.org/wiki/Earley_algorithm consider grammar: P → S # the start rule S → S + M | M M → M * T | T T → number and input: 2 + 3 * 4 Earley…
dfens
  • 5,413
  • 4
  • 35
  • 50
1
vote
1 answer

Earley cannot handle epsilon-states already contained in chart

I have implemented the Earley parser using a queue to process states. The queue is seeded with the top-level rule. For each state in the queue, one of the operations (prediction, scanning, completion) is performed by adding new states to the queue.…
Frithjof
  • 2,214
  • 1
  • 17
  • 38
1
vote
3 answers

Earley parser generator for Java

I'm looking for an Earley parser generator that is able to generate Java output code, i.e. that generates Java code for the lexer and parser, and allows to include actions (realised as Java code) that are performed for the grammar rules. I looked at…
Frank Grimm
  • 1,151
  • 7
  • 11
1
vote
1 answer

How to write a CFG with functions?

In an Assignment, I was asked to write a CFG for functions like: def f(x, y): return x + y def g(x, y): return x – y def h(x, y, z): return x + y % z def w(x, y, z): return x * y – z and def h1(x, y, z): return (x + y) % z def h2(x, y, z): return x…
1
vote
0 answers

PEP Java Parser empty terminal word on right sight

I am using a PEP java earley parser. And i have now a question about an empty rule (epsilon(ε)) on the right site: A -> ε | b | c | b A | c A How can I define such a rule in java like List right = new ArrayList(); right.add(new…
frankenstein
  • 161
  • 1
  • 13
1
vote
1 answer

simple CFG parser with epsilon transition

I have stumbled upon many different algorithms(CYK and Earley) to check whether or not a string is part of the CFL whose CFG is provided. I am looking for something simple to understand and implement. What I need to know is if the string is in the…
iordanis
  • 1,284
  • 2
  • 15
  • 28
1
vote
0 answers

Converting ambiguous to unambigous grammar for arithmetic expressions

I'm attempting to come up with a non-ambiguous grammar for arithmetic expressions to make an Earley parser faster but I seem to be having trouble. This is the given ambiguous grammar S -> E | S,S E -> E+E | E-E | E*E | (E) | -E | V V -> a | b |…
1
vote
1 answer

NLP - How would you parse highly noisy sentence (with Earley parser)

I need to parse a sentence. Now I have an implemented Earley parser and a grammar for it. And everything works just fine when a sentence has no misspellings. But the problem is a lot of sentences I have to deal with are highly noisy. I wonder if…
StuffHappens
  • 6,457
  • 13
  • 70
  • 95
0
votes
1 answer

Is there a simple example how Earley parser outperforms (or allows less verbose grammar than) LL(k) parser?

I've read that Earley is easier to use and that it can handle more cases than LL(k) (see https://www.wikiwand.com/en/Earley_parser): Earley parsers are appealing because they can parse all context-free languages, unlike LR parsers and LL parsers,…
egor10_4
  • 331
  • 2
  • 9
0
votes
0 answers

Parsing nested `if/else' statements

I am working on a JavaScript implementation of the OpenSCAD language, which -- for this purpose -- is a C-type language. I've been able to successfully parse all sorts of if and if/else statements: if(true) t1=200;t2=500; if(true)…
Jeremy J Starcher
  • 23,369
  • 6
  • 54
  • 74
-1
votes
4 answers

Writing manual parser

I need write a parser manually. Can`t choose between LL(*) and LR (maybe try Earley?). Should I use bottom-up parsing, because grammar for LL will be rather difficult?
mystdeim
  • 4,802
  • 11
  • 49
  • 77
1
2