Skip to content

Lecture No. 10

Dated: 17-03-2025

Syntactic Analysis

The parser1 ensures that sentences of a programming language that make up a program abide by the syntax of the language. If there are errors, the parser will detect them and reports them accordingly. Consider the following code segment that contains a number of syntax errors:

int* foo(int i, int j)) {
    for ( k = 0; i j; )
        fi( i > j )
    return j;
}

It is clear that a scanner based upon regular expressions2 will not be able to detect syntax error.

References


  1. Read more about parser

  2. Read more about regular expressions