hlship 2004/05/21 11:46:57
Modified: . .classpath
common jar-module.xml common.xml
framework build.xml
Added: framework/src/javacc SimpleDataLanguageParser.jj
. build.xml
common project.xml
Removed: framework/src/javacc SimpleDataLanguage.jj
Log:
Add project.xml and a top-level build.xml to use it.
Revision Changes Path
1.1
jakarta-hivemind/framework/src/javacc/SimpleDataLanguageParser.jj
Index: SimpleDataLanguageParser.jj
===================================================================
// $Id: SimpleDataLanguageParser.jj,v 1.1 2004/05/21 18:46:54 hlship Exp $
options
{
STATIC = false;
DEBUG_PARSER = false;
DEBUG_TOKEN_MANAGER = false;
}
PARSER_BEGIN(SimpleDataLanguageParser)
// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.hivemind.sdl.parser;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
public class SimpleDataLanguageParser
{
private ContentHandler _handler;
private SDLLocator _locator = new SDLLocator();
private boolean _firstElement = true;
private void handleException(SAXException ex)
throws ParseException
{
throw new SystemParseException(ex);
}
/**
* Returns the locator used by this parser instance; which is needed to
generate
* SAXParseExceptions in SDLResourceParser.
*/
public Locator getLocator()
{
return _locator;
}
private void updateLocator()
{
_locator.update(token.beginLine, token.beginColumn);
}
private void fireStartDocument() throws ParseException
{
try { _handler.startDocument(); }
catch (SAXException ex) { handleException(ex); }
}
private void fireEndDocument() throws ParseException
{
try { _handler.endDocument(); }
catch (SAXException ex) { handleException(ex); }
}
private void fireStartElement(String elementName, Attributes
attributes) throws ParseException
{
// No namespace, no qualified name
try { _handler.startElement(null, elementName, null,
attributes); }
catch (SAXException ex) { handleException(ex); }
}
private void fireEndElement(String elementName) throws ParseException
{
// No namespace, no qualified name
try { _handler.endElement(null, elementName, elementName); }
catch (SAXException ex) { handleException(ex); }
}
private void fireCharacters(String string) throws ParseException
{
try { _handler.characters(string.toCharArray(), 0, string.length()); }
catch (SAXException ex) { handleException(ex); }
}
private void fireCharactersForExtendedLiteral(String string) throws
ParseException
{
try
{
_handler.characters(string.toCharArray(), 2, string.length() - 4);
}
catch (SAXException ex) { handleException(ex); }
}
private void addAttribute(AttributesImpl attributes, String name,
String value)
{
attributes.addAttribute(null, name, name, "CDATA", value);
}
private String unquote(String input)
{
StringBuffer buffer = new StringBuffer(input.length());
char[] chars = input.toCharArray();
int state = 0;
for (int i = 1; i < chars.length - 1; i++)
{
char ch = chars[i];
switch (state)
{
case 0:
if (ch == '\\')
{
state = 1;
continue;
}
buffer.append(ch);
continue;
case 1:
state = 0;
if (ch == '\\' || ch == '"') {
buffer.append(ch); continue; }
if (ch == 'n') { buffer.append('\n'); continue;
}
if (ch == 't') { buffer.append('\t'); continue;
}
if (ch == 'r') { buffer.append('\r'); continue;
}
buffer.append('\\');
buffer.append(ch);
default:
}
}
// state == 1 means a slash just before the end of the string.
// Is this the right thing to do?
if (state == 1) buffer.append('\\');
return buffer.toString();
}
// Removes the "<<" and ">>" from an extended literal string.
private String defang(String input)
{
int length = input.length();
return input.substring(2, length - 2);
}
}
PARSER_END(SimpleDataLanguageParser)
/* Standard whitespace to ignore between tokens. */
SKIP :
{
" "
| "\t"
| "\n"
| "\r"
}
/* This is interesting; order is important (first match wins). <LITERAL>
needs to be ahead of <NUMERIC_LITERAL> and friends or you get an error. */
TOKEN :
{
< NUMERIC_LITERAL: (<SIGN>)? ( ((<DIGIT>)+ (<DOT>)?) | ((<DIGIT>)* <DOT>
(<DIGIT>)+) ) >
| < SIMPLE_ID: ["a" - "z", "A" - "Z", "_"] ( [ "a" - "z", "A" - "Z", "0" -
"9", "_", "-"] )* >
| < COMPLEX_ID: <SIMPLE_ID> ( <DOT> <SIMPLE_ID> )*>
| < QUOTED_LITERAL: <QUOTE> ((~["\""]) | ("\\" ["\"", "\\", "n", "r",
"t"]))* <QUOTE> >
| < EXTENDED_LITERAL: "<<" ( (~[">"]) | ( ">" ~[">"]) )* ">>" >
// Ant-syntax symbol.
| < SYMBOL: "${" <COMPLEX_ID> "}" >
| < #DIGIT: ["0" - "9"] >
| < #SIGN: ("+" | "-") >
| < OPAREN: "(" >
| < CPAREN: ")" >
| < OBRACE: "{" >
| < CBRACE: "}" >
| < EQ: "=" >
| < #QUOTE: "\"" >
| < #DOT: "." >
}
SKIP:
{
"//": SINGLE_LINE_COMMENT
| "/*": MULTILINE_COMMENT
}
<EXTRACTING_QUOTED_LITERAL> SKIP:
{
"\"": DEFAULT
}
<SINGLE_LINE_COMMENT> SKIP:
{
< ["\n", "\r"] > : DEFAULT
| < ~[] >
}
<MULTILINE_COMMENT> SKIP:
{
"*/": DEFAULT
| < ~[] >
}
/**
* Parses an SDL document from a stream provided in the constructor. An
instance
* of SimpleDataLanguageParser should be used once and then discarded ... it
will
* be left in an unknown state after parsing a stream (especially if an error
* occurs).
*
*/
void parse(ContentHandler handler) :
{
_handler = handler;
}
{
{
// setDocumentLocator() is invoked once, before any other method
// is invoked.
_handler.setDocumentLocator(_locator);
}
element() { fireEndDocument(); } <EOF>
}
void element() :
{
String elementName;
AttributesImpl attributes = new AttributesImpl();
}
{
<SIMPLE_ID>
{
updateLocator();
elementName = token.image;
if (_firstElement)
{
fireStartDocument();
_firstElement = false;
}
}
(element_attributes(attributes))?
{
fireStartElement(elementName, attributes); }
(element_body())? { updateLocator();
fireEndElement(elementName); }
}
void element_attributes(AttributesImpl attributes) : {}
{
(<OPAREN> (attribute(attributes))* <CPAREN>)
}
void attribute(AttributesImpl attributes) :
{
String attributeName;
}
{
<SIMPLE_ID> { attributeName = token.image; }
<EQ> attribute_value(attributeName, attributes)
}
void attribute_value(String attributeName, AttributesImpl attributes) : {}
{
( <NUMERIC_LITERAL> | <SIMPLE_ID> | <COMPLEX_ID> | <SYMBOL>) {
addAttribute(attributes, attributeName, token.image); }
| <QUOTED_LITERAL> { addAttribute(attributes, attributeName,
unquote(token.image)); }
| <EXTENDED_LITERAL> { addAttribute(attributes, attributeName,
defang(token.image)); }
}
void element_body() : {}
{
<OBRACE> (body_content())* <CBRACE>
}
void body_content() : {}
{
element()
| <QUOTED_LITERAL> { fireCharacters(unquote(token.image)); }
// A <SIMPLE_ID> may not be a literal, since it will look like a new
element.
| ( <COMPLEX_ID> | <NUMERIC_LITERAL> | <SYMBOL> ) {
fireCharacters(token.image); }
| <EXTENDED_LITERAL> { fireCharactersForExtendedLiteral(token.image); }
}
1.29 +1 -1 jakarta-hivemind/.classpath
Index: .classpath
===================================================================
RCS file: /home/cvs/jakarta-hivemind/.classpath,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- .classpath 20 May 2004 23:57:44 -0000 1.28
+++ .classpath 21 May 2004 18:46:54 -0000 1.29
@@ -19,7 +19,7 @@
<classpathentry kind="lib" path="ext-package/lib/oro-2.0.6.jar"/>
<classpathentry kind="lib" path="ext-package/lib/servletapi-2.3.jar"/>
<classpathentry kind="lib" path="ext-package/lib/werkz-1.0-beta-10.jar"/>
- <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
+ <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"
sourcepath="ANT_HOME/apache-ant-1.6.1-src.zip"/>
<classpathentry kind="var" path="ANT_HOME/lib/xercesImpl.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/xml-apis.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/junit-3.8.1.jar"/>
1.3 +26 -202 jakarta-hivemind/build.xml
1.2 +9 -4 jakarta-hivemind/common/jar-module.xml
Index: jar-module.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/common/jar-module.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jar-module.xml 20 May 2004 23:57:44 -0000 1.1
+++ jar-module.xml 21 May 2004 18:46:54 -0000 1.2
@@ -101,7 +101,7 @@
<echo>
-*** Compiling Java source to ${java.classes.dir}...
+*** Compiling Java sources to ${java.classes.dir}...
</echo>
<javac
@@ -140,7 +140,7 @@
<attribute name="classpath-id" default="default.test.classpath"
description="Reference to path used for tests."/>
<attribute name="fork" default="off" description="Run the tests
in a seperate JVM if on."/>
- <element name="junit-elements"/>
+ <element name="junit-elements" optional="true"
description="Additional elements places within the junit task."/>
<sequential>
<mkdir dir="${junit.temp.dir}"/>
@@ -169,7 +169,9 @@
<exclude
name="**/*$*.class"/>
<include
name="**/Test*.class"/>
</fileset>
- </batchtest>
+ </batchtest>
+
+ <junit-elements/>
</junit>
<fail if="junit-failure" message="Some tests failed."/>
@@ -261,5 +263,8 @@
<target name="javadoc" depends="-compile-init" description="Create
JavaDoc from Java source files.">
<default-javadoc/>
</target>
+
+ <target name="install" depends="jar"
+ description="Synonum for 'jar' invoked by the containing
project."/>
</project>
1.2 +4 -1 jakarta-hivemind/common/common.xml
Index: common.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/common/common.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- common.xml 20 May 2004 23:57:44 -0000 1.1
+++ common.xml 21 May 2004 18:46:54 -0000 1.2
@@ -22,6 +22,9 @@
<dirname property="common.dir" file="${ant.file.common}"/>
+ <!-- Hm. To reuse these files across different projects, may need a
split here between the
+ "build scripts" directory and each project's "common"
directory. -->
+
<property file="${common.dir}/common.properties"/>
<property file="${common.dir}/version.properties"/>
1.1 jakarta-hivemind/common/project.xml
Index: project.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: project.xml,v 1.1 2004/05/21 18:46:54 hlship Exp $ -->
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="project">
<!-- Top level module used to combine other types of modules. -->
<import file="common.xml"/>
<macrodef name="reinvoke-ant">
<attribute name="target" description="Target to achieve in each
module."/>
<attribute name="files" default="project.modules"
description="List of build.xml's, in build order."/>
<element name="parameters" optional="true"
description="Parameters passed to the subant task."/>
<sequential>
<subant target="@{target}" inheritall="false">
<filelist refid="@{files}"/>
<parameters/>
</subant>
</sequential>
</macrodef>
<target name="install" description="Reinvokes install in each module.">
<reinvoke-ant target="install"/>
</target>
<target name="clean" description="Deletes all derived files in the
project and in each module.">
<reinvoke-ant target="clean"/>
<antcall target="common.clean"/>
</target>
</project>
1.2 +11 -3 jakarta-hivemind/framework/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/build.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build.xml 20 May 2004 23:57:44 -0000 1.1
+++ build.xml 21 May 2004 18:46:55 -0000 1.2
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project name="HiveMind Framework" default="jar">
+<project name="HiveMind Framework" default="jar" basedir=".">
<property name="jar.name" value="hivemind"/>
<property name="javadoc.package" value="org.apache.hivemind.*"/>
@@ -34,9 +34,17 @@
<ibiblio-dependency jar="easymock-1.1.jar" group-id="easymock"
use="test"/>
- <run-javacc input="${javacc.src.dir}/SimpleDataLanguage.jj"
package-path="org/apache/hivemind/sdl/parser"/>
+ <run-javacc
input="${javacc.src.dir}/SimpleDataLanguageParser.jj"
package-path="org/apache/hivemind/sdl/parser"/>
<default-compile/>
</target>
+ <target name="run-tests" description="Runs JUnit tests."
depends="compile-tests">
+ <default-run-tests>
+ <junit-elements>
+ <!-- Adjust for wrong current directory when
framework/build.xml invoked from the project. -->
+ <sysproperty key="FRAMEWORK_ROOT"
value="${basedir}/"/>
+ </junit-elements>
+ </default-run-tests>
+ </target>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]