Some languages rely on an engine to perform a useful service. In particular, logic languages and query languages need an engine in order to work. For example, Prolog is a leading logic programming language that needs an engine to prove its logical statements. SQL, or Structured Query Language, is a popular query language that also uses an engine to do the work that a query requests . A parser can parse a statement such as:
"select status from sales where city = 'Istanbul'"
However, a parser needs an engine to actually find the results. The engine is the part of the software in a database that decides which records fulfill the demands of a query.
Writing code to directly access an engine is usually complicated. It is safe to say that most people who use SQL never dream of accessing the engine directly from a programming language. In fact, many SQL users are unaware that the engine exists. If your only interaction with a database is through its query language, it might not occur to you to ponder the mechanics that allow the query language to function. A more realistic view of a database is that the database is the engine, and the engine comes with a language that provides a simple interface to the engine.
Engines and parsers are natural partners . Parsers provide a simple interface to an engine. The engine powers the language. This chapter introduces a logic engine used in the next three chapters. Chapter 13 introduces logic programming, giving examples in the Logikus programming language. Chapter 14 shows how to create a parser for Logikus. Chapter 15 shows how to create a query language using the engine from this chapter in place of a commercial database engine.