iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 14
3
Software Development

Let's build a DBMS: StellarSQL -- a minimal SQL DBMS written in Rust系列 第 14

StellarSQL 13: Recursive Descent Parser

13: Recursive Descent Parser

2018/10/28

It's recommended to read on Gitbook

I am confused in these days about how to implement the parser. PhD candidate Yushan Lin suggest me to see how VanillaDB implement, which is a DBMS developed by his lab.

There are many document about VanillaDB in its official website, including the parser one. It is worth and enlightening to read the parser slide, because it is professional but not complicated.

The most important part is that VanillaDB adopt recursive descent parser. You can check out more via google the keyword. I decide to use this method to implement grammar rule parser.

A recursive-descent parser has a method for each grammar rule, and calls these methods recursively to traverse the parse tree in prefix order.

In the end, let's update the status of the previous code. In order to lexically scan messages, I add another types in Group, which are Operator, Number, and Identifier.

pub enum Group {
    DataType,
    DoubleKeyword,
    MultiKeyword,
    Function,
    Keyword,
    Operator, // >, >=, ==, !=, <, <=
    Number,
    Identifier, // t1, a, b
}

So, Token is also updated.

pub enum Token {

    // ...

    /* Operator */
    LT, // <
    LE, // <=
    EQ, // ==
    NE, // !=
    GT, // >
    GE, // >=
}

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 12: Lexical Scanner Case Study
下一篇
StellarSQL 14: Lexical Scanner Implementation (4)
系列文
Let's build a DBMS: StellarSQL -- a minimal SQL DBMS written in Rust30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言