parseMain.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
class ResourceWriter {
public ResourceWriter(BufferedWriter w) {
theWriter = w;
}
public void close() throws IOException {
}
}
}
public void fileheader() throws IOException {
writenl("/* ");
writenl(" * GENERATED CODE");
writenl(" *");
writenl(" * Copyright 1999 Sun Microsystems, Inc.");
writenl(" * All rights reserved.");
writenl(" *");
writenl(" */");
writenl("");
writenl("package com.sun.admin.pm.client;");
writenl("import java.util.*;");
}
" extends ListResourceBundle {");
"static final Object[][] pmHelpBundlecontents = {");
}
public void footer() throws IOException {
writenl("}");
}
}
}
}
}
}
}
}
}
}
return;
while (e.hasMoreElements()) {
if (s.length() == 0) {
if (e.hasMoreElements())
continue;
else {
break;
}
}
" +" :
"\n },");
}
}
public void delimiter() throws IOException {
}
public void commentStart() throws IOException {
}
public void commentEnd() throws IOException {
}
writenl(COMMENTLINE_START + s);
}
}
class Article {
Reader r;
r = theReader;
try {
while (true) {
theTag = readNextTag();
if (theTag instanceof CommentTag) {
} else if (theTag instanceof ContentTag) {
} else if (theTag instanceof SeeAlsoTag) {
} else if (theTag instanceof KeywordsTag) {
} else {
}
}
} catch (IOException x) {
}
}
int localread() throws IOException {
if (ch == -1) {
throw new IOException();
}
// Debug.message("localread: " + ch);
return ch;
}
/*
*/
int ch;
StringBuffer b = new StringBuffer();
while (true)
break;
while (true) {
break;
else
}
}
int ch;
StringBuffer b;
rv = new KeywordsTag();
rv = new SeeAlsoTag();
rv = new ContentTag();
rv.readMultipleLines(r);
} else {
}
return rv;
}
"> Keywords <" + theKeywords +
"> See-Also <" + theSeeAlso +
}
}
class HelpSyntax {
public final static int tagOpen = '<';
public final static int tagClose = '>';
}
class ParseException extends Exception {
}
class BadTagException extends ParseException {
}
class SyntaxErrorException extends ParseException {
}
abstract class Tag {
protected boolean escapeQuotes = false;
content = s;
}
public Tag() {
this(null);
}
}
// respect line spacing, stuff contentVector
int ch;
StringBuffer b = new StringBuffer();
boolean spaced = false;
while (true) {
if (ch == -1)
break;
if (ch == '\n') {
v.addElement(new String(b));
b = new StringBuffer();
continue;
}
if (spaced == false) {
b.append(" ");
spaced = true;
}
continue;
}
b.append("\\\"");
continue;
}
spaced = false;
boolean localspaced = false;
boolean localopen = true;
if (localspaced == false) {
localspaced = true;
}
continue;
}
}
break;
} else {
b.append(t);
}
} else {
}
}
contentVector = v;
}
// catenate input lines, eliminating whitespace
int ch;
StringBuffer b = new StringBuffer();
boolean spaced = false;
while (true) {
if (ch == -1)
break;
if (spaced == false) {
b.append(" ");
spaced = true;
}
continue;
}
b.append("\\\"");
continue;
}
spaced = false;
boolean localspaced = false;
boolean localopen = true;
if (localspaced == false) {
localspaced = true;
}
continue;
}
}
break;
} else {
b.append(t);
}
} else {
}
}
}
}
public TitleTag() {
}
}
class SeeAlsoTag extends Tag {
public SeeAlsoTag() {
}
}
class ContentTag extends Tag {
public ContentTag() {
escapeQuotes = true;
}
}
class CommentTag extends Tag {
public CommentTag() {
}
}
class KeywordsTag extends Tag {
public KeywordsTag() {
escapeQuotes = true;
}
}
class parseMain {
static int firstFile = 0;
// returns -1 if error, 0 otherwise
int rv = 0;
int i;
} else {
outputFileName = args[++i];
}
} else {
commentFileName = args[++i];
}
} else
break; // unknown arg ==> list of files starts
}
firstFile = i;
/*
* System.out.println("outputFileName = " + outputFileName +
* " commentFileName = " + commentFileName +
* " firstFile = " + firstFile);
*/
return rv;
}
FileReader f = null;
// validate command line
}
try {
// create output file
// imports and package statement
rw.fileheader();
// comment block
if (commentFile.exists()) {
rw.commentStart();
rw.commentEnd();
} else {
" not found.");
}
// create class name w/o extension or leading path
// class name is output filename w/o extension
if (dotIndex < 0)
// class definition
// iterate over input files
try {
f = new FileReader(filename);
} catch (Exception x) {
return;
}
BufferedReader r = new BufferedReader(f);
a.read(r);
// System.out.println(a);
// process the Article
// HTML syntax checking on content
if (!validHTMLSyntax(a.theContent))
throw new IOException(
"Bad HTML syntax in article " + tagName);
}
w.close();
} catch (IOException x) {
// try to unlink the broken output file
boolean unlink = true;
try {
} catch (IOException xx) {
unlink = false;
}
if (unlink) {
}
}
}
// return true if no syntax errors found
static boolean validHTMLSyntax(String s) {
if (s == null)
return true;
// check only for <b>..</b> pairs
int i;
int opens = 0;
i != -1;
++opens;
int closes = 0;
i != -1;
++closes;
// System.out.println("syntax: " + opens + " " + closes);
}
// return true if no syntax errors found
static boolean validHTMLSyntax(Vector v) {
Enumeration e = v.elements();
while (e.hasMoreElements())
s = s + (String) e.nextElement();
return validHTMLSyntax(s);
}
/*
* extract the tag name from a filename, possibly containing
* a fully qualified path as well as a complex extension.
*/
// the help tag is the filename exclusive of path or extensions
// System.out.println("filename: " + s);
if (period < 0)
// System.out.println("period = " + period);
}
}
class Debug {
/**
* Log a highest-priority message.
* @param String s The message to be logged.
*/
}
/**
* Log a highest-priority message.
* @param String s The message to be logged.
*/
}
/**
* Log a highest-priority message.
* @param String s The message to be logged.
*/
}
/**
* Log a highest-priority message.
* @param String s The message to be logged.
*/
}
/**
* Log a highest-priority message.
* @param String s The message to be logged.
*/
static public void setDebugLevel(int lvl) {
return;
}
if (lvl < globalDebugLevel)
return;
DebugPrint(s);
}
// here is where we could hide syslog or file destination...
private static void DebugPrint(String s) {
}
/**
* Verbosity level to suppress all messages.
*/
static public final int NONE = 5;
/**
* Verbosity level to log only highest-priority messages.
*/
static public final int FATAL = 4;
/**
* Verbosity level to log high- and highest-priority messages.
*/
static public final int ERROR = 3;
/**
* Verbosity level to log medium-, high-, and
* highest-priority messages.
*/
static public final int WARNING = 2;
/**
* Verbosity level to log low-, medium-, high-, and
* highest-priority messages.
*/
static public final int MESSAGE = 1;
/**
* Verbosity level to log all messages.
*/
static public final int ALL = 0;
private static int globalDebugLevel = ERROR;
}