Questions tagged [parser-generator]

A parser-generator is a tool that accepts a grammar description of a language (usually as an extended Backus-Naur Formalism (EBNF)), and generates computer code that will parse the language described by that grammar. Parser generators may produce recursive descent parsers, Earley parsers, L(AL)R parsers, or other more exotic parser types.

A parser-generator is a tool that accepts a grammar description of a language (usually as an extended Backus-Naur Formalism (EBNF)), and generates computer code that will parse the language described by that grammar. Parser generators may produce recursive descent parsers, Earley parsers, L(AL)R parsers, or other more exotic parser types. Often a parser generator produces code that interfaces well with a particular type of lexer generator, which is a type of parser generator that accepts regular expressions instead of EBNF, and is used to parse an input stream into tokens that are the abstract elements of the language processed by the EBNF.

326 questions
46
votes
7 answers

Extracting text data from PDF files

Is it possible to parse text data from PDF files in R? There does not appear to be a relevant package for such extraction, but has anyone attempted or seen this done in R? In Python there is PDFMiner, but I would like to keep this analysis all in R…
DrewConway
  • 5,407
  • 7
  • 35
  • 32
42
votes
5 answers

What are the disadvantages of the Spirit parser-generator framework from boost.org?

In several questions I've seen recommendations for the Spirit parser-generator framework from boost.org, but then in the comments there is grumbling from people using Spirit who are not happy. Will those people please stand forth and explain to the…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
38
votes
7 answers

What advantages do LL parsers have over LR parsers?

What advantages do LL parsers have over LR parsers to warrant their relative popularity in today's parser generator tools? According to Wikipedia, LR parsing appears to have advantages over LL: LR parsing can handle a larger range of languages than…
Adam Paynter
  • 46,244
  • 33
  • 149
  • 164
35
votes
4 answers

Can parser combinators be made efficient?

Around 6 years ago, I benchmarked my own parser combinators in OCaml and found that they were ~5× slower than the parser generators on offer at the time. I recently revisited this subject and benchmarked Haskell's Parsec vs a simple hand-rolled…
J D
  • 48,105
  • 13
  • 171
  • 274
30
votes
4 answers

Lex and Yacc in PHP

Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I…
Rik Heywood
  • 13,816
  • 9
  • 61
  • 81
28
votes
5 answers

What is the advantage of using a parser generator like happy as opposed to using parser combinators?

To learn how to write and parse a context-free grammar I want to choose a tool. For Haskell, there are two big options: Happy, which generates a parser from a grammar description and *Parsec, which allows you to directly code a parser in…
fuz
  • 88,405
  • 25
  • 200
  • 352
27
votes
6 answers

Scannerless Parser Generators

Prologue: Although the set of languages recognized by parsers (context-free grammars) is strictly larger than the one of scanners (regular grammars), most parser generators need a scanner. (Please don't try to explain the reasons behind it, I know…
Meinersbur
  • 7,881
  • 1
  • 27
  • 29
27
votes
2 answers

ANTLR4: Whitespace handling

I have seen many ANTLR grammars that use whitespace handling like this: WS: [ \n\t\r]+ -> skip; // or WS: [ \n\t\r]+ -> channel(HIDDEN); So the whitespaces are thrown away respectively send to the hidden channel. With a grammar like this: grammar…
flux
  • 275
  • 1
  • 3
  • 5
25
votes
4 answers

Scala Parsers: Availability, Differences and Combining?

My question is about the Scala Parsers: Which ones are available (in the Standard library and outside), what's the difference between them, do they share a common API and can different Parsers be combined to parse one input string? I found at…
soc
  • 27,983
  • 20
  • 111
  • 215
24
votes
4 answers

GLR parsing algorithm resources

I am writing a GLR parser generator and would like some advice on resources relating to this algorithm both on the internet and of the dead-tree variety (books for those unfamiliar with the geek-speak). I know Bison can generate GLR parsers, and…
ljs
  • 37,275
  • 36
  • 106
  • 124
24
votes
2 answers

How can we get the Syntax Tree of TypeScript?

Is there a process on getting a syntax tree of a compiler. We had been assigned on a project that needs to access typescript's syntax tree (which is opensource so we could see the whole compiler's code). But we don't know how to get it. I've been…
Daj
  • 241
  • 2
  • 3
24
votes
7 answers

What is a good C# compiler-compiler/parser generator?

I'm looking for a parser generator that given an EBNF for a LL(k) language will give me a C# parser and generate classes the types defined in the EBNF.
HasaniH
  • 8,232
  • 6
  • 41
  • 59
22
votes
3 answers

Choice of Parser Generator

OK, I understand this question may sound quite opinion-based, however since I have several specific criteria of choice, I think it would make a nice fit for SO. So, here I am... I've worked with compiler/interpreter construction in the past quite a…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
22
votes
2 answers

Advice on Python Parser Generators

I've been given a task where I have to create a parser for a simple C-like language. I can use any programming language and tools I wish to create the parser, but I'm learning Python at the same time so it would be my preferred choice. There are a…
greenie
  • 1,732
  • 4
  • 18
  • 33
21
votes
1 answer

Negating inside lexer- and parser rules

How can the negation meta-character, ~, be used in ANTLR's lexer- and parser rules?
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
1
2 3
21 22