Parser-Driven Games Tool programming © Allan C. Milne Abertay University v12.7.11.
Click here to load reader
-
Upload
scott-bailey -
Category
Documents
-
view
216 -
download
1
Transcript of Parser-Driven Games Tool programming © Allan C. Milne Abertay University v12.7.11.
Parser-DrivenGames Tool programming
© Allan C. Milne
Abertay University
v12.7.11
Agenda.
• Motivation and Course Overview.• Translator Process Overview.
• Applications.• Some Terminology.
Motivation.
• Games are complicated compositions of many components and often a tool may assist either the development or implementation process.
• Tools may be useful in the areas of
– management, assisting the project development process by providing support functions against the code base;
– development, generating parts of the code base.
– implementation, being an integral part of the code base.
Motivation Continued.
• The tools you develop will often be analysing, processing or be under the control of a program/script written in some language.
• Therefore the tool is in some sense “driven” by the structure of the program; this structure being elucidated by a parser; hence the term parser-driven tools.
The Aim Of This Course Is To Provide You With …
… an overview of analysis and synthesis phases of the compilation process;
… an appreciation of appropriate parser-based tools for use within computer games software development projects;
… an introduction to the skills, terminology and techniques used to develop such tools.
The Development Environment.
• We will be using Flex and Bison;– These are versions of the Lex and Yacc
language processing packages respectively.
• These will be working in the C language.• We will be working in a command-line
environment;– Programs > Visual Studio > Visual Studio
Tools > Visual Studio Command Prompt
On Completion You Should Be Able To …
… explain the terms and terminology used to describe the construction and operation of compilers
… construct simple software translators
… identify opportunities for parser based tools within a development project
… specify and develop parser based tools
Translator Overview.
• A translator (or compiler) will process input text by treating it syntactically as a sentence from some language.
• It must also include semantic knowledge of the language in its processing.
• In processing the sentence a compiler must– Determine its syntactic structure,– check the semantic consistency, and– interpret or generate corresponding artifacts.
Translator Input.
• The primary input to a translator is the input text (source program).
• Formally this input text is a sentence from some language.
• The translator inputs the program as a stream of individual characters.
• Other user inputs may control the operation of the translator.
Translator Output.
• Intermediate or machine code.• A program in some other language.• An analytical report on the input text.• A data structure representing the input.• Direct actions.• … or some other artifact.
Translator Processing Phases.
Input text LexicalAnalysis
SyntaxAnalysis
SemanticAnalysis
SynthesisGenerated
artifact
Component Interactions.
characterstream
LexicalAnalysis
SyntaxAnalysis
SemanticAnalysis
Synthesis
Artifact(instruction
stream)
terminal tokens
syntax tree
symbol table
Error Handling.
• The translator must handle syntactic and semantic errors.
• Error detection: find invalid syntactic structures or misuse of semantics.
• Error reporting: report to the user the type, position and cause of the error.
• Error recovery: allow the translation process to continue after an error.
Application Areas.
• Management.– providing support functions against the
code base;
• Development.– generating parts of the code base.
• Implementation.– being an integral part of the code base.
Examples of Management Tools.
• Reporting code metrics.• Code transformations.• Integration of different code components.• Test data generation.• Identifying and controlling versioning.
Examples of Development Tools.
• Particle generators.• Generating graphics rendering pipelines.• Managing audio resources.• Generating graphics data files.• Scripting generic game engines.
Examples of Implementation Tools.
• Processing user conversations.• Dynamic scripting.• Configuration and property management.• Handling message protocols.• Game state storage and retrieval.
Some Translator Terminology.
• Translator;– Transforms structured input text into some
corresponding output artifact.
• Compiler;– Transforms an input source program into
object code for a real or virtual machine.
• Interpreter;– Transforms input source program into directly
executed actions.
Some Compiler Terminology.
• Source program = input text.• Object code = 1 type of generated artifact.• Scanner = lexical analyser = lexer.• Parser = syntax analyser = recogniser.
The Language.
• The tools we are looking at all require some input text that is a sentence (program) in some language.
• This language has both a syntax (structure) and semantics (context-sensitive meaning).
• The syntax of the language defines the structure of all possible programs that can be written in that language.