Write a recursive descent recognizer pseudocode. The following is a set of requi
ID: 3722548 • Letter: W
Question
Write a recursive descent recognizer pseudocode.
The following is a set of requirements for this recognizer (parser):
- Ask the user for an input stream.
- Report "legal" or "errors found" (not both!).
- Assume the input stream is the token stream.
- Assume the input stream terminates with a $.
- Assume there is no white space.
- Use a form to collect input and return the output.
- Test your recognizer with illegal and legal strings.
- Give a brief description of this recognizer for the user on how to use and what method that it based on.
Explanation / Answer
Collect input stream
Pass token into the recogniser() function
}
define recogniser()
{
if token == "$"
Legal Stream
else
{
r=match(token)
if r==error
{
Illegal string
break
}
else
check_grammar(token)
}
}
define match (token t)
{
if token == t //t represents the expected value
advanceToken //advance token pointer
else
return error
}
construct functions for each non-terminal in your grammar. i.e. a function for each grammar rule
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.