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
0 answers

Assistance with a Recursive Descent Parser in Java

so as part of an assignment I need to implement a recursive descent parser for the following grammar; piece ::= {stmnt ; } [lststmnt ; ] block ::= piece stmnt ::= assignst | whilst | ifst | forst assignst ::= varlist = explst whilst ::= W expr D…
Craig
  • 9
  • 1
0
votes
3 answers

why recursive decent parser can not parse the aaaaaa EX(4.4.5) Ullman ravisethi

The grammar S -> a S a | a a generates all even-length strings of a's. We can devise a recursive-descent parser with backtrack for this grammar. If we choose to expand by production S -> aa first, then we shall only recognize the string aa. Thus,…
0
votes
1 answer

getting bedmas to work correctly

My code fails when I input something like 3(5). How do I modify my code so that it solves in expression in the middle and then multiplies? double parseTerm() { double x = parseFactor(); while(true) { if (shift('*')){ …
byzht
  • 11
  • 2
0
votes
1 answer

ANTLR 4 mismatched input on parsing

I'm on my first steps using ANTLR 4 with IntelliJ. I am trying to create a simple Recursive Climbing Parser for mathematical expressions. I get an error line 1:0 mismatched input '3' expecting {VARIABLE; REALNUM, INTNUM} It seems like the lexer…
lukas681
  • 33
  • 3
0
votes
1 answer

Polymorphic Abstract Syntax Tree (recursive descent parser): impossible?

I have begun writing a polymorphic recursive descent parser in C++. However I am running an issue. The classes are set up like this: class Node { public: std::vector children; }; class NodeBinary : public Node { public: Node* left; …
0
votes
3 answers

Python:How can you recursively search a .txt file, find matches and print results

I have been searching for an answer to this, but can not seem to get what I need. I would like a python script that reads my text file and starting from the top working its way through each line of the file and then prints out all the matches in…
Kali Berry
  • 11
  • 2
0
votes
1 answer

Producing Expressions from This Grammar with Recursive Descent

I've got a simple grammar. Actually, the grammar I'm using is more complex, but this is the smallest subset that illustrates my question. Expr ::= Value Suffix | "(" Expr ")" Suffix Suffix ::= "->" Expr | "<-" Expr | Expr …
Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
0
votes
2 answers

Parsing + and * in boolean expressions by recursive descent

I am writing a recursive descent parser for Boolean expressions, for example: (1 * 0) (0 + ~1) (0 * (1 + c) Where 1 is 'True', 0 is 'False', + is 'or', * is 'and', ~ is 'not' and 'c' is just some variable name (it could be any single alphabetic…
K810
  • 3
  • 2
0
votes
0 answers

Difference between nltk.parse.recursivedescent and nltk.parse.rd?

Would someone please explain the difference between the two Python modules nltk.parse.recursivedescent and nltk.parse.rd? It seems that the former is automatically included when I import NLTK into iPython, but I am interested in using one of the…
Steven Barkin
  • 99
  • 1
  • 2
  • 8
0
votes
2 answers

java complex logical conditions parser

I have a set of incoming records, that needs to be evaluated under a set of logical clauses defined and stored. An example logical clause be like : Acct1 != 'Y' AND Acct2 > 1004 AND Acct3 >= 96 AND Acct4 < 1004 AND Acct5 = 99 AND ((Acct6 <= 9090 OR…
Atom
  • 768
  • 1
  • 15
  • 35
0
votes
1 answer

Recursive Descent Parser in C - skipping over epsilon productions

Constructing a recursive descent parser to parse the following grammar. Is there a way i could return without passing anything back for all the epsilon productions(e)? (considering this approach I'm taking of parsing as shown in the code) E = TG …
mrdoubtful
  • 429
  • 2
  • 7
  • 17
0
votes
1 answer

Recursive Descent Parser - ClassCastException

I have a Recursive Descent Parser project, and I earlier posted a problem that I was having regarding stack overflow error. I have been able to fix that issue, however it is now returning a ClassCastException. From a main SWING GUI form, I pass…
0
votes
1 answer

Multiline comments in a recursive descent parser

I'm trying to wrap my head around how to handle C-style multiline comments (/* */) with a recursive descent parser. Because these comments can appear anywhere, how do you account for them? For example, suppose you're parsing a sentence into word…
0
votes
1 answer

Recursive descent parser first and follow

to implement a recursive descent parser is the first and follow sets required? and if so can you still build the recursive descent given non uniqueness in the first and follows? I'm having a hard time distinguishing between recursive descent and…
0
votes
2 answers

Descent recursive parser implementation in C++, based on EBNF Grammar

I have implemented descent recursive parser in C++ that is based on EBNF grammar and its pseudo-code. Here is the code: #include #include #include #include char s[100]; int pos=-1,len; void asignstmt(); void…
sana
  • 410
  • 2
  • 6
  • 24
1 2 3
13
14