Language Processing
v2.0

Package wcs

Web compiler service.

See:
          Description

Interface Summary
Job.Processor what each step of a processing pipeline must do.
 

Class Summary
Applet backend for System spoofer: a singleton class to run main in a simulated terminal.
Clipboard import and export of text using drag and drop and cut/copy/paste; modified from an example in Sun's Java Tutorial.
CUPProcessor preprocess CUP elements at any level with non-empty source and sink but not sink='false'.
DelimiterProcessor process delimiter attributes in source elements at level 3.
HowtoProcessor make URLs in howto attributes at any level absolute.
JagProcessor preprocess jag elements at any level with non-empty source and sink but not sink='false'.
JarProcessor collate the applet archive from applet.jar, the temporary class file tree, and from each jar element at level 2 and each nested jar element with sink='applet' or sink='jnlp' at level 2 on the classpath.
JavaccProcessor preprocess javacc elements at any level with non-empty source and sink but not sink='false'.
JavacProcessor compile Java source tree using the Java Compiler API.
JavacProcessor.FileObject common base class.
JavacProcessor.JobFileManager redirect file management to a job.
JavacProcessor.JobListener insert message into javac or job; mark job if error.
JavacProcessor.SourceObject represent a source element.
JavacProcessor.SystemObject represent System spoofed in a package.
JayProcessor preprocess jay elements at any level with non-empty source and sink but not sink='false' or sink='jay'.
JLexProcessor preprocess JLex elements at any level with non-empty source and sink but not sink='false'.
Job process a job document.
Job.Copy transfer input and output from an operating system process.
JParsecProcessor process jparsec elements at any level with non-empty source and sink but not sink='false'.
MopsProcessor preprocess mops elements at any level with non-empty source and sink but not sink='false'.
Oops3Processor preprocess oops3 elements at any level with non-empty source and sink but not sink='false'.
PackageProcessor determine package and class name of non-empty javac/source elements at any level with javac.sink='applet' or javac.sink='jnlp'.
Pj2Processor preprocess pj2 elements at any level with non-empty source and sink but not sink='false'.
PjProcessor preprocess pj elements at any level with non-empty source and sink but not sink='false'.
Reaper manage file deletion.
Servlet dispatch queryString from GET and POST to Job, return files based on pathInfo.
SinkProcessor process common aspects of sink attributes at level 2.
SourceProcessor replace URLs in source elements at level 3: fetch source from URL and process format attributes.
Terminal simulate standard i/o connections.
VigProcessor preprocess vig elements at any level with non-empty source and sink but not sink='false'.
XvProcessor preprocess xv elements at any level with non-empty source and sink but not sink='false'.
 

Package wcs Description

Web compiler service.

This is the homepage of wcs, a servlet to provide Java-based compilation and execution in an applet or through Java Web Start. It is intended to support rapid prototyping and experimentation with small Java programs and Java-based compiler generation tools but it can be used to outsource all compilation steps. The client only needs to install a Java runtime environment and optionally support the execution of unsigned Java applets; the software development tools reside on the server.

Service is requested through a XML-based job document containing a job, as defined in doc-files/job.dtd. Alternatively, a set of key/value pairs can be specified in any order; they are converted into a job as described in Converting keys.

A job can have global attributes such as form which control how nested elements and attributes are interpreted. A job contains processing steps which can have additional attributes.

Often a job is sent as a set of key/value pairs by submitting a form to a web server. There are no particular requirements for a form as long as all necessary key/value pairs are sent. For convenience, the servlet also supports the creation of typical forms with dynamic creation and resizing of multiple text areas as described Forms. Those forms can be a starting point for integrating compilation and execution of examples with tutorial materials.

Requests

The servlet does not distinguish between GET and POST requests. It does, however, act either on pathInfo or on a queryString containing key/value pairs, not both:

GET servlet/pathInfo GET servlet?queryString POST servlet queryString

pathInfo should be a partial or absolute URL, ending in .job, which specifies a job document, see doc-files/job.dtd.

The servlet only accepts HTTP-based URLs. Partial URLs may be prefixed with http:. Partial URLs are resolved relative to the referer of a request, if any, or relative to the web server of the servlet. Partial URLs in a job document are resolved relative to the address of the document itself.

pathInfo can also be a simple file name matching result.path. This type of request is used internally to retrieve temporary files resulting from successfully completed jobs. Temporary files will eventually be removed by the Reaper, see reap.

Converting keys

Key/value pairs from a queryString are converted into a job document by Job.job. In general, a key is used as an attribute name for the job element and the value is the attribute's value.

Some keys, e.g., processor, are suffixed with a period followed by a number starting at one and ranging uninterrupted through consecutive values. Suffixed keys are grouped by suffix and the group defines a processing step. Processing steps are nested into the job in numerical order. (The order should not be relevant for processing.)

The value of the key processor.n is used as the element name for the processing step. The value of the key source.n is used as the text content of a source element which is nested into the processing step. All other keys with the same suffix are used as attribute names for the processing step and the key values are the attributes' values; the suffix is removed from each attribute name.

Job attributes

The job element can have the following attributes. As discussed in Converting keys, these attribute names can be used as keys in a queryString.

AttributeConstraintPurpose
howto optional, URL refers to a XML-based document, typically a well-formed XHTML div, p, or explicitly styled table node, which is inserted as instructions on the page resulting from a successful compilation; defaulted to the document howto for an applet and jnlp for Java Web Start.
main optional, blank-separated list of fully qualified class names the list is added to the list of class names collected by process from each compiled Java source file. The complete list is handed to Applet which offers the classes for selection to run their main method.

Common attributes

The following attributes can be specified for each processing step. As discussed in Converting keys, these attribute names require numerical suffixes if they are used as keys in a queryString.

AttributeConstraintPurpose
delimiter optional, regular expression if specified, the nested source element is split into one or more source elements for separate processing. Splitting is applied after retrieving the text content of a source from a URL; it cannot be used to specify multiple URLs for retrieval.
format optional, url if specified as url the text content of the nested source element must be a (partial) URL which is dereferenced unconditionally.
otherwise if the text content of the nested source element starts with http: it is assumed to be a URL which is dereferenced.
howto optional, URL refers to a XML-based document, typically a well-formed XHTML div, p, or explicitly styled table node, which is inserted as instructions on the request page resulting from a form request, see Forms.

Forms

A form request is a convenient way to create a web page with text areas containing sources for editing and submission for compilation. The request is supported as a convenience for online tutorials and to provide a variety of examples for the creation of compilation requests. A form request need not precede a compilation request.

If a job element is a form request there are additional attributes. As discussed in Converting keys, these attribute names can be used as keys in a queryString.

AttributeConstraintPurpose
download optional, false or a blank-separated list of processor names limits the possibility of accessing tool homepages in the form.
dynamic optional, false or a blank-separated list of processor names limits the possibility of dynamically creating new text areas in the form.
form true true is required for a form request, see Forms.
target optional, usually _blank, _self, or _top set as target attribute of the form, i.e., the value controls where the result of submitting the form is displayed; defaulted to the value configured for target.

Examples
doc-files/1-form.job If the servlet receives neither pathInfo nor a queryString it acts as if it receives a trivial job for a form request. The servlet replies with a default request page from which any number of sources for any known processor can be submitted.
form=true

javac
doc-files/2-form.job This job returns a form to edit and execute a single public Java class. The text area is initialized by dereferencing a partial URL. The applet page will replace the request page and contain execution instructions. There is no link to access tool homepages.
download=false
dynamic=false
form=true
howto=doc-files/2.xml
target=_self
processor.1=javac
source.1=http:doc-files/2.java
sink.1=applet
doc-files/3-form.job This job returns a form to edit and execute two public Java classes which are obtained by dereferencing partial URLs. As explained in the form, the second text area can only contain a URL (not a good choice). More text areas for Java sources can be created.
download=false
dynamic=javac
form=true
howto=doc-files/3.xml
target=_self
processor.1=javac
source.1=http:doc-files/3a.java
sink.1=applet
processor.2=javac
source.2=doc-files/3b.java
format.2=url
howto.2=doc-files/url.xml
sink.2=applet
doc-files/4-form.job This job returns a form with a single text area to edit one or more Java classes which are separated by %%, as explained in the form. No more text areas may be created to avoid confusion with the delimiter feature in the first text area. Only one of the two selectable classes contains main.
download=false
dynamic=false
form=true
howto=doc-files/2.xml
target=_self
processor.1=javac
source.1=http:doc-files/4.txt
delimiter.1=%%
howto.1=doc-files/delimiter.xml
sink.1=applet

JLex
doc-files/5-form.job This job returns a form to edit a single source and preprocess it with JLex. The text area is initialized by dereferencing a partial URL. As explained, for execution a main method needs to be added. Therefore, more text areas for Java sources may be created. The homepage for JLex may be accessed.
download=JLex
dynamic=javac
form=true
target=_self
processor.1=JLex
source.1=http:doc-files/Num.lex
howto.1=doc-files/Num.xml
sink.1=java
doc-files/6-form.job This job returns a form to edit a JLex-based line numbering function and a Java driver. The text areas are initialized by dereferencing partial URLs. The instructions for the applet page explain that lines from standard input will be numbered.
download=JLex
dynamic=false
form=true
howto=doc-files/Main.xml
target=_self
processor.1=JLex
source.1=http:doc-files/Num.lex
sink.1=applet
processor.2=javac
source.2=http:doc-files/Main.java
sink.2=applet

jay
doc-files/7-form.job This job returns a form to edit a parser and preprocess it with jay. The form explains how to get a description of the parser or show the generated Java code. The text area is initialized by dereferencing a partial URL. More text areas for Java and JLex sources may be created and the trace archive may be downloaded.
download=jay JLex yydebug
dynamic=javac JLex
form=true
target=_self
processor.1=jay
source.1=http:doc-files/expr.jay
howto.1=doc-files/jay.xml
sink.1=verbose
doc-files/8-form.job This job returns a form to edit a parser and preprocess it with jay, edit a scanner and preprocess it with JLex, and edit a Java-based scanner and a main program. The text areas are initialized by dereferencing partial URLs. The trace archive may be downloaded. The instructions for the form explain that there are two scanners, only one at a time should be compiled. The instructions for the applet page explain how to run the resulting interpreter.
download=jay JLex yydebug
dynamic=false
form=true
howto=doc-files/float.xml
target=_self
processor.1=jay
source.1=http:doc-files/expr.jay
howto.1=doc-files/jay.xml
sink.1=applet
processor.2=JLex
source.2=http:doc-files/Scanner.lex
howto.2=doc-files/scan.xml
sink.2=applet
processor.3=javac
source.3=http:doc-files/Scanner.java
sink.3=applet
processor.4=javac
source.4=http:doc-files/expr.java
sink.4=applet

pj
doc-files/9-form.job This job returns a form to edit a parser system and preprocess it with pj; the form explains what preprocessing options to set. The form includes a base class so that an integer expression can be displayed as an indented tree. The applet page explains how to test the scanner, parser, and tree builder.
download=pj jay JLex yydebug
dynamic=false
form=true
howto=doc-files/pj-run.xml
processor.1=pj
source.1=http:doc-files/expr.pj
howto.1=doc-files/pj.xml
sink.1=false
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet

pj2
doc-files/10-form.job This job returns a form to edit a parser system and preprocess it with pj2; the form explains what preprocessing options to set. The applet page explains how to test the scanner and parser.
download=pj2 jay JLex yydebug
dynamic=false
form=true
howto=doc-files/pj2-run.xml
processor.1=pj2
source.1=http:doc-files/expr.pj2
howto.1=doc-files/pj2.xml
sink.1=false

oops3
doc-files/11-form.job This job returns a form to edit a parser system and preprocess it with oops3; the form explains what preprocessing options to set. The parser will display an integer expression as an indented tree. The applet page explains how to test the scanner and parser.
download=oops3 JLex mops scanner
dynamic=false
form=true
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
howto.1=doc-files/oops3.xml
main.1=true
sink.1=false

jag
doc-files/12-form.job This job returns a form to edit two jag-based visitors and the pj-based frontend introduced above. The instructions for the applet page explain that four main methods may be selected and suggest a coding experiment.
download=jag pj
dynamic=false
form=true
howto=doc-files/jag.xml
target=_self
processor.1=jag
source.1=http:doc-files/dump.jag
sink.1=applet
processor.2=jag
source.2=http:doc-files/code.jag
sink.2=applet
processor.3=pj
source.3=http:doc-files/expr.pj
recover.3=true
scanner.3=static
sink.3=applet
tree.3=static
processor.4=javac
source.4=http:doc-files/Node.java
sink.4=applet

CUP
doc-files/13-form.job This job returns a form to edit a parser and preprocess it with CUP and edit a scanner and preprocess it with JLex. The text areas are initialized by dereferencing partial URLs. The instructions for the applet page explain how to run the resulting interpreter.
download=CUP JLex
dynamic=false
form=true
howto=doc-files/cup-run.xml
target=_self
processor.1=CUP
source.1=http:doc-files/expr.cup
howto.1=doc-files/cup.xml
sink.1=applet
processor.2=JLex
source.2=http:doc-files/lexer.lex
sink.2=applet

javacc
doc-files/14-form.job This job returns a form to edit an interpreter, a tree builder, and a class representing leaf nodes and preprocess it with javacc. The text areas are initialized by dereferencing partial URLs. The instructions for the applet page explain how to run the resulting interpreter and tree builder.
download=javacc
dynamic=javac
form=true
howto=doc-files/javacc-run.xml
target=_self
processor.1=javacc
source.1=http:doc-files/expr.jj
sink.1=applet
processor.2=javacc
source.2=http:doc-files/expr.jjt
howto.2=doc-files/javacc.xml
sink.2=applet
tree.2=true
processor.3=javac
source.3=http:doc-files/ASTLiteral.java
sink.3=applet

vig
doc-files/15-form.job This job returns a form to edit two vig-based visitors and the pj2-based frontend introduced above. The instructions for the applet page explain that four main methods may be selected and suggest a coding exercise.
download=vig pj2
dynamic=false
form=true
howto=doc-files/vig.xml
processor.1=vig
source.1=http:doc-files/postfix.vig
sink.1=applet
processor.2=vig
source.2=http:doc-files/stack.vig
sink.2=applet
processor.3=pj2
source.3=http:doc-files/expr.pj2
main.3=true
sink.3=applet

mops
doc-files/16-form.job This job returns a form to edit a functional tree builder. The instructions for the applet page suggest a coding exercise.
download=mops scanner
dynamic=false
form=true
howto=doc-files/mops.xml
processor.1=mops
source.1=http:doc-files/Tree.jm
sink.1=applet

xv
doc-files/17-form.job This job returns a form to edit an xv-based visitor and the pj2-based frontend introduced above. The instructions for the applet page explain that three main methods may be selected and suggest a coding exercise.
download=pj2 xv
dynamic=false
form=true
howto=doc-files/xv.xml
processor.1=xv
source.1=http:doc-files/stack.xv
sink.1=applet
processor.2=pj2
source.2=http:doc-files/expr.pj2
main.2=true
sink.2=applet
style.2=xml

jparsec
doc-files/18-form.job This job returns a form to edit three calculators implemented using the jparsec framework.
download=jparsec
dynamic=false
form=true
processor.1=jparsec
source.1=http:doc-files/jparsec-1.java
sink.1=applet
processor.2=jparsec
source.2=http:doc-files/jparsec-2.java
sink.2=applet
processor.3=jparsec
source.3=http:doc-files/jparsec-3.java
sink.3=applet

javac

A javac element submits one or more Java sources for compilation and execution. The element can have Common attributes and sink. If compilation is successful, the server responds with an applet page or Java Web Start for execution; otherwise a text page displays the compilation errors.

A preprocessing step might add a nested javac element internally to submit Java sources resulting from preprocessing for compilation.

AttributeConstraintPurpose
sink applet, false, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as false causes the processing step to be ignored.


Examples
doc-files/2.job This job returns an applet page to execute a single public Java class. The source doc-files/2.java includes a non-public class and is obtained by dereferencing a partial URL. The applet page includes execution instructions.
howto=doc-files/2.xml
processor.1=javac
source.1=http:doc-files/2.java
sink.1=applet
doc-files/3.job This job returns an applet page to execute two public Java classes. Each source, doc-files/3a.java and doc-files/3b.java, includes a main method and is obtained by dereferencing a partial URL. The applet page includes execution instructions.
howto=doc-files/3.xml
processor.1=javac
source.1=http:doc-files/3a.java
sink.1=applet
processor.2=javac
source.2=doc-files/3b.java
format.2=url
sink.2=applet
doc-files/4.job This job returns an applet page to execute one of two public Java classes. The source doc-files/4.txt is obtained by dereferencing a partial URL and employs %% as delimiter between two Java sources. The applet page includes execution instructions. Only one of the two selectable classes contains main.
howto=doc-files/2.xml
processor.1=javac
source.1=http:doc-files/4.txt
delimiter.1=%%
sink.1=applet
doc-files/no.job This job returns a log page because the source text consists only of the delimiter, i.e., there are no Java sources.
processor.1=javac
source.1=@@
delimiter.1=@@
sink.1=applet

JLex

JLex generates a Java class from a table of regular expressions and associated Java code which is executed when input matches an expression. A JLex element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and an additional value for sink. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. If compilation is successful the server responds with an applet page or Java Web Start for execution; otherwise a text page displays compilation errors or the generated Java code.

AttributeConstraintPurpose
sink applet, false, java, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the JLex step will result in Java code only.

if specified as false causes the JLex step to be ignored.

if specified as java for a JLex step results in Java code only.


Examples
doc-files/5.job This job obtains doc-files/Num.lex by dereferencing a partial URL and returns comments and the Java source resulting from preprocessing with JLex.
processor.1=JLex
source.1=http:doc-files/Num.lex
sink.1=java
doc-files/6.job This job adds doc-files/Main.java to the previous job and returns an applet page with instructions how to number lines from standard input.
howto=doc-files/Main.xml
processor.1=JLex
source.1=http:doc-files/Num.lex
sink.1=applet
processor.2=javac
source.2=http:doc-files/Main.java
sink.2=applet
doc-files/noJLex.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=JLex
source.1= @@ x @@
delimiter.1=@@
sink.1=applet
processor.2=javac
source.2=http:doc-files/Main.java
sink.2=applet

jay

jay generates a Java class from a table of grammar rules and associated Java code which is executed when tokenized input matches a rule. A jay element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the parser tables, the generated Java source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink applet, false, java, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the jay step will result in Java code only.

if specified as false causes the jay step to be ignored.

if specified as java for a jay step results in Java code only.

if specified as verbose for a jay step results in a description of the generated parser and Java code only.

trace optional, true specify true to generate trace code.

Examples
doc-files/7a.job This job obtains doc-files/expr.jay by dereferencing a partial URL and returns a description of the parser tables and the Java code generated by jay.
processor.1=jay
source.1=http:doc-files/expr.jay
sink.1=verbose
doc-files/7b.job This job returns the generated Java code with the trace code uncommented.
processor.1=jay
source.1=http:doc-files/expr.jay
sink.1=java
trace.1=true
doc-files/8a.job This job returns an applet page with instructions how to interpret floating point expressions. The main program is a separate Java class. The scanner is preprocessed with JLex and lags one input character behind.
howto=doc-files/float.xml
processor.1=jay
source.1=http:doc-files/expr.jay
sink.1=applet
processor.2=JLex
source.2=http:doc-files/Scanner.lex
sink.2=applet
processor.3=javac
source.3=http:doc-files/expr.java
sink.3=applet
doc-files/8b.job This job returns an applet page with instructions how to interpret floating point expressions. The main program and the scanner are separate Java classes. The scanner is based on StreamTokenizer and needs no lookahead.
howto=doc-files/float.xml
processor.1=jay
source.1=http:doc-files/expr.jay
sink.1=applet
processor.2=javac
source.2=http:doc-files/Scanner.java
sink.2=applet
processor.3=javac
source.3=http:doc-files/expr.java
sink.3=applet
doc-files/nojay.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=jay
source.1= @@ x @@
delimiter.1=@@
sink.1=applet
processor.2=javac
source.2=http:doc-files/Scanner.java
sink.2=applet
processor.3=javac
source.3=http:doc-files/expr.java
sink.3=applet

pj

pj uses JLex and jay to generate a Java-based parser and tree builder from a table of annotated grammar rules and regular expressions. A pj element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the parser tables, the generated source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

pj is superseded by pj2 and is supported for legacy purposes only.

AttributeConstraintPurpose
sink applet, dump, factory, false, java, jay, JLex, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the pj step will result in Java code only.

if specified as dump the pj step results in a description of the parser's tree only.

if specified as factory the pj step results in the Java code generated for the tree factory only.

if specified as false causes the pj step to be ignored.

if specified as java for a pj step results in Java code only.

if specified as jay or JLex the pj step results in the code generated for the specific preprocessor only.

if specified as verbose the pj step results in a description of the generated parser only.

flatten optional, true specify true so that the tree factory squeezes out a single ArrayList parameter.
recover optional, true specify true to insert error recovery rules in iteration constructs.
scanner optional, static or true specify true to generate a scanner, static to generate a static scanner and a main method for testing.
trace optional, true or a digit from 0 to 3 specify true to arrange for tracing information as diagnostic output or specify a digit to animate parsing. The digit is composed from the bit flags 1 to request an input window and 2 for an output window.
tree optional, static or true specify true (or static) to generate a (static) tree factory and call it from the parser's main method.

Examples
doc-files/9a.job This job obtains a parser system doc-files/expr.pj by dereferencing a partial URL, dumps the tree which represents the parser system within pj, and shows the source which is generated for jay.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=dump
doc-files/9b.job This job shows the code sent to JLex to generate a scanner.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=JLex
doc-files/9c.job This job shows the code sent to jay to generate a parser.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=jay
doc-files/9d.job This job describes the parser tables generated by jay.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=verbose
doc-files/9e.job This job adds robust error recovery to iterative constructs and describes the parser tables.
processor.1=pj
source.1=http:doc-files/expr.pj
recover.1=true
sink.1=verbose
doc-files/9f.job This job shows a Java code fragment generated for the tree factory to represent a parse tree.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=factory
doc-files/9g.job This job shows the Java code generated for the parser.
processor.1=pj
source.1=http:doc-files/expr.pj
sink.1=java
doc-files/9h.job This job shows the generated code which includes a scanner yyLex and two main methods to test the scanner and the parser.
processor.1=pj
source.1=http:doc-files/expr.pj
scanner.1=static
sink.1=java
doc-files/9i.job This job shows the generated code which includes a scanner yyLex, a tree factory yyTree, and two main methods to test the scanner and the tree builder.
processor.1=pj
source.1=http:doc-files/expr.pj
scanner.1=static
sink.1=java
tree.1=static
doc-files/9j.job This job returns an applet page with instructions how to test the scanner and parse integer expressions. The result is simply no error message for syntactically correct expressions.
howto=doc-files/pj-run.xml
processor.1=pj
source.1=http:doc-files/expr.pj
scanner.1=static
sink.1=applet
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet
doc-files/9k.job This job returns an applet page with instructions how to test the scanner and parse integer expressions. The parser includes error recovery on input lines. Execution of the parser is animated.
howto=doc-files/pj-run.xml
processor.1=pj
source.1=http:doc-files/expr.pj
recover.1=true
scanner.1=static
sink.1=applet
trace.1=3
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet
doc-files/9l.job This job returns an applet page with instructions how to test the scanner and represent integer expressions as trees. The parser includes error recovery on input lines.
howto=doc-files/pj-run.xml
processor.1=pj
source.1=http:doc-files/expr.pj
recover.1=true
scanner.1=static
sink.1=applet
tree.1=static
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet
doc-files/9m.job This job uses a hand-crafted scanner doc-files/yyLex.java and returns an applet page with instructions how to represent integer expressions as trees. The scanner is subclassed from a StreamTokenizer-based scanner doc-files/Scanner.java which, unfortunately, needs constants defined by a jay-based parser doc-files/expr.jay.
howto=doc-files/yyLex.xml
processor.1=pj
source.1=http:doc-files/expr.pj
recover.1=true
scanner.1=static
sink.1=applet
tree.1=static
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet
processor.3=javac
source.3=http:doc-files/yyLex.java
sink.3=applet
processor.4=javac
source.4=http:doc-files/Scanner.java
sink.4=applet
processor.5=jay
source.5=http:doc-files/expr.jay
sink.5=applet
doc-files/noPj.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
howto=doc-files/pj-run.xml
processor.1=pj
source.1=@@ x @@
delimiter.1=@@
recover.1=true
scanner.1=static
sink.1=applet
tree.1=static
processor.2=javac
source.2=http:doc-files/Node.java
sink.2=applet

pj2

pj2 targets jay to generate a Java-based parser and tree builder from a table of annotated grammar rules and regular expressions; it uses JLex to generate the scanner. A pj2 element submits one or more sources for preprocessing, jay preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the parser tables, the generated sources, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink applet, false, java, jay, JLex, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the pj2 step will result in Java code only.

if specified as false causes the pj2 step to be ignored.

if specified as java for a pj2 step results in Java code only.

if specified as jay or JLex the pj step results in the code generated for the specific preprocessor only.

if specified as verbose the pj2 step results in a description of the generated parser only.

main optional, null or true specify a value to generate a main program to test the parser; if the value is null the parser will represent empty input as null, if the value is true the parser will silently ignore empty input; the behavior can be toggled with an argument on the parser's command line.
recover optional, true specify true to insert error recovery rules in iteration constructs.
scanner optional, false specify false to suppress scanner generation.
style optional, visitor or xml specify visitor to implement the visitor pattern for the tree nodes, specify xml to represent the tree using XML rather then Java objects.
trace optional, true or a digit from 0 to 3 specify true to arrange for tracing information as diagnostic output or specify a digit to animate parsing. The digit is composed from the bit flags 1 to request an input window and 2 for an output window.

Examples
doc-files/10a.job This job obtains a parser system doc-files/expr.pj2 by dereferencing a partial URL and shows the code sent to JLex to generate a scanner.
processor.1=pj2
source.1=http:doc-files/expr.pj2
sink.1=JLex
doc-files/10b.job This job shows the code sent to jay to generate a parser with value collection.
processor.1=pj2
source.1=http:doc-files/expr.pj2
sink.1=jay
doc-files/10c.job This job shows a description of the parser tables and the Java code generated by jay.
processor.1=pj2
source.1=http:doc-files/expr.pj2
sink.1=verbose
doc-files/10d.job This job adds robust error recovery to iterative constructs and describes the parser tables.
processor.1=pj2
source.1=http:doc-files/expr.pj2
recover.1=true
sink.1=verbose
doc-files/10e.job This job shows the Java code generated for the parser without a scanner.
processor.1=pj2
source.1=http:doc-files/expr.pj2
scanner.1=false
sink.1=java
doc-files/10f.job This job shows the generated code which includes a scanner yyLex, a tree factory yyTree, and two main methods to test the scanner and the tree builder.
processor.1=pj2
source.1=http:doc-files/expr.pj2
main.1=true
sink.1=java
doc-files/10g.job This job returns an applet page with instructions how to test the scanner and parse integer expressions. The parser includes error recovery on input lines. Execution of the parser is animated.
howto=doc-files/pj2-trace.xml
processor.1=pj2
source.1=http:doc-files/expr.pj2
main.1=true
recover.1=true
sink.1=applet
trace.1=3
doc-files/10h.job This job returns an applet page with instructions how to test the scanner, parse integer expressions, and display the collected values. The parser includes error recovery on input lines.
howto=doc-files/pj2-run.xml
processor.1=pj2
source.1=http:doc-files/expr.pj2
main.1=true
recover.1=true
sink.1=applet
doc-files/10i.job This job returns an applet page with instructions how to test the scanner, parse integer expressions, and display the collected values as an XML document. The parser includes error recovery on input lines.
howto=doc-files/pj2-run.xml
processor.1=pj2
source.1=http:doc-files/expr.pj2
main.1=true
recover.1=true
sink.1=applet
style.1=xml
doc-files/noPj2.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=pj2
source.1=@@ x @@
delimiter.1=@@
sink.1=applet

oops3

oops3 generates Java code for LL(1) and functional parsers and tree builders from a table of annotated grammar rules and regular expressions; it uses JLex to generate the scanner for LL(1) parsers and scanner for functional parsers. An oops3 element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the parser, the builder interface, the generated scanner or Java source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink actions, applet, false, follow, java, JLex, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the oops3 step will result in Java code only.

if specified as false causes the oops3 step to be ignored.

if specified as actions for an oops3 step results in a description of the builder interface.

if specified as follow for an oops3 step results in a description of the generated parser which for an LL(1) parser includes the follow sets.

if specified as java for an oops3 step results in Java code only.

if specified as JLex for an oops3 step results in the code from which the scanner is generated for an LL(1) parser.

if specified as verbose for an oops3 step results in a description of the generated parser only.

functional optional, true specify true to generate a functional parser.
main optional, null or true specify a value to generate a main program to test the parser; if the value is null the parser will represent empty input as null, if the value is true the parser will silently ignore empty input; the behavior can be toggled with an argument on the parser's command line.
scanner optional, false specify false to suppress scanner generation.
visitor optional, true specify true to implement the visitor pattern for the tree nodes.

Examples
doc-files/11a.job This job obtains doc-files/expr.xbnf by dereferencing a partial URL and returns a description of the parser generated by oops3.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
sink.1=verbose
doc-files/11b.job This job additionally shows the follow sets for the parser.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
sink.1=follow
doc-files/11c.job This job shows the code sent to JLex to generate a scanner.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
sink.1=JLex
doc-files/11d.job This job generates an interface which a builder class should implement. The actual connection is by reflection, i.e., the interface should be considered advisory.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
sink.1=actions
doc-files/11e.job This job shows the generated code which includes a scanner yyLex, a tree factory Tree, and two main methods to test the scanner and the tree builder.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
main.1=true
sink.1=java
doc-files/11f.job This job shows the generated code if the tree factory implements the visitor pattern.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
main.1=true
sink.1=java
visitor.1=true
doc-files/11g.job This job returns an applet page with instructions how to test the scanner and parse integer expressions.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
main.1=true
sink.1=applet
doc-files/11h.job This job returns an applet page where the parser stores null if an empty input is recognized.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
main.1=null
sink.1=applet
doc-files/11i.job This job shows the generated code for a functional parser which includes a regular-expression-based scanner, a tree factory, and a main method to test the tree builder.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
functional.1=true
main.1=true
sink.1=java
doc-files/11j.job This job returns an applet page with instructions how to parse integer expressions with a functional parser.
howto=doc-files/oops3-F-run.xml
processor.1=oops3
source.1=http:doc-files/expr.xbnf
functional.1=true
main.1=true
sink.1=applet
doc-files/noOops3.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
howto=doc-files/oops3-run.xml
processor.1=oops3
source.1=@@ x @@
delimiter.1=@@
main.1=true
sink.1=applet

jag

jag generates a Java-based tree visitor from a table of node class patterns and associated Java code which is executed upon matches; a tree is typically created by one of the frontends discussed above. A jag element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and sink. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. If compilation is successful the server responds with an applet page or Java Web Start for execution; otherwise a text page displays compilation errors or the generated Java code.

jag is superseded by vig and is supported for legacy purposes only.

AttributeConstraintPurpose
sink applet, false, java, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the jag step will result in Java code only.

if specified as false causes the jag step to be ignored.

if specified as java for a jag step results in Java code only.


Examples
doc-files/12a.job This job obtains a visitor doc-files/code.jag by dereferencing a partial URL and returns the Java source resulting from preprocessing with jag.
processor.1=jag
source.1=http:doc-files/code.jag
sink.1=java
doc-files/12b.job This job returns an applet page with instructions how to use a visitor doc-files/dump.jag to display an indented tree or another visitor doc-files/code.jag to generate code for a stack machine from integer expressions, or test the scanner or the tree builder.
howto=doc-files/jag.xml
processor.1=jag
source.1=http:doc-files/dump.jag
sink.1=applet
processor.2=jag
source.2=http:doc-files/code.jag
sink.2=applet
processor.3=pj
source.3=http:doc-files/expr.pj
recover.3=true
scanner.3=static
sink.3=applet
tree.3=static
processor.4=javac
source.4=http:doc-files/Node.java
sink.4=applet
doc-files/noJag1.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=jag
source.1= @@ x @@
delimiter.1=@@
sink.1=applet
doc-files/noJag2.job This job returns a page explaining the errors in compiling a preprocessed source which references the missing frontend.
processor.1=jag
source.1=http:doc-files/code.jag
sink.1=applet

CUP

CUP generates a Java class from a table of grammar rules and associated Java code which is executed when tokenized input matches a rule. A CUP element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the parser tables, the generated Java source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink applet, false, java, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the CUP step will result in Java code only.

if specified as false causes the CUP step to be ignored.

if specified as java for a CUP step results in Java code only.

if specified as verbose for a CUP step results in a description of the generated parser and Java code only.

expect optional, non-negative integer specify the expected number of conflicts in the grammar, if any.
parser optional, simple class name specify a class name for the parser class; the default is parser.
symbols optional, simple class name specify a class name for the class defining constants for the terminal symbol names; the default is sym.

Examples
doc-files/13a.job This job obtains a parser doc-files/expr.cup by dereferencing a partial URL and describes the parser generated by CUP.
processor.1=CUP
source.1=http:doc-files/expr.cup
sink.1=verbose
doc-files/13b.job This job shows the Java code generated for the parser.
processor.1=CUP
source.1=http:doc-files/expr.cup
sink.1=java
doc-files/13c.job This job returns an applet page with instructions how to interpret integer expressions. The scanner is preprocessed with JLex.
howto=doc-files/cup-run.xml
processor.1=CUP
source.1=http:doc-files/expr.cup
sink.1=applet
processor.2=JLex
source.2=http:doc-files/lexer.lex
sink.2=applet
doc-files/noCUP.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=CUP
source.1= @@ x @@
delimiter.1=@@
sink.1=applet
processor.2=JLex
source.2=http:doc-files/lexer.lex
sink.2=applet

javacc

javacc generates Java classes from grammar rules and embedded Java code which is executed when tokenized input matches a rule. jjtree preprocesses annotations of the rules and generates Java classes for tree building. jjdoc extracts the grammar from either type of input file. A javacc element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with a description of the grammar, the generated javacc or Java source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink applet, false, java, javacc, jnlp, or verbose if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the javacc step will result in Java code only.

if specified as false causes the javacc step to be ignored.

if specified as java for a javacc step results in Java code only.

if specified as javacc for a javacc step results in the javacc code generated by jjtree only.

if specified as verbose for a javacc step results in a description of the grammar rules only.

tree optional, true if specified as true, requests preprocessing by jjtree prior to javacc.

Examples
doc-files/14a.job This job obtains the source of an interpreter doc-files/expr.jj and a tree builder a doc-files/expr.jjt by dereferencing partial URLs and describes the grammars processed by javacc.
processor.1=javacc
source.1=http:doc-files/expr.jj
sink.1=verbose
processor.2=javacc
source.2=http:doc-files/expr.jjt
sink.2=verbose
tree.2=true
doc-files/14b.job This job shows the Java code generated for the interpreter, the source code for the parser implementing the tree builder, and finally the Java code generated for the tree builder.
processor.1=javacc
source.1=http:doc-files/expr.jj
sink.1=java
processor.2=javacc
source.2=http:doc-files/expr.jjt
sink.2=javacc
tree.2=true
processor.3=javacc
source.3=http:doc-files/expr.jjt
sink.3=java
tree.3=true
doc-files/14c.job This job overrides the class representing leaves doc-files/ASTLiteral.java and returns an applet page for the interpreter and the tree builder with instructions how to evaluate or create trees for integer expressions.
howto=doc-files/javacc-run.xml
processor.1=javacc
source.1=http:doc-files/expr.jj
sink.1=applet
processor.2=javacc
source.2=http:doc-files/expr.jjt
sink.2=applet
tree.2=true
processor.3=javac
source.3=http:doc-files/ASTLiteral.java
sink.3=applet
doc-files/noJavacc.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=javacc
source.1= @@ x @@
delimiter.1=@@
sink.1=applet

vig

vig generates a Java-based tree visitor from a table of node class patterns and associated Java code which is executed upon matches; a tree is typically created by one of the frontends discussed above. A vig element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. If compilation is successful the server responds with an applet page or Java Web Start for execution; otherwise a text page displays compilation errors or the generated Java code.

AttributeConstraintPurpose
sink applet, false, java, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the vig step will result in Java code only.

if specified as false causes the vig step to be ignored.

if specified as java for a vig step results in Java code only.

trace optional, true specify true to generate trace code.

Examples
doc-files/15a.job This job obtains a visitor doc-files/t.vig by dereferencing a partial URL and returns the Java source resulting from preprocessing with vig.
processor.1=vig
source.1=http:doc-files/postfix.vig
sink.1=java
doc-files/15b.job This job returns an applet page with instructions how to use a visitor doc-files/postfix.vig to display a tree in postorder or another visitor doc-files/stack.vig to generate code for a stack machine from integer expressions, or test the scanner or the tree builder.
howto=doc-files/vig.xml
processor.1=vig
source.1=http:doc-files/postfix.vig
sink.1=applet
processor.2=vig
source.2=http:doc-files/stack.vig
sink.2=applet
processor.3=pj2
source.3=http:doc-files/expr.pj2
main.3=true
sink.3=applet
doc-files/noVig1.job This job returns a page explaining the error in preprocessing a defective source consisting only of the character x; two empty preprocessor inputs are ignored after splitting the source.
processor.1=vig
source.1= @@ x @@
delimiter.1=@@
sink.1=applet
doc-files/noVig2.job This job returns a page explaining the errors in compiling a preprocessed source which references the missing frontend.
processor.1=vig
source.1=http:doc-files/postfix.vig
sink.1=applet

mops

mops translates the monadic notation described in Monadic Parsing using JavaScript to Java or JavaScript and supports functional parsers in Java. A mops element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and an additional value for sink. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. Depending on sink the server responds with the generated Java or JavaScript source, an applet page or Java Web Start for execution, or a text page in case of preprocessing or compilation errors.

AttributeConstraintPurpose
sink applet, false, java, javascript, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the mops step will result in Java code only.

if specified as false causes the mops step to be ignored.

if specified as java for a mops step results in Java code only.

if specified as javascript for a mops step results in JavaScript code only.


Examples
doc-files/16a.job This job obtains a tree builder for an arithmetic expression doc-files/Tree.jm by dereferencing a partial URL and shows the Java code generated by mops.
processor.1=mops
source.1=http:doc-files/Tree.jm
sink.1=java
doc-files/16b.job This job returns an applet page with instructions how to build a tree for an integer expression.
howto=doc-files/mops.xml
processor.1=mops
source.1=http:doc-files/Tree.jm
sink.1=applet
doc-files/16c.job This job translates the parser for the monadic notation doc-files/jsm.jsm into JavaScript.
processor.1=mops
source.1=http:doc-files/jsm.jsm
sink.1=javascript
doc-files/noMops.job This job returns a page explaining the error in preprocessing a defective source consisting only of the symbol |||; two empty preprocessor inputs are ignored after splitting the source.
processor.1=mops
source.1= @@ ||| @@
delimiter.1=@@
sink.1=applet

xv

xv generates a Java-based XML tree visitor from a table of regular expressions and/or xpath expressions with associated Java code which is executed upon matches; an XML can be created by pj2. A xv element submits one or more sources for preprocessing, Java compilation, and execution. The element can have Common attributes and more. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. If compilation is successful the server responds with an applet page or Java Web Start for execution; otherwise a text page displays compilation errors or the generated Java code.

AttributeConstraintPurpose
sink applet, false, java, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the xv step will result in Java code only.

if specified as false causes the xv step to be ignored.

if specified as java for a xv step results in Java code only.

trace optional, true specify true to generate trace code.

Examples
doc-files/17a.job This job obtains a visitor doc-files/stack.xv by dereferencing a partial URL and returns the Java source resulting from preprocessing with xv.
processor.1=xv
source.1=http:doc-files/stack.xv
sink.1=java
doc-files/17b.job This job returns an applet page with instructions how to use a visitor doc-files/stack.xv to display an XML tree in postorder, or test the scanner or the tree builder.
howto=doc-files/xv.xml
processor.1=xv
source.1=http:doc-files/stack.xv
sink.1=applet
processor.2=pj2
source.2=http:doc-files/expr.pj2
main.2=true
sink.2=applet
style.2=xml

jparsec

jparsec is a Java-based implementation of a combinator parser originally implemented in Haskell. It is similar to mops but much more elaborate. A jparsec element submits one or more sources for Java compilation and execution; alternatively, a jar element with basename='jparsec.jar' could be added to a javac element. The jparsec element can have Common attributes and sink. As discussed in Converting keys, processor attribute names require numerical suffixes if they are used as keys in a queryString. If compilation is successful the server responds with an applet page or Java Web Start for execution; otherwise a text page displays compilation errors or the Java code.

AttributeConstraintPurpose
sink applet, false, or jnlp if specified as applet or false by all processing steps, and as applet by at least one step, Java compilation is performed and should result in a page with an applet to be returned.

if specified as jnlp or false by all processing steps, and as jnlp by at least one step, Java compilation is performed and should result in a Java Web Start application to be returned.

if specified as applet or jnlp but Java compilation is not performed, the jparsec step will result in the original Java code only.

if specified as false causes the jparsec step to be ignored.


Examples
doc-files/18.job This job obtains the calculators doc-files/jparsec-1.java, doc-files/jparsec-2.java, and doc-files/jparsec-3.java by dereferencing partial URLs and returns an applet page to execute each calculator. Each calculator evaluates lines with arithmetic expressions.
processor.1=javac
source.1=http:doc-files/jparsec-1.java
sink.1=applet
processor.2=jparsec
source.2=http:doc-files/jparsec-2.java
sink.2=applet
processor.3=jparsec
source.3=http:doc-files/jparsec-3.java
sink.3=applet

Servlet configuration

The following init-param keys must be defined properly in web.xml:

Key Purpose
action path portion of the URL to reach the servlet.
css URL for stylesheet for HTML pages.
CUP head of command line for parser generator; several arguments may be separated by blanks.
CUP.name pattern to validate parser and symbols class name.
ea true to enable assertions when executing the applet.
expires positive int with expiration intervall for temporary result files in milliseconds.
jag head of command line for visitor generator; several arguments may be separated by blanks.
jar.level archive compression level.
jar.path pattern to validate runtime jar file names; should at least permit applet.jar.
jars absolute path to directory with (client) runtime jars; directory must contain applet.jar.
java absolute path to file with Java launcher.
javac.options blank-separated list of options; for compiler: -key value.. (number of values determined by compiler), for file manager: -key value.. (values without leading -).
j2seVersion JRE version to request for Java Web Start; should agree with javac.options.
javacc head of command line for parser generator; several arguments may be separated by blanks.
javascript URL for request page scripting.
jay head of command line for parser generator; several arguments may be separated by blanks.
JLex head of command line for (patched) scanner generator; several arguments may be separated by blanks.
mime.types pairs consisting of extension and MIME type to classify file response; words are separated by white space.
mops.jar absolute path to archive with preprocessor and runtime support.
mops.java parametrized command line to produce Java code.
mops.javascript parametrized command line to produce JavaScript code.
oops3.false.actions parametrized command line to show advisory actions interface for LL(1) parser.
oops3.false.follow parametrized command line to show parser tree with follow sets for LL(1) parser.
oops3.false.java parametrized command line to produce Java code for LL(1) parser.
oops3.false.JLex parametrized command line to show JLex code for LL(1) parser.
oops3.false.verbose parametrized command line to show parser tree with lookahead sets for LL(1) parser.
oops3.jar absolute path to archive with parser generator.
oops3.true.actions parametrized command line to show advisory actions interface for functional parser.
oops3.true.follow parametrized command line to show parser tree for functional parser.
oops3.true.java parametrized command line to produce Java code for functional parser.
oops3.true.JLex parametrized command line to show JLex code (even) for functional parser.
oops3.true.verbose parametrized command line to show parser tree for functional parser.
pj head of command line for preprocessor; several arguments may be separated by blanks.
pj2.jar absolute path to archive with parser generator.
pj2.java parametrized command line to produce Java code.
pj2.jay parametrized command line to produce jay code.
pj2.JLex parametrized command line to show JLex code.
pj2.recover flags to turn error recovery off.
pj2.verbose parametrized command line to show parser tables with jay.
reap if set, minimum number of minutes until an archive or other result file will be deleted.
result.path pattern to validate result file names.
target string with default target for request form.
tmpdir wcs-wide directory for temporary files, must exist.
vig head of command line for visitor generator; several arguments may be separated by blanks.
vig-trace head of command line for visitor generator with tracing enabled; several arguments may be separated by blanks.
wcsHome absolute URL of (descriptive) homepage of this service.
xv head of command line for XML visitor generator; several arguments may be separated by blanks.
xv-trace head of command line for XML visitor generator with tracing enabled; several arguments may be separated by blanks.

Filesystem structure

Path Purpose Configuration
jag.jar archive with visitor generator. jag
java-cup.jar archive with parser generator. CUP
javacc.jar archive with parser generator. javacc
jay parser generator. jay
JLex.jar archive with (patched) scanner generator. JLex
mops.jar archive with preprocessor and runtime support. mops.jar
oops3.jar archive with visitor generator. oops3.jar
pj.jar archive with preprocessor. pj
tmpdir/ root of web server's temporary files. tmpdir
jobXXXXX.htm result file with job's messages. result.path
jobXXXXX.html result file with job's applet page. result.path
jobXXXXX.jar result file with job's archive. result.path
jobXXXXX.jnlp result file with job's Java Web Start description. result.path
jobXXXXX/ work area for preprocessing and compilation of a single request; current directory and TMPDIR for jay and pj/pj2 preprocessing.
classes/ root of output of Java compilation prior to archiving.
package.class.ser serialized LL(1) parser from oops3.
javaccX/ work area for javacc.
class.java output from javacc and jjtree.
javaccX.html output from jjdoc.
javaccX.jj input for javacc and jjdoc, output from jjtree.
javaccX.jjt input for jjtree.
job.job final job document, see doc-files/job.dtd. reap
parser.rfc annotated grammar input file for pj2.
parser.xbnf annotated grammar input file for oops3.
parser.java Java code for parser generated by CUP. CUP.name
pj.scanner generated scanner code from pj preprocessing.
pj.tree generated tree factory from pj preprocessing.
symbols.java Java code for symbol definitions generated by CUP. CUP.name
y.input grammar input file for jay.
y.output grammar description from jay and pj/pj2 preprocessing.
yacc.XXXXXXX temporary files during jay (and therefore pj/pj2) preprocessing.
doc/ root of this documentation. make doc
wcs/doc-files/ generated directory containing all examples for this documentation (Originals are in source/doc-files/).
wcs.css stylesheet for generated HTML pages. css
wcs.js scripting for generated forms. This file contains a list of browsers which have been checked to work with the service. javascript
WEB-INF/ generated root of web application. make all
classes/ resources and class files for servlet. (Originals are in source/rsc/).
applet.xsl XSL script to create applet page.
form.xsl XSL script to create form page. This file contains a table of links which can be selected using the download attribute.
frameset.xsl XSL script to create frameset for applet and log page.
howto.xml default instructions for applet page.
jnlp.xml default instructions for Java Web Start page.
jnlp.xsl XSL script to create job's Java Web Start description.
log.xsl XSL script to create log page which may include instructions for Java Web Start and a link to download the result archive.
pj2.skeleton code template for pj2 preprocessing.
skeleton.java code template for jay.
System.java Java source code to redirect System to Applet.
wcs/ class files for servlet.
jars/ archives to support Java compilation and execution. They are requested with an (internally generated) jar step (see doc-files/job.dtd) and added to the compilation classpath and the applet archive. jars
applet.jar default applet execution environment.
file.jar compile/run time archive. jar.path
web.xml Servlet configuration. (Original is in source/web-platform.xml).

Installation

Use of wcs requires a web browser supporting forms, CSS level 1, and Javascript. To execute compiled programs the browser additionally must support the execution of Java 5 applets and/or Java Web Start descriptions (the servlet can be configured for some other versions).

Before wcs can be executed, the compiler tools supported by wcs must be available and installed (in particular, pj requires configuring). For each tool there is a subdirectory in the wcs distribution with a makefile which was used during development to download and install the tool. Each makefile should be reviewed prior to use.

There should be no version dependence between wcs and the tools. However, JLex was modified to operate as a filter and to simplify spoofing; the provided patch might be version dependent. Depending on the platform jay may have to be compiled from a source distribution or the Java version of jay has to be used.

Once all tools are available, the makefile for wcs should be inspected because it points to some of the tools. Compilation requires (at least) Java 6.

Deployment requires a servlet container such as tomcat or winstone. Before installation, web-platform.xml must be inspected because it points to almost all tools and it may depend on the servlet container.

The documentation should be served by a web server because it contains wcs requests. The top-level makefile is be used to create the entire documentation and localize the requests; it needs to contain a reference to the servlet container.

Extending the service

This implementation of wcs tries to have very loose coupling between the servlet, the job driver, and the processors for the individual processing steps. As a result it was fairly simple to support additional processors such as oops3 and CUP. Here is the check list which was followed in adding support for CUP:

Projects

Version:
2.1.0, Pittsford, December 2008.
Author:
Axel T. Schreiner. Support from a Provost's Learning Innovation Grant at Rochester Institute of Technology for version 1 is gratefully acknowledged.


(c) 2008 Axel T. Schreiner