Package examples
Class Main
- java.lang.Object
-
- examples.Main
-
public class Main extends java.lang.Object
This class provides a static main() function which is the driver for selecting from among the several available tests. Interested persons should look at the example code for details of how to use Java APG parsers for the examples given. Some of the examples provide simple demonstrations of usage. Most of the examples give a comparison between the normal CFG parsers and the same problem using UDT functions for greater efficiency. The comparisons are done with the standardized functions inRunTests
Some typical time factors. Timing Test Name factor anbn 7.754 anbncn 21.18 expressions 1.836 inifile 3.468 mailbox 4.896 udtlib-alphanum 6.962 udtlib-any 7.861 udtlib-comment-semi 12.90 udtlib-comment-cpp 17.98 udtlib-comment-c 25.15 udtlib-decnum 3.175 udtlib-hexnum 11.49 udtlib-lineend-forgiving 1.897 udtlib-lineend-lf 2.408 udtlib-lineend-crlf 1.096 udtlib-quoted-string 1.398 udtlib-wsp 7.259 udtlib-wsp-comments 10.89 udtlib-wsp-folding 11.44 udtlib-wsp-folding-comments 10.74 A quick comparison of the average time factors for the examples is given in the table to the right. The factor is CFG time / UDT time. Results will vary in different environments. (A factor of 10, for example, means that the CFG time is 10 times greater than the UDT time.)
Command line usage of the driver function main() is given below.
command line: java -jar examples.jar [args] args: flags and/or parameters flags ? if true, print the help screen /? if true, print the help screen help if true, print the help screen /help if true, print the help screen -help if true, print the help screen --help if true, print the help screen parameters /reps= number of times to repeat the parse of the input string (default: 1000000) /test= the test name (required) (default: null) /out= file name of the output device(if default uses System.out) (default: null) All flags are false by default. Specifying a flag one or more times sets it to true. Parameters are of the form "arg value" (no space). eg. /test=demo-ast. Parameter values may not be empty. Parameter values containing spaces must be quoted. All command line arguments must be a valid flag or parameter. valid test names: test name : description --------- : ----------- demo-ast : demonstration of creating and displaying the AST demo-ast-callback : demonstration of translating the AST demo-udt-ast : demonstration of a UDT adding nodes to the AST demo-udt-alt : demonstration of a UDT acting as a specialized ALT operator demo-trace : demonstration of displaying the trace anbn : timing comparison for a^nb^n grammar anbncn : timing comparison for a^nb^nc^n grammar expressions : timing comparison for Expressions grammar inifile : timing comparison for the "ini" file format mailbox : timing comparison for the email address grammar udtlib-alphanum : timing comparison for UdtLib.Alphanum udtlib-any : timing comparison for UdtLib.Any udtlib-comment : timing comparison for UdtLib.SemiComment udtlib-comment-semi : timing comparison for UdtLib.SemiComment udtlib-comment-cpp : timing comparison for UdtLib.CppComment udtlib-comment-c : timing comparison for UdtLib.CComment udtlib-decnum : timing comparison for UdtLib.DecNum udtlib-hexnum : timing comparison for UdtLib.HexNum udtlib-lineend : timing comparison for UdtLib.ForgivingLineEnd udtlib-lineend-forgiving : timing comparison for UdtLib.ForgivingLineEnd udtlib-lineend-lf : timing comparison for UdtLib.LFLineEnd udtlib-lineend-crlf : timing comparison for UdtLib.CRLFLineEnd udtlib-quoted-string : timing comparison for UdtLib.DoubleQuotedString udtlib-wsp : timing comparison for UdtLib.WhiteSpace udtlib-wsp-comments : timing comparison for UdtLib.WhiteSpace including comments udtlib-wsp-folding : timing comparison for UdtLib.WhiteSpace including folding white space udtlib-wsp-comments-folding : timing comparison for UdtLib.WhiteSpace including both folding and comments udtlib-wsp-folding-comments : timing comparison for UdtLib.WhiteSpace including both folding and comments demos : run all demonstrations timing : run all timing tests (may take up to 10 or more minutes) all : run all tests (may take up to 10 or more minutes)
Disclaimer: These examples should not be considered a part of the Java APG API. Backward compatibility or even the existence of these examples or packages from version to version is not guaranteed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Main.Tests
-
Constructor Summary
Constructors Constructor Description Main()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
The driver for test selection.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
The driver for test selection. Selects a test from the first command line parameter and runs the test. Catches all Exceptions thrown by the test and displays the Exception message and a stack trace of where it was thrown from.- Parameters:
args
- the command line parameters for test selection. Request help (arg=?) to see all command line parameters and valid test names.
-
-