Questions tagged [recursive-descent]

Recursive Descent Parser is a kind of top-down parser built as a set of recursive procedures each implementing a production rule of the grammar.

Recursive descent parsers can be hand-written or generated. Examples of parser generators producing recursive descent parsers include ANTLR, Coco/R, and JavaCC.

207 questions
93
votes
1 answer

Difference between an LL and Recursive Descent parser?

I've recently being trying to teach myself how parsers (for languages/context-free grammars) work, and most of it seems to be making sense, except for one thing. I'm focusing my attention in particular on LL(k) grammars, for which the two main…
Noldorin
  • 144,213
  • 56
  • 264
  • 302
29
votes
9 answers

Rename files to lowercase in Powershell

I am trying to rename a bunch of files recursively using Powershell 2.0. The directory structure looks like this: Leaflets + HTML - File1 - File2 ... + HTMLICONS + IMAGES - Image1 - Image2 - File1 - File2 ... + RTF - File1 …
Ralph
  • 31,584
  • 38
  • 145
  • 282
22
votes
6 answers

How to do recursive descent of json using json.net?

I am trying to parse a json file using json.net. The file looks like this {X: { Title:"foo", xxxx:xxxx } } {Y: {ZZ: {Title: "bar",...} } } I am trying to recurse down this structure processing all objects with a…
pm100
  • 48,078
  • 23
  • 82
  • 145
18
votes
3 answers

Recursive descent parser implementation

I am looking to write some pseudo-code of a recursive descent parser. Now, I have no experience with this type of coding. I have read some examples online but they only work on grammar that uses mathematical expressions. Here is the grammar I am…
user1072706
  • 573
  • 2
  • 8
  • 20
18
votes
1 answer

Which grammars can be parsed using recursive descent without backtracking?

According to "Recursive descent parser" on Wikipedia, recursive descent without backtracking (a.k.a. predictive parsing) is only possible for LL(k) grammars. Elsewhere, I have read that the implementation of Lua uses such a parser. However, the…
user200783
  • 13,722
  • 12
  • 69
  • 135
17
votes
4 answers

Simple recursive descent in PyParsing

I've tried taking this code and converting it to something for a project I'm working on for programming language processing, but I'm running into an issue with a simplified version: op = oneOf( '+ - / *') lparen, rparen = Literal('('),…
Charlie
16
votes
1 answer

How do I parse basic arithmetic (eg "5+5") using a simple recursive descent parser in C++?

This has been on my mind for a while. I'm intrigued by recursive descent parsers, and would like to know how to implement one. What I want is a simple parser that will understand simple arithmetic such as "5+5", or "(5+5)*3". I figure the first step…
user377628
14
votes
2 answers

Converting EBNF to BNF

It's been a few years since my computer-language class and so I've forgotten the finer points of BNF's and EBNF's and I don't have a textbook next to me. Specifically, I've forgotten how to convert an EBNF into BNF. From what little I remember, I…
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
13
votes
1 answer

Expression parser grammar and left-associativity

I have been trying create my parser for expression with variables and simplify them to quadratic expression form. This is my parser grammar: Exercise : Expr '=' Expr Expr : Term [+-] Expr | Term Term : Factor [*/] Term | Factor Factor: Atom [^]…
12
votes
1 answer

boost::spirit composing grammars from grammars

I have figured out how to use spirit -- i.e., I have written a moderately complex grammar. I always take the approach of growing a program -- one subsystem at a time. I've written the data structures for a complex model which has 4 types at the…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
11
votes
2 answers

Resources for writing a recursive descent parser by hand

I'm looking to write a recursive descent parser by hand and I'm looking for good resources on how to structure it, algorithms, etc.
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
10
votes
5 answers

How do you write an arithmetic expression parser in JavaScript, without using eval or a constructor function?

Given a string: var str1 = "25*5+5*7"; Without using eval or the constructor function in JavaScript, how would I be able to write a function called "output" that takes in the string and outputs the arithmetic value of the string, which in this…
10
votes
2 answers

Recursively dir() a python object to find values of a certain type or with a certain value

I have a complex Python data structure (if it matters, it's a large music21 Score object) which will not pickle due to the presence of a weakref somewhere deep inside the object structure. I've debugged such problems with the stack trace and python…
9
votes
4 answers

Recursive descent parsing - from LL(1) up

The following simple "calculator expression" grammar (BNF) can be easily parsed with the a trivial recursive-descent parser, which is predictive LL(1): := + | - |
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
8
votes
2 answers

Haskell - Recursive descent parser

Can some one recommend a simple working example(code) of using recursive descent parser on haskell? All the information I found are too difficult to understand. Thx!
Ferry
  • 583
  • 8
  • 18
1
2 3
13 14