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
0
votes
1 answer

How to eliminate left recursion in context-free grammar?

How would I eliminate the left recursion in this CFG? -> '|' | -> | -> '*' | -> 'a' | 'b' | 'c' | 'd' | '('')'
0
votes
1 answer

Recursive descent parser C program

I have the following grammar and need to write a recursive descent parser in C E->E+E|E*E|(E)|i I used left-factoring to get the following grammar E->EX|Y X->+E|*E Y->(E)|i Now, I eliminated left recursion to get the following…
Sridhar
  • 59
  • 1
  • 2
  • 8
0
votes
1 answer

How do I get (A*B)>C string parsed by this grammar?

Issue is because of -- addExpression ((EQ | NE | GT | LT | LE | GE) addExpression)+ --- . By doing this I want to filter the math expressions from being alone unless followed by a relational to make it logical as a whole... I don't want my parser to…
-1
votes
1 answer

Recursive sub to determinate level of items in BOM

In the next sample structure BOM: updated screenshot we find articles, and further down we find their structure with its content, other articles which in their turn may or may not have their content and so on. I'm trying to create a recursive…
wiwi_99
  • 3
  • 3
-1
votes
1 answer

Parsing procedure calls for a toy language

I have a certain toy language that defines, amongst others, procedures and procedure calls, using EBNF syntax: program = procedure, {procedure} ; procedure = "procedure", NAME, bracedblock ; bracedBlock = "{" , statementlist , "}" ; statementlist =…
SRSR333
  • 187
  • 4
  • 15
-1
votes
1 answer

Accepting an Equal Sign using Recursive Descent Parsing in C

I am currently trying to build a recursive descent parser that parses assignment statements such as a = 4 + b. The grammar looks as follows → id = {(+ | -) } {(* | /) } → id |…
Ikechukwu Anude
  • 346
  • 1
  • 4
  • 16
-1
votes
1 answer

Ocaml: build list for Ast type in recursive function

I have a handwritten LL1 parser. My AST is not as simplified as it could be. The portion for statements looks like this: type stmt_opt = StmtExpression of assignment | OptNil [@@deriving show] (*stmt_list -> stmt stmt_list | ε *) type stmtlist = …
maddie
  • 1,854
  • 4
  • 30
  • 66
-1
votes
1 answer

Recursive descent parser implementation in python

The objective of the python code(3.5) is to read standard C codes for the following rules: Program --> main () { declarations statement-list } declarations--> data-type identifier-list; declarations |epsilon data-type --> int|char…
krishnair1123
  • 71
  • 1
  • 9
-2
votes
1 answer

K&R C Chapter 5 dcl issue

I've gotten to the end of chapter 5 of K&R C second edition, which is about pointers. I've done ok and understood everything so far, but for some reason I'm struggling to understand what exercise 5-18 is asking: "Make dcl recover from input…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
-2
votes
1 answer

recursive descend parser - avoiding left recursion

I have the following productions A -> Aa A -> b so it is clear that there is left recursion like parseA() { parseA();//recursion parsea(); } It is said that the left recursion can be avoided using the following rule A -> bA' A' ->…
Jinu Joseph Daniel
  • 5,864
  • 15
  • 60
  • 90
-3
votes
2 answers

Recursive Descent Parser LL(4) with example

I want to define a grammar that the language generated from the grammar needs LL(4) recursive descent parser. The grammar doesn't need to be complicated, as long as it satisfies the requirement? the if statement for the grammar can be as follows if…
AWA
  • 303
  • 1
  • 2
  • 11
-5
votes
1 answer

recursive descent parser in C code

I want to make recursive descent parser in C. Given conditions are here: -> -> [;stmts] -> | -> if '(' ')' ('{' '}' | ) -> {(+ | -) ->
Jay
  • 5
  • 3
1 2 3
13
14