P. Maurer's Website, DGL, FHDL, Education, Research |
|||||||||||||||
|
The DGL ActiveX ControlInstallationTo install the DGL ActiveX control on your system, you need to respond with OK when your browser asks you if its OK to install. If you gave the wrong answer, refresh the page and reply OK this time. If you have fire-wall problems, click here to download a zip file with an installer. Unzip file to a directory and run "setup.exe". Depending on your zip settings, a new directory might be created while unzipping. The installer was created using VS.NET under Windows XP, but should work on Win98 and above. I don't have a Win95 to test. On Win98, the installer keeps asking you to close "applications" that are really just folder displays. Don't be intimidated by this, just keep clicking "Continue." To test the installation, (automatic or manual) select the following line, and paste it into the first text box. Then click on the "Generate" button. You should see 10 5-digit binary numbers in the second text box. main: %10{bn}; bn: %{fived}\r\n; fived: %5d; d: 0,1; See below for properties, methods, and events.
Procedures for useNote that the DGL ActiveX control is at a somewhat lower level than the UNIX version of DGL. Some things, like saving states, that were automatic in the UNIX version, must now be done explicitly. This is because the DGL ActiveX control is a component, not a finished program like the UNIX version. You must use this component to create your own programs. The ActiveX version of DGL is actually enormously more powerful than the UNIX version of DGL, but with increased power comes a bit more work. The data-generation work of the DGL ActiveX control is actually performed by the CGrammar class, its aggregates, and their derived classes. The class structure will be made freely available once the documentation is complete. (Who knows when that will be? This is a labor of love, not anything that I get paid for!) Suppose you have added a control called DGL1 to your Visual Basic project. Let's parse a grammar, save and restore production states, and generate three random strings. The following code is used for this purpose. (I'm specifying function calls in .NET style.) DGL1.ParseFile("MyGrammar.dgl")
PropertiesThese properties are all properties of the current grammar. Changing the grammar will change these properties as well. All properties are run time only. long GrammarHandle - Pointer to the current CGrammar object, cast to a long. Read Only. String FlagCharacter - The flag character of the current grammar. % is the default character String StartSymbol - The start symbol of the current grammar. "main" is the default. String StateFileName - The state file where the grammar state is saved. There is no default. short Seed1 - Random number seed, part 1, 16-bit integer. Used by drand48 standard C function short Seed2 - Random number seed, part 2, 16-bit integer. short Seed3 - Random number seed, part 3, 16-bit integer. long RepetitionCount - The repetition count of the current grammar. In this version of DGL, the repetition count is the number of times that the start symbol is interpreted each time the Select method is called. This repetition count is used only if the argument of the select method is zero. Boolean SaveSeed - Indicates whether the random number seed is saved after each invocation of the grammar. long ProductionCount - number of productions in the grammar. Read Only. String GrammarName - Name of the current grammar, the NULL string is the default. Boolean IgnoreTimeStamp - Use the seed file even if the hash code is wrong. long Hash1 - first 32-bits of the hash code long Hash2 - second 32-bits of the hash code
MethodsStandard Data Generationlong ParseString(String Value,String FileName)
long ParseFile(String FileName)
String Select(long RepetitionCount)
long SaveState(void)
long RestoreState(void)
Production Manipulationlong Reset(void)
long ResetProduction(String ProductionName)
long SetProbability(String ProductionName, long TableIndex, long ProbabilityValue)
void AddString(String NewString)
long SaveProduction(long ProductionIndex)
Macro ProcessingA DGL grammar can be used as a set of recursive macros. The following methods facilitate this usage. String InterpretString(String InputString)
long InterpretFile(String InputFileName,String OutputFileName)
long InterpretHeader(String FileName)
Remote Grammar HandlingRemote Grammar handling is done using the following functions, and the property GrammarHandle. To obtain a pointer to the CGrammar object representing the current grammar, access the value of GrammarHandle. Use the SetGrammar method to pass a grammar (by pointer) to a component. When passing a grammar from one component to another, use the ReleaseGrammar method to make the first component "forget" about the grammar. The method DestroyHandle is used to destroy a grammar handle that no longer belongs to any component, due to the use of the ReleaseGrammar method. Note that using the SetGrammar method will cause the new component to "own" the grammar. One must not call the DestroyHandle method on a grammar handle for a grammar that is owned by a component. One should be careful not to end up with two or more components owing the same grammar, because this will cause the grammar to be double-deleted when the program terminates. (This usually causes program failure.) The DestroyCurrentGrammar method causes the component to destroy its current internal grammar. DestroyCurrentGrammar is essentially the same as the NewGrammar method described in the next section. long DestroyHandle(long GrammarPointer) void DestroyCurrentGrammar(void) void ReleaseGrammar(void) void SetGrammar(long GrammarPointer) Creating Grammars DynamicallyDGL Grammars can be created dynamically, one production at a time. The first step in doing this is usually to call the NewGrammar method, but this is not necessary. If the NewGrammar method is not called, then any new productions are added to the current grammar, if any. long NewGrammar(String GrammarName)
Once a new grammar has been created, it can be converted to ASCII and/or saved using the following methods. The GetAscii method allows the host program to perform its own I/O, while the SaveAscii method causes the file to be written by the component. String GetAscii(void) long SaveAscii(String FileName) In addition to creating new productions, it is possible to delete existing productions. The following method can be used to delete any production, including those that came into existence as a result of a ParseString or ParseFile method call. long DeleteProduction(String ProductionName) The following is a list of the methods that can be used to create productions. The type StringList is actually the same as the type String. The reason it is designated differently here is because the functions will treat the value of the string as a list of strings. Each string must be terminated by a null character, and the list itself must be terminated by two consecutive null characters. This is \0 in C++ and Chr(0) in Visual Basic. Those StringList variables named "TaggedList" have an additional requirement that the strings must appear in pairs. The first string of the pair will be interpreted as an ASCII-encoded decimal number and will be converted to a binary value. The second string will be interpreted as a string. Counter and BinaryCounter productions have an operand called "EndValid." If this value is zero, the End argument will be ignored, and the counter will be interpreted as if no End value was specified. Otherwise the End value is used as one would expect. For binary productions, the Width should be 8, 16, or 32. Any value larger than 32 will be interpreted as 32. Otherwise the specified value will be rounded up to the next highest value from the list 8, 16, and 32. Productions that can run out of choices have ContinueSpec and NextName parameters. ContinueSpec must be specified as a value from 0 through 5 inclusive. These values will be interpreted as the Continue specification of the production, with the following meanings: DEFAULT=0, NEXT=1, STOP=2, ABORT=3, CONTINUE=4, RESTART=5. If 3 (NEXT) is specified, then NextName must contain the name of a production, otherwise NextName is ignored. The value 0 (DEFAULT) causes the default action for the particular production to be used. Seed productions require the specification of a 48-bit random number seed. This value will be used as the initial value of the random number seed. The value must be specified as 3 16-bit signed numbers. The list of strings specified for the AddExpression method has a special form. The collection of strings must consist of a set of operators and operands specified in prefix form. For example, the expression "A+B" must be specified as three consecutive strings "+", "A", and "B". No parentheses are used in the specification. Thus (A+B)*(C+D) must be specified as the following sequence of strings "*", "+", "A", "B", "+", "C", "D". long
AddAction(String ProductionName, String FileName, String FunctionName) EventsErrorMessage(String Message, long LineNumber, String FileName)
|
||||||||||||||