|
|
The Bartels User Language Compiler translates User Language source code into User Language machine programs and/or User Language libraries. User Language machine programs can be executed by the User Language Interpreter. User Language libraries usually are generated from frequently used source code. User Language library machine code can be linked to other User Language machine code (programs or libraries). Library linking can be done either statically (at compile time by the User Language Compiler) or dynamically (at runtime by the User Language Interpreter). As an advantage of the User Language library concept, frequently used source code needs to be compiled just once and can subsequently be referenced through linking, which is much faster than compiling. 3.2.1 Mode of OperationAt the compilation of User Language source code the User Language Compiler performs comprehensive syntactic and semantic consistency checks, removes redundancies from the program and/or library, and finally produces - in very compact form - a source code equivalent User Language machine code (User Language program and/or User Language library). The built-in linker of the Compiler performs static library linking and generates information for dynamic linking on request. This is applied with the subsequently described sequence of operations. Syntax Analysis and Semantic CheckThe first phase of the compilation process performs syntactic analysis. A parser pass is applied to handle formal problems, i.e., to check whether the sequence of words and symbols from the source code represents a syntactically valid User Language program and/or library. With this parser pass, semantic checks are performed in order to ensure consistency and uniqueness of the source's variable, parameter, and function definitions. As a result, this first parser pass (pass 1) generates an internal symbol table, which is required for the semantic test performed in the second parser pass (pass 2). The semantic test includes a context-sensitive analysis of the source code text to suppress the misuse of the defined program objects, i.e., the semantic test checks on the validity of the usage of names as well as the admissibility of the operations on the defined objects. Machine Code GenerationThe source code equivalent machine code is constructed already whilst running the semantic test, i.e., with the second parser pass (pass 2). The machine code generated by the Compiler corresponds with a valid machine program and/or library only if the semantic test was completed without errors. LinkerThe built-in linker of the Compiler performs static library linking and generates information for dynamic linking on request. The static link process (Compiler option -lib) binds machine code from required User Language libraries to the machine code currently to be translated. The requested libraries are checked for Compiler version compatibility. References to library machine code such as global function and/or variable addresses are resolved with consistency check. The dynamic link process (Compiler option -dll) only simulates machine code binding. As a result, dynamic link library relocation tables for resolving references to dynamic link libraries at runtime is stored with the machine code. The information provided with these relocation tables is later used by the User Language Interpreter to check library compatibility when performing dynamic link processes at runtime. Note that User Language library modifications require the recompilation of all User Language programs and/or libraries containing dynamic link requests to the changed library. OptimizerThe optimizer of the User Language Compiler can be activated using the Compiler option -O. The optimizer frees the machine code from redundancies and modifies the machine code in order make it more efficient. The optimizer recognizes and eliminates unused code segments as well as unreferenced function, variable, and parameter definitions. It changes variable references to constant accesses if possible (Constant Propagation), and it accomplishes algebraic optimizations. In most cases optimization considerably reduces machine code's memory and runtime requirements. The optimization introduces a very useful side effect: optimizer-modified machine code can be checked for special programming errors, which the Compiler otherwise would not have been able to recognize. Machine Code CheckAfter generating the machine code, the Compiler checks it again for fatal errors, which the Compiler eventually is able to recognize by analyzing the machine code. Such errors are division by zero, endless loop constructs and endless-recursive function calls. Listing File OutputThe User Language Compiler can be caused optionally to produce a listing file. The specifications in this file can be useful for locating errors occurred at runtime (i.e., with the program execution) only. The complete listing file content is composed of general program and/or library specifications (name, version, caller type), dynamic link request information, static link library reference listings, tables of the definitions (functions, variables, structures, etc.) used throughout the machine code, and the machine code listing (i.e., the list of the machine instructions including source text and machine code line number specifications). The listing option -l of the User Language Compiler supports different modes for making the output more or less verbose. With this option, it is possible to, e.g., restrict output for User Language library documentation purposes (library function reference). The
-ld option allows for the specification of an alternative output directory for the listing files created with the
-l option. This option is useful when applying
Machine Code StorageWith the final phase of the compilation process the machine code generated by the
User Language Compiler is stored to the
Special
User Language Compiler options allow for the deletion of
User Language programs (option
-dp) and/or libraries (option
-dl) stored to
3.2.2 Compiler CallThe translation of an User Language program and/or an User Language library is started with the User Language Compiler call. SynopsisThe User Language Compiler must be called from the operating system shell. The synopsis for calling the Compiler is: ulc [-wcon|-wcoff] [[-S[ource]] srcfile...] [-lib libname...] [-dll libname...] [{-cp|-cl} [dstname...]] [-I[nclude] includepath...] [-D[efine] macroid...] [-O[0|1]] [-e[0|1]] [-w[0|1|2|3|4]] [-t[0|1]] [-l[0|1|2|3|4|5]] [-ld listingdirectory] [-dp prgname...] [-dl libname...] [-ulp prgfilename] [-ull libfilename] [-log logfilename] On syntactically wrong Compiler calls, the correct ULC command syntax is displayed, and the compilation process is aborted. OptionsCommand line options of the
User Language Compiler consist of the dash
( Wildcard Option [-wcon|-wcoff]
Source File Option [[-S[ource]] srcfile...]
Static Link Option [-lib libname...]
Dynamic Link Option [-dll libname...]
Create Program/Library Option [{-cp|-cl} [dstname...]]
Include Path Option [-I[nclude] includepath...]
Define Option [-D[efine] macroid...]
Optimizer Option [-O[0|1]]
Error Severity Option [-e[0|1]]
Warning Severity Option [-w[0|1|2|3|4]]
Top Level Warnings Only Option [-t[0|1]]
Listing Option [-l[0|1|2|3|4|5]]
Listing Directory Option [-ld listingdirectory]
Delete Program Option [-dp prgname...]
Delete Library Option [-dl libname...]
Program Database File Name Option [-ulp prgfilename]
Library Database File Name Option [-ull libfilename]
Log File Option [-log logfilename]
ExamplesCompilation of the User Language program contained in
ulc ulprog -Ow Compilation of the User Language program contained in
ulc ulprog -l -cp newprog Deleting the User Language programs named
ulc -dp ulprog newprog -dl test*lib Generate User Language library
ulc libbae.ulh -cl libsll -l2O Compile all current directory files with extension
ulc *.ulc -Define USELIB -lib libsll -O Generate libraries
ulc -w2 -O -cl libstd stdlib -Source std.ulh Generate library
ulc /wO -cl liblay -S \baeulc\lay.ulh -dll libstd -log genlib.rep Generate programs
ulc laypcr.old /dll liblay /cp -O /S tracerep 3.2.3 Error HandlingOne of the most important Compiler features is the error handling. This is due to the fact, that source codes, which contain errors and/or redundancies are most frequently processed (a correct, redundancy-free program is usually only compiled once). The error and warning messages issued by the Compiler are intended to support the programmer in developing error-free User Language programs and/or libraries without redundancies as quickly as possible. The
User Language Compiler prints all messages to the screen and to a log file. Log file output is generated to save long message lists which could be generated at the compilation of different sources. On default, the log file name is set to
This section lists all error and warning messages defined with the User Language Compiler. At the appearance of errors no valid machine code can be produced. Warnings indicate the generation of valid machine code, which, however, might show up with unpredictable side effects at runtime. With each message a line number is included wherever possible to localize the corresponding error. This line number specification refers either to the source code file (denoted by "Ll") or to the machine code (denoted by "Lp"). The warnings messages listed below are preceded with a number enclosed in square brackets. These are not part of the actually printed warnings, but denote the minimum warning severity level to be set with the -w option to prompt the User Language Compiler to issue the corresponding warnings. Warnings assigned to severity level 0 are always printed, regardless of the selected warning severity level. General MessagesOn syntactically wrong Compiler calls, the correct ULC command syntax is displayed, and the compilation process is aborted. The following general Compiler messages denote current Compiler actions and/or issue resumes on the compilation process: Deleting programs from "n"... Program 'n' deleted. Deleting libraries from "n"... Library 'n' deleted. Loading/linking libraries... Compiling source code file "n"... Program 'n' successfully created. Library 'n' successfully created. Source code file "n" successfully compiled. e errors, w warnings. User Language Compiler aborted! User Language Compilation successfully done. The following Compiler messages indicate general errors regarding the Compiler call, such as missing Compiler runtime authorization, invalid file and/or element name specifications, file access problems or link library access problems: ERROR : Please check your User Authorization! ERROR : File name "n" is too long! ERROR : File name "n" contains invalid chars! ERROR : Element name 'n' is too long! ERROR : Element name 'n' contains invalid chars! ERROR : Error writing listing file "n"! ERROR : Error creating ULC log file "n"! ERROR : Too many source code files specified! ERROR : Source code file "n" not found! ERROR : Library 'n' not found! ERROR : User Language Library 'n' Version not compatible! The following messages indicate general problems accessing specified directories and/or program or library elements or notify of link library inconveniences: [0] WARNING : Directory 'n' not found/not available! [0] WARNING : Program 'n' not found! [0] WARNING : Library 'n' not found! [0] WARNING : Library 'n' is not optimized! Fatal ErrorsThe following internal compiler messages either indicate memory management errors or refer to Compiler implementation gaps: (Ll) ERROR : List overflow! (Ll) ERROR : Out of memory! (Ll) ERROR : INTERNAL ERROR IN function -- PLEASE REPORT! Parser ErrorsThe following messages indicate source code file access and/or syntax errors: (Ll) ERROR : Cannot open source file "n"! (Ll) ERROR : Cannot read source file "n"! (Ll) ERROR : Source file expression too complex ('s')! (Ll) ERROR : Source file element too long ('s')! (Ll) ERROR : Syntax error at 'string' (unexpected symbol)! (Ll) ERROR : Unspecified syntax analyzer error! Semantic Errors and WarningsThe following errors can be issued whilst performing semantic source code analysis: (Ll) ERROR : Identifier 'n' is too long! (Ll) ERROR : Character 's' is too long / no character! (Ll) ERROR : String "s" is too long! (Ll) ERROR : Numeric value 's' is too long! (Ll) ERROR : Invalid numeric value 's'! (Ll) ERROR : Type 'n' not defined! (Ll) ERROR : Multiple definition of type 'n'! (Ll) ERROR : Function 'n' not defined! (Ll) ERROR : Multiple definition of function 'n'! (Ll) ERROR : Function 'n' is a system function! (Ll) ERROR : Function parameter 'n' not defined! (Ll) ERROR : Multiple definition of function parameter 'n'! (Ll) ERROR : Multiple declaration of function parameter 'n'! (Ll) ERROR : Variable 'n' not defined! (Ll) ERROR : Multiple definition of variable 'n'! (Ll) ERROR : Assignment to constant or result value is attempted! (Ll) ERROR : Not an array; cannot perform index access! (Ll) ERROR : Invalid array index specified! (Ll) ERROR : Array subscript out of range! (Ll) ERROR : Access to member ('n') of unknown struct! (Ll) ERROR : Structure 'n' unknown/invalid! (Ll) ERROR : Multiple definition of structure 'n'! (Ll) ERROR : Structure member 'n' unknown/invalid! (Ll) ERROR : Multiple definition of structure member 'n'! (Ll) ERROR : Index 'n' unknown/invalid! (Ll) ERROR : Index variable 'n' unknown/invalid! (Ll) ERROR : 'n' is not an index variable! (Ll) ERROR : 'forall'-index not defined for 'of'-index 'n'! (Ll) ERROR : 'continue' not within a loop! (Ll) ERROR : 'break' not within a loop or 'switch'! (Ll) ERROR : 'void' function 'n' cannot return a value! (Ll) ERROR : Function 'n' must 'return' a valid value! (Ll) ERROR : 'return' expr. not type-compat. to function 'n'! (Ll) ERROR : Expression not type-compatible to parameter 'n'! (Ll) ERROR : Expression not type-compatible to variable 'n'! (Ll) ERROR : Operand not type-compatible to the 'n'-operator! (Ll) ERROR : Operands not type-compatible to the 'n'-operator! (Ll) ERROR : Invalid assignment to active loop index variable! (Ll) ERROR : Invalid 'n'-expression! (Ll) ERROR : Unknown/undefined function 'n'! (Ll) ERROR : Function 'n' - not enough parameters specified! (Ll) ERROR : Function 'n' - parameter not compatible! (Ll) ERROR : Function 'n' - parameter out of range! (Ll) ERROR : Invalid '#if-#else-#endif' construct! (Ll) ERROR : Identifier 'n' is defined as macro! (Ll) ERROR : Access to void macro 'n'! (Ll) ERROR : Cannot store BNF to UL library! (Ll) ERROR : BNF redefined! (Ll) ERROR : BNF symbol 'n' unknown/undefined! (Ll) ERROR : BNF production 'n' double defined! (Ll) ERROR : BNF reduce/reduce conflict at production 'n'! (Ll) ERROR : BNF terminal symbol 'n' is invalid! (Ll) ERROR : BNF comment delimiter 's' is invalid! (Ll) ERROR : BNF function 'n' not of type 'int'! (Ll) ERROR : Division by zero is attempted! (Ll) ERROR : Endless loop! (Ll) ERROR : Function 'n' - recursive call! (Lp) ERROR : Stack overflow! ERROR : End of file reached where '}' has been expected! ERROR : Incompatible index/function reference(s)! The following warnings can be issued whilst performing semantic source code analysis: [1] (Ll) WARNING : BNF contains no valid productions! [2] (Ll) WARNING : Function 'n' - default return value used! [1] (Ll) WARNING : Function 'n' - too many parameters specified! [2] (Ll) WARNING : Function 'n' - change of parameter n will be ignored! [2] (Ll) WARNING : Function 'n' - change of parameter 'n' will be ignored! [2] (Ll) WARNING : Constant 'n'-expression! [2] (Ll) WARNING : Expression has no side-effects! [2] (Ll) WARNING : Function 'n', local variable 'n' hides global variable! [2] (Ll) WARNING : Function 'n', parameter 'n' hides global variable! [4] (Ll) WARNING : Variable 'n' has not been initialized! [4] (Ll) WARNING : Macro 'n' redefined! Optimizer WarningsThe following warnings are issued by the optimizer and indicate source code redundancies: [1] (Ll) WARNING : BNF is not referenced! [2] (Ll) WARNING : Global variable 'n' not referenced! [2] (Ll) WARNING : Function 'n' not referenced! [2] (Ll) WARNING : Statement is not reached! [3] (Ll) WARNING : Function 'n', Local variable 'n' not referenced! [3] (Ll) WARNING : Function 'n', Parameter 'n' not referenced! [4] WARNING : Library function 'n' not referenced! [4] WARNING : Library variable 'n' not referenced! [4] WARNING : Dynamic Link Library 'n' is not referenced! Database Access ErrorsThe following messages indicate errors on the storage of the machine program: ERROR : Cannot create database file "n"! ERROR : Read/write error whilst accessing file "n"! ERROR : Too many open files! ERROR : File "n" is not a database/DDB file! ERROR : File structure is damaged in file "n"! ERROR : File structure is erroneous in file "n"! ERROR : Function not available for old format! ERROR : Database limit exceeded! ERROR : File "n" is not compatible with program version! ERROR : Element 'n' not found! ERROR : Element 'n' exists already! ERROR : File "n" not found! ERROR : Record end reached! ERROR : Unspecified database error!
Compiler |
|