17: Parser Implementation (1)

2018/11/1

I have done the lexical scanner. So, now I can get tokens from a message (SQL command).

The parser should do several things, including syntax checking, semantics checking and worker.

The syntax of a language is a set of rules that describes the words to make meaningful statements.

For example, a SQL query:

select from table t1

This is a wrong syntax. As you can see, there is no identifier in the middle of select and from. Also, table is not a keyword.

So, the correct one should be:

select user_id from table_t1

That's what syntax checking doing -- Find the wrong usage of SQL.

The semantics of a language specifies a statement to have an actual meaning.

For instance,

select user_id from table_t1

However, is user_id a field name? or is table_t1 the name of tables? Is the name ambiguous? Is the type of field correct?

The semantics should check for these things.

Finally, if everything okay? The parser will pass the result to worker, and the worker will execute the tasks to finish the command.

results matching ""

    No results matching ""