Game Development Reference
In-Depth Information
Figure 11.2 Kismet visual scripting system.
Implementing a Scripting Language
Although the full implementation of a scripting language is well beyond the scope
of this topic, it's worthwhile to at least discuss the main components necessary to
implement one. This is both to give a sense of how complex the problem is and to
at least provide some guidance on how to start off on the right track.
The basics of implementing a custom scripting language is very similar to that of
creating a general compiler; therefore, many of the topics covered in this section
can be studied in much further detail in a topic focused on compilers (such as
the one detailed in the references). Learning at least the basics of how a com-
piler works is important, even if you aren't going to implement one, because it's
what makes high-level programming possible. Without compiler theory, everyone
would still be writing code in assembly, which at the very least would mean there
would be far fewer qualified programmers.
Tokenization
The first step necessary to read in a language is to take the stream of text and break
it down into a series of tokens such as identifiers, keywords, operators, and sym-
bols. This process is known as tokenization , or more formally as lexical analysis .
Table 11.2 shows a simple C file broken down into its tokens.
Search WWH ::




Custom Search