iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 18
1

17: Parser Implementation (1)

2018/11/1

It's recommended to read on Gitbook

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.


Quick Link
1.StellarSQL Repository
2.Gitbook of this series

Author
Liu, An-Chi (劉安齊). A software engineer, who loves writing code and promoting CS to people. Welcome to follow me at Facebook Page. More information on Personal Site and Github.


上一篇
StellarSQL 16: Good RDB Design with the Concept of Normal Forms
下一篇
StellarSQL 18: Parser Implementation (2)
系列文
Let's build a DBMS: StellarSQL -- a minimal SQL DBMS written in Rust30

尚未有邦友留言

立即登入留言