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
8
votes
2 answers

Recursive Descent vs. Generated Parsers - Efficiency

How do hand-written recursive descent parsers (which are inevitably LL(k)) compare to generated LALR parsers in terms of performance? I know that LALR parsers are able to handle far more grammars than LL(k); however it's my intention to write my…
ljs
  • 37,275
  • 36
  • 106
  • 124
8
votes
2 answers

Left recursion parsing

Description: While reading Compiler Design in C book I came across the following rules to describe a context-free grammar: a grammar that recognizes a list of one or more statements, each of which is an arithmetic expression followed by a…
8
votes
1 answer

Is it possible to use Recursive Descent Parser to both verify the grammar AND build the parse tree at the same time?

Is it possible to generate a parse tree at the same time as I use recursive descent parser to check if the data matches grammar? If so, what approach would I use to build a tree as I recursively descent? Thanks, Boda Cydo. Note: I am new to parsing.…
bodacydo
  • 75,521
  • 93
  • 229
  • 319
7
votes
2 answers

Recursive descent parser questions

I have two questions about how to write a recursive descent parser: The first is what when you have a nonterminal that can match one of a few different nonterminals? How do you check which way is correct? Second, how do you build an AST? Using YACC,…
mtk358
  • 565
  • 1
  • 7
  • 20
7
votes
1 answer

Recursive descent parser example for C

I'm trying to learn about parsing expressions.I found recursive descent parse seems easy to do this. From wikipedia,I found an example in C. So,I start reading and editing this code to understand how it works. I written the missing routines…
Jack
  • 16,276
  • 55
  • 159
  • 284
6
votes
1 answer

Difference between a PEG and recursive descent parser?

I have recently come across PEG parsers, and Guido van Rossum's article on PEG parsers and how to construct them. That article talks about "PEG" parsers but internally it looks exactly like a recursive descent parser (generator). I have a feeling…
Monolith
  • 1,067
  • 1
  • 13
  • 29
6
votes
3 answers

Recursive Descent Parser for EBNF in PHP

I am attempting to write a recursive descent parser in PHP for the following EBNF: EXP ::= < TERM > { ( + | - ) < TERM > } TERM ::= < FACTOR > { ( * | / ) < FACTOR > } FACTOR ::= ( < EXP > ) | < DIGIT > DIGIT ::= 0 | 1 | 2 | 3 I followed this guide…
Seephor
  • 1,692
  • 3
  • 28
  • 50
6
votes
1 answer

Calculate number of descendants recursively

I have a table with navigation that joins back on its self using ParentId. I am trying to calculate how many descendents each record has, I know that I need to increment a counter in the recursion, I'm just not sure how to go about it! Any help…
user147215
6
votes
4 answers

resolving logical operations - AND, OR, looping conditions dynamically

I have an incoming records filter stored with the logical clause as given below. Acct1 = 'Y' AND Acct2 = 'N' AND Acct3 = 'N' AND Acct4 = 'N' AND Acct5 = 'N' AND ((Acct6 = 'N' OR Acct7 = 'N' AND Acct1 = 'Y') AND Formatted= 'N' AND Acct9 = 'N' AND…
Atom
  • 768
  • 1
  • 15
  • 35
6
votes
2 answers

Parsing an expression grammar having function application with parser combinators (left-recursion)

As a simplified subproblem of a parser for a real language, I am trying to implement a parser for expressions of a fictional language which looks similar to standard imperative languages (like Python, JavaScript, and so). Its syntax features the…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
5
votes
1 answer

Why is my recursive descent parser right-associative

I'm writing my own programming language, and I have the tokenizer (lexer) all done. But for parsing, I'm having trouble writing a recursive descent parser. It seems to be right associative, when it should be left, and I don’t know why. For example,…
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
5
votes
1 answer

Recursive Descent Parser with Indentation and Backtracking

I have been trying to find an Recursive Descent Parser Algorithm that is also suited for indentation with backtracking. But I keep having myself finding troublesome solutions for this. Are there any resources out there that also deal with…
user896326
5
votes
2 answers

Syntax analysis and semantic analysis

I am wondering how the syntax analysis and semantic analysis work. I have finished the lexer and the grammar construction of my interpreter. Now I am going to implement a recursive descent (top down) parser for this grammar For example, I have the…
newbie
  • 14,582
  • 31
  • 104
  • 146
4
votes
1 answer

How to evaluate expressions in this tree?

Here is an example of a parsed xml file I'm working with that tabs it into a tree form commandList assign variable #text[a] expression-int #text[1] assign variable #text[b] expression-int #text[2] …
Chucky
  • 1,701
  • 7
  • 28
  • 62
4
votes
5 answers

How the Perl regular expressions dialect/implementation is called?

The engine for parsing strings which is called "regular expressions" in Perl is very different from what is known by the term "regular expressions" in books. So, my question is: is there some document describing the Perl's regexp implementation and…
lithuak
  • 6,028
  • 9
  • 42
  • 54
1
2
3
13 14