13COMP CAT

formal languages

Level 3 CAT

13COMP & 13DTEC

Date: Wednesday 26th October  

Time: 1pm to 4pm

DURATION: 3hrs to complete 91908 (COMP) &/or 91909 (DTEC)

ROOM: Students will be allocated a room to go to sit the exam (not necessarily with their class)

What exactly is 'formal languages'?

From Canterbury Uni's The Computer Science Field Guide (CSFG):

If you've ever written a text-based program or typed a formula in a spreadsheet, chances are that at some stage the system has told you there's an error and won't even attempt to follow your instructions.

>>> x = (a+b) * c+d)

SyntaxError: invalid syntax

These "syntax errors" are annoying messages that programmers become excruciatingly familiar with... it means that they didn't follow the rules somehow, even if it's just a tiny mistake. For example, suppose you intended to write:

x = (a+b) * (c+d)

but you accidentally left out one of the brackets:

x = (a+b) * c+d)

When you try to compile or run the program, the computer will tell you that there's an error. If it's really helpful, it might even suggest where the error is, but it won't run the program until you fix it.

This might seem annoying, but in fact by enforcing precision and attention to detail it helps pinpoint mistakes before they become bugs in the program that go undetected until someone using it complains that it's not working correctly.