The syntax analyser takes the query from the users, parses it into tokens and analyses the tokens and their order to make sure they comply with the rules of the language grammar. If an error is found in the query submitted by the user, it is rejected and an error code together with an explanation of why the query was rejected is returned to the user.
A simple form of language grammar that could be used to implement a SQL statement is given below:
|QUERY:||= SELECT_CLAUSE + FROM_CLAUSE + WHERE_CLAUSE|
|SELECT_CLAUSE:||= ‘SELECT’ + <COLUMN_LIST>|
|FROM_CLAUSE :||= ‘FROM’ + <TABLE_LIST>|
|WHERE_CLAUSE :||= ‘WHERE’ + VALUE1 OP VALUE2|
|VALUE1:||= VALUE / COLUMN_NAME|
|VALUE2:||= VALUE / COLUMN_NAME|
|OP:||= +, -, /, * =|
The above grammar can be used to implement ...