171k views
0 votes
Syntax Analysis

In this assignment you will extend the work that you did in Assignment 1 on lexical analysis. You will now add a syntax analyser (parser) to it. The syntax analyser will handle expressions described by the EBNF given as an example in the section 4.4.1 of the textbook. The parser will be based on recursive-descent parsing algorithm and the outline C code for the parser is already given in the textbook. You will improve it by adding error handling capability.

First get the code for the recursive-descent parser described in the textbook working. Try it out on simple examples, e.g. (sum + 47) / total. This example should produce the trace given in section 4.4.1 (page 184-185 of 10th edition). To handle the error-handling you will have to implement the error() function. This function should report errors and also indicate what is expected by the parser in case a wrong token is found at the input.

Rubrics: Marks 10/10 if missing operator error, missing right bracket, missing left bracket is detected and reported.

1 Answer

0 votes

Final answer:

This question is about syntax analysis in computer programming, specifically implementing a recursive-descent parser with error handling capability.

Step-by-step explanation:

The subject of this question is syntax analysis in the context of computer programming.

Syntax analysis is the process of analyzing the structure of a program based on its grammar rules. In this assignment, the student is asked to extend their previous work on lexical analysis by adding a syntax analyzer or parser. The parser should be able to handle expressions described by the EBNF (Extended Backus-Naur Form) given as an example in the textbook.

The goal is to implement a recursive-descent parsing algorithm and enhance it with error handling capability. The error() function should report errors and indicate what is expected by the parser in case of a wrong token in the input. The student will earn full marks if they are able to detect and report missing operator error, missing right bracket, and missing left bracket.

User Alex Zielenski
by
7.9k points