[fpc-pascal] compiler / language // ----- sending error

spir denis.spir at gmail.com
Fri Jun 4 10:15:01 CEST 2010


*** Sorry, I sent this post to the wrong list. Hope you find it interesting anyway ...


Hello,


I just discovered a set of wiki pages about freepascal's compiler: http://wiki.lazarus.freepascal.org/FPC_internals. On can find at http://wiki.lazarus.freepascal.org/Symbol_tables the following table (a bit refactored here).


The Symbol table object

All symbol tables in the compiler are this type of object, which contains fields for the total size of the data in the symbol table, and methods to read and write the symbol table into a stream. The start of the linked list of active symbol tables is the symtablestack variable.
[...]
The type of possible symbol tables are shown in the following table:
Field 	                Description
-----                   -----------
abstractSymTable 	    (Default value for debugging purposes)
WithSymTable 	        All symbols accessed in a with statement
StaticSymTable 	        Contains unit implementation or program symbols
GlobalSymTable   	    Contains unit interface symbols
ObjectSymTable   	    Contains all symbols within an object/class...
RecordSymTable   	    Contains all symbols within a record statement
LocalSymTable   	    Hold symbols for all local variables of a routine
ParaSymTable    	    Holds symbols for all actual parameters of a routine
Stt_ExceptSymTable   	Contains all exception symbols defined in an except block
exportedMacroSymTable 	Holds all exported macros
localMacroSymTable 	    Holds all macros currently in scope
enumSymTable     	    Contains all enumeration elements symbols of an enumeration 


Well, this is a rather good presentation of claro! (my own project). Not of its compiler's guts, but of the language structure itself: everything is a symbol table (a "unit" in claro slang). Units are the kind of object/flexible record I discussed a data structure for, in a previous thread.
Scopes (including the global "world"), ordinary values (including things=references), their types, methods, formal and actual parameter sets, code elements (meta-level)... really everything is a symbol table.

[Note: I thought I was the only one in programming using "symbol" in the (for me proper) meaning of an association between a form & a sense, more precisely here a name:value link. See eg Lisp or Ruby where "symbol" means a name or id, just a special kind of string.]

Replacing Lisp's lists by symbol tables, one gets a pretty good idea of claro's guts. This is slightly more complex, also more expressive imo. (But I need plain sequences anyway, so Lisp is indeed more raw, as I won't represent sequences as symbol tables which symbols are ordinals!)


Denis
________________________________

vit esse estrany ☣

spir.wikidot.com



More information about the fpc-pascal mailing list