90 likes | 287 Views
Symbol table handling in ScriptBasic. The Module sym. Who is this presentation for What is this module Data structures the module uses Services of the module How symbol/value pairs are stored Where is it used in ScriptBasic. Contents. Who this presentation is for.
E N D
Symbol table handling in ScriptBasic The Module sym
Who is this presentation for What is this module Data structures the module uses Services of the module How symbol/value pairs are stored Where is it used in ScriptBasic Contents
Who this presentation is for • Curious (why things happen?) • Want to learn and understand how ScriptBasic works • Want to modify ScriptBasic • Want to use the module outside ScriptBasic NOT for those, who just • want to program in scriba
What is this module? • Handles association of string and value • string is a ZCHAR terminated C string • value is (void *) pointer • Handles one or more symbol tables
Data structures typedef struct _symbol { char *name; void *value; struct _symbol *small_son, *big_son; } Symbol, *pSymbol, **SymbolTable;
Services of the module • Create new symbol table • memory allocation via function pointers • Lookup symbol • Traverse symbol table • Calls a callback function with symbol name, symbol value (pointer) and a (void *) pointer • Destroy symbol table • does not release the memory pointed by value pointers
How symbol/value pairs are stored • A symbol table is a hash of 211 elements • Hash function fromAho-Sethi-Ulman: Compilers Principles, techniques, and ToolsAddison-Wesley Publishing Company 1986 • Each hash element is a binary tree
Where is it used? • Syntax analysis • Global, local variables • Functions • Not used by the run-time system • Available for external modules