Sqlite Parser

The following files are generated automatically by the sqlite Makefile:

# Generated source code files
#
SRC += \
  keywordhash.h \
  opcodes.c \
  opcodes.h \
  parse.c \
  parse.h \
  shell.c \
  sqlite3.h

The parse.c and parse.h are derived from the parse.y, which is interpreted by the file /sqlite/tool/lemon.c. Their function is to interpret the input SQL and return computer readable sequence of simple instructions.

For example, a EXPLAIN xxx returns the following:

lemon.c uses lempar.c as a template, and fills it with the code generated from the dictionary file parse.y. The instructions to build it are disseminate in the Makefile, but basically consist of the following commands:

gcc -g -O2 -o ./lemon lemon.c
./lemon -c parse.y

The -c flag instructs the lemon parser not to compress the output files to improve human readability.

To use the above commands, the three generating files

  • /sqlite/tool/lemon.c
  • /sqlite/tool/lempar.c
  • /sqlite/src/parse.y

must be copied to the same directory, otherwise the file path should be appropriately stated.