Parsing SQL
Parsing task is similar to that for programming languages.
Language elements:
- keywords:
create , select , from , where , ...
- identifiers:
Students , name , id , CourseCode , ...
- operators:
+ , - , = , < , > , AND , OR , NOT , IN , ...
- constants:
'abc' , 123 , 3.1 , '01-jan-1970' , ...
PostgreSQL parser ...
- implemented via lex/yacc (
src/backend/parser )
- maps all identifiers to lower-case (A-Z → a-z)
- needs to handle user-extendable operator set
- makes extensive use of catalog (
src/backend/catalog )
|