Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

com.coasttocoastresearch.examples
Class Main

java.lang.Object
  extended by com.coasttocoastresearch.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 in RunTests

Timing Test Namefactor
anbn7.754
anbncn21.18
expressions1.836
inifile3.468
mailbox4.896
udtlib-alphanum6.962
udtlib-any7.861
udtlib-comment-semi12.90
udtlib-comment-cpp17.98
udtlib-comment-c25.15
udtlib-decnum3.175
udtlib-hexnum11.49
udtlib-lineend-forgiving1.897
udtlib-lineend-lf2.408
udtlib-lineend-crlf1.096
udtlib-quoted-string1.398
udtlib-wsp7.259
udtlib-wsp-comments10.89
udtlib-wsp-folding11.44
udtlib-wsp-folding-comments10.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.

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
static class Main.Tests
           
 
Constructor Summary
Main()
           
 
Method Summary
static void main(java.lang.String[] args)
          The driver for test selection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Main

public Main()
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.

Java APG, Version 1.0
Author Lowell D. Thomas
Copyright © Coast to Coast Research, Inc. 2011

Licence Notification

All the software in this distribution is free software:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program in the COPYING file. If not, see GPL, Version 2
or GPL, Version 3 or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.