Main Danish Module


Due to the linear nature of Danish, separating the code into modules defeats the purpose of modular design. The code does fall into three general categories of utility, though - initialization, file input, and code generation. The three sections communicate primarily by reading or writing the set of global arrays which store the relevent information necessary for testing the Java class.

If a function name is in green, then that function plays a Java-specific role.


Global Arrays

These arrays store the information necessary when processing the files and generating the tester code. As in Perl grammar, array names preceded by the @ symbol are standard list arrays, and those preceded by the % symbol are associative arrays, and are referred to by $array_name{key}.

@alii
list of alii
%isAlias
contains 1 if {key} is an alias
%aliasOf
contains replacement of alias {key}
@types
list of variable types recognized by the parser
%isType
contains 1 if {key} is a variable type
@vectors
list of test vectors
%isVector
contains 1 if {key} is a test vector
%vectorType
contains variable type of test vector {key}
%exParam
contains expression for test vector or axiom {key}
%vectorOnce
contains 1 if {key} is a 'resolve-once' test vector (see User Manual)
@funcs
list of function names recognized by the parser
%isFunc
contains 1 if {key} is a function name
%seFunc
contains 1 if function signature {key} is a member function (and must be called as such)
%funcType
contains return value type of function signature {key}
%funcSeParam
contains side-effect parameter of function signature {key}
%funcSigs
contains signature of function {key}
%printOf
contains print function of variable type {key}
@infix
list of infix functions (basic hard-coded functions, like == or +, etc.) recognized by the parser
@vars
list of variables recognized by the parser
%isVar
contains 1 if {key} is a variable
%varType
contains type of variable {key}
@axia
list of axia
%isAxiom
contains 1 if {key} is the name of an axiom

Initialization functions

These functions initialize the
global arrays and begin filling them with data that will be universal to all Java programs, such as the behavior of the boolean type.

initialise
Begin to initialize global state, setting arrays and useful global strings.
addTypes
Adds basic variable types int, boolean, char, and String to the lists of variable types, and adds some basic operators to the lists of functions.

Sets arrays @types, %isType, @alii, %isAlias, %aliasOf, %isFunc, @funcs, %seFunc, %funcType, %funcSeParam, %funcParams, @infix, %isInfix, $infixSearch

typeAdd
Add one specific type to the lists.

Takes new type name.

Sets arrays @types, %isType

constAdd
Add a typed constant by creating an alias.

Takes new constant name, constant type, value that that constant will take.

Sets arrays @funcs, %isFunc, %funcType, %seFunc, %funcSeParam, %funcSigs, @alii, %isAlias, %aliasOf

func1Add
Add unary function by creating an alias.

Takes new function name, function return type, alias that will replace any occurence of the function name, and parameter type.

Sets arrays @funcs, %isFunc, %funcType, %seFunc, %funcSeParam, %funcSigs, @alii, %isAlias, %aliasOf

aliasAdd
Add a new alias.

Takes the word that will be replaced, and the text string that will replace that word.

Sets arrays @alii, %isAlias, %aliasOf

fixIn
Add infix, or simple built-in functions for the axiom parser to recognize. These functions must be able to be recognized by Java itself, since the parser will not replace these functions.

Takes the return value type of the function, the variable type that the function can be used on (e.g. 'int' for '+'), and the function. Note that as many functions as necessary can be listed, separated by commas, and the wild card "*" can replace any type, if the function warrants it.

Sets arrays @infex, %funcType, %isInfix, %funcParam, %funcParams

processRCFile
Processes the resource file .danishrc. Note that this function is not as necessary in the web implementation, since the user interface calls Danish with command line options.

Desires file .danishrc to be present, but this is not necessary.

Sets arrays $outputFile, @javaFiles, @aliasFiles, @signatureFiles, @vectorFiles, @axiomFiles

processParameters
Processes command line options.

Requires @ARGV array exist.

Sets arrays $outputFile, @javaFiles, @aliasFiles, @signatureFiles, @vectorFiles, @axiomFiles


File Input and Decoding Functions

These functions read the input files and decode them, checking for errors. The information from the associated files is put into the
global arrays for use during code generation.

useFiles
Start using a new set of files, for example, axiom files, or signature files, etc.

Outputs list of files of that type.

getLine
Reads a new line from the current file list.
readAlii
Reads and parses alii.

Sets arrays %isAlias, %aliasOf, @alii

readSignatures
Reads and parses signatures.

Sets arrays %isType, @types, %isFunc, @funcs, %funcSigs, %funcType, %seFunc, %funcSeParam, %printOf

readVectors
Reads and parses test vectors.

Sets arrays %isVector, %vectorOnce, @vectors, %exParam

checkVectors
Checks all vector types for sanity.

Sets array %vectorType

vectorCheck
Checks one vector type sanity.

Takes a vector name.

Outputs a vector type.

Sets arrays %vectorType, %vectorInUse, %vectorDone

vectorParamCheck
Checks type sanity of parameters within test vector.

Takes a vector parameter location relative to operator (name.#, where # is 0, 1, or 2).

Outputs variable type at that parameter location.

readAxia
Reads and parses axia.

Sets arrays %isAxiom, @axia, $globAx, %exParam

checkAxia
Checks current axia for type, infix sanity.

Sets arrays @vars, %isVar, %varType

axiomCheck
Checks a specific axiom for sanity. Called recursively on shorter parts of axia, called sub-axia.

Takes axiom name, sub-axiom location, desired type to check for, ternary ':' acceptability.

Outputs type returned by sub-axiom

getEx
Reads an expression, either axiom or vector, recursively.

Takes type, which is "A" for axiom, and "V" for vector

Outputs location of root operation

Sets arrays $globAx, %exParam

matchSig
Returns a matching signature from a signature list with a signature

Takes signature list, signature being matched

Outputs signature, or "?" on fail

nextSymbol
Go to start of next symbol.

Outputs (not EOF)

pullIdentifier
Return an identifier symbol

Outputs identifier word or ""

pullSymbol
Return an identifier or constant symbol

Outputs identifier word or ""

pullType
Return a variable type symbol. Valid sequences are *, ident, {}, {*}, or {ident}, where ident represents a variable type symbol.

Outputs identifier word or ""

pullVectorName
Return a vector name. Valid sequences are ident or {ident}

Outputs name or ""

pullAlias
Return an alias definition (which will be replaced by another string). Valid sequences are to EOL

Outputs: alias or ""

pullInfix
Return an infix name. Valid sequences are ($infixSearch)+

Outputs name or ""

constType
Return the type of a constant

Takes the symbol for the constant

Outputs : constant type of symbol


Code Generation and Error Reporting

These functions take the data in the
global arrays and produce the java code which will be compiled and run with the java class being tested. These functions also handle the printing of information relevent to an error in one of the input files or, heaven forbid, the Danish program itself.

outputMain
Writes the main method to the Java class file, which calls each axiom-testing method and displays the results.
outputAxia
Writes the axiom-testing methods. Each axiom gets two methods - one which simulates the left and right sides of the axia and returns whether or not they are equal, and on which runs that method on each possible combination of test vectors, recording the number of passes, fails, aborts, and reneges.
outputDispensers
Writes the vector-dispenser methods, which, when asked for the nth vector of a certain type, returns that vector.

Sets arrays %typeVectors, %typeVector

outputVectors
Writes the methods that build up the test vectors.
openOutput
Open output Java file and begins writing the tester class
closeOutput
Finishes writing the tester class and closes the output file
evalEx
Returns variables, processing and result to evaluate an expression - works recursively. This function holds the majority of the Java-specific work

Takes sub-expression location, and (? set $DAv,$DAl,$DAr variable || ? = axiom name)

Outputs variables, init code, result, type, lrvars

deAlias
Un-alias an alias

Takes a word

Outputs the un-aliased version of that word if it is an alias.

simpleVar
Returns whether or not the parameter is a simple variable ($DAt\d+)

Takes an expression

Returns true or false.

reportAxia
Reports the current list of axia
reportVectors
Reports current list of vectors
reportSignatures
Reports current list of signatures
reportTypes
Reports current list of variable types
reportParameters
Reports parameters Danish was called with
reportAlii
Reports current list of alii
syntaxError
Reports a syntax error if Danish is called incorrectlty and exits
exitError
Report error and exit

Takes a string which is printed out.

fileDetails
Returns current file, line number, symbols, current object

Outputs $fileName . $fileLine . $_ . $currentObject

exReport
Returns an ASCII expression

Takes a location

Outputs a string

signatureOf
Returns a textual signature

Outputs text signature


Goto Previous Topic Goto Next Topic
Created 04/06/98 by Tim Preston
Revised 04/29/98