summaryrefslogtreecommitdiffstats
path: root/parser/html/java/htmlparser/mozilla-export-scripts
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-01-15 14:56:04 -0500
committerMatt A. Tobin <email@mattatobin.com>2020-01-15 14:56:04 -0500
commit6168dbe21f5f83b906e562ea0ab232d499b275a6 (patch)
tree658a4b27554c85ebcaad655fc83f2c2bb99e8e80 /parser/html/java/htmlparser/mozilla-export-scripts
parent09314667a692fedff8564fc347c8a3663474faa6 (diff)
downloadUXP-6168dbe21f5f83b906e562ea0ab232d499b275a6.tar
UXP-6168dbe21f5f83b906e562ea0ab232d499b275a6.tar.gz
UXP-6168dbe21f5f83b906e562ea0ab232d499b275a6.tar.lz
UXP-6168dbe21f5f83b906e562ea0ab232d499b275a6.tar.xz
UXP-6168dbe21f5f83b906e562ea0ab232d499b275a6.zip
Add java htmlparser sources that match the original 52-level state
https://hg.mozilla.org/projects/htmlparser/ Commit: abe62ab2a9b69ccb3b5d8a231ec1ae11154c571d
Diffstat (limited to 'parser/html/java/htmlparser/mozilla-export-scripts')
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/README.txt25
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/export-all.sh24
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/export-java-srcs.sh25
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/export-translator.sh24
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/make-translator-jar.sh63
-rw-r--r--parser/html/java/htmlparser/mozilla-export-scripts/util.sh23
6 files changed, 184 insertions, 0 deletions
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/README.txt b/parser/html/java/htmlparser/mozilla-export-scripts/README.txt
new file mode 100644
index 000000000..3567b846c
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/README.txt
@@ -0,0 +1,25 @@
+These scripts export the Java-to-C++ translator and the java source files that
+implement the HTML5 parser. The exported translator may be used (with no
+external dependencies) to translate the exported java source files into Gecko-
+compatible C++.
+
+Hacking the translator itself still requires a working copy of the Java HTML5
+parser repository, but hacking the parser (modifying the Java source files and
+performing the translation) should now be possible using only files committed
+to the mozilla source tree.
+
+Run any of these scripts without arguments to receive usage instructions.
+
+ make-translator-jar.sh: compiles the Java-to-C++ translator into a .jar file
+ export-java-srcs.sh: exports minimal java source files implementing the
+ HTML5 parser
+ export-translator.sh: exports the compiled translator and javaparser.jar
+ export-all.sh: runs the previous two scripts
+ util.sh: provides various shell utility functions to the
+ scripts listed above (does nothing if run directly)
+
+All path arguments may be either absolute or relative. This includes the path
+to the script itself ($0), so the directory from which you run these scripts
+doesn't matter.
+
+Ben Newman (7 July 2009)
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/export-all.sh b/parser/html/java/htmlparser/mozilla-export-scripts/export-all.sh
new file mode 100644
index 000000000..9ae07d33d
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/export-all.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env sh
+
+SCRIPT_DIR=`dirname $0`
+source $SCRIPT_DIR/util.sh
+SCRIPT_DIR=`abs $SCRIPT_DIR`
+
+if [ $# -eq 1 ]
+then
+ MOZ_PARSER_PATH=`abs $1`
+else
+ echo
+ echo "Usage: sh `basename $0` /path/to/mozilla-central/parser/html"
+ echo "Note that relative paths will work just fine."
+ echo
+ exit 1
+fi
+
+$SCRIPT_DIR/export-translator.sh $MOZ_PARSER_PATH
+$SCRIPT_DIR/export-java-srcs.sh $MOZ_PARSER_PATH
+
+echo
+echo "Now go to $MOZ_PARSER_PATH and run"
+echo " java -jar javalib/translator.jar javasrc . nsHtml5AtomList.h"
+echo
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/export-java-srcs.sh b/parser/html/java/htmlparser/mozilla-export-scripts/export-java-srcs.sh
new file mode 100644
index 000000000..6d32b07da
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/export-java-srcs.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env sh
+
+SCRIPT_DIR=`dirname $0`
+source $SCRIPT_DIR/util.sh
+SCRIPT_DIR=`abs $SCRIPT_DIR`
+
+SRCDIR=`abs $SCRIPT_DIR/../src/nu/validator/htmlparser/impl`
+
+if [ $# -eq 1 ]
+then
+ MOZ_PARSER_PATH=`abs $1`
+else
+ echo
+ echo "Usage: sh `basename $0` /path/to/mozilla-central/parser/html"
+ echo "Note that relative paths will work just fine."
+ echo
+ exit 1
+fi
+
+SRCTARGET=$MOZ_PARSER_PATH/javasrc
+
+rm -rf $SRCTARGET
+mkdir $SRCTARGET
+# Avoid copying the .svn directory:
+cp -rv $SRCDIR/*.java $SRCTARGET
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/export-translator.sh b/parser/html/java/htmlparser/mozilla-export-scripts/export-translator.sh
new file mode 100644
index 000000000..d1f4f1c39
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/export-translator.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env sh
+
+SCRIPT_DIR=`dirname $0`
+source $SCRIPT_DIR/util.sh
+SCRIPT_DIR=`abs $SCRIPT_DIR`
+
+LIBDIR=`abs $SCRIPT_DIR/../translator-lib`
+
+if [ $# -eq 1 ]
+then
+ MOZ_PARSER_PATH=`abs $1`
+else
+ echo
+ echo "Usage: sh `basename $0` /path/to/mozilla-central/parser/html"
+ echo "Note that relative paths will work just fine."
+ echo "Be sure that you have run `dirname $0`/make-translator-jar.sh before running this script."
+ echo
+ exit 1
+fi
+
+LIBTARGET=$MOZ_PARSER_PATH/javalib
+
+rm -rf $LIBTARGET
+cp -rv $LIBDIR $LIBTARGET
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/make-translator-jar.sh b/parser/html/java/htmlparser/mozilla-export-scripts/make-translator-jar.sh
new file mode 100644
index 000000000..4f21ae665
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/make-translator-jar.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env sh
+
+SCRIPT_DIR=`dirname $0`
+source $SCRIPT_DIR/util.sh
+SCRIPT_DIR=`abs $SCRIPT_DIR`
+
+SRCDIR=`abs $SCRIPT_DIR/../translator-src`
+BINDIR=`abs $SCRIPT_DIR/../translator-bin`
+LIBDIR=`abs $SCRIPT_DIR/../translator-lib`
+
+if [ $# -eq 1 ]
+then
+ JAVAPARSER_JAR_PATH=`abs $1`
+else
+ echo
+ echo "Usage: sh `basename $0` /path/to/javaparser-1.0.7.jar"
+ echo "Note that relative paths will work just fine."
+ echo "Obtain javaparser-1.0.7.jar from http://code.google.com/p/javaparser"
+ echo
+ exit 1
+fi
+
+set_up() {
+ rm -rf $BINDIR; mkdir $BINDIR
+ rm -rf $LIBDIR; mkdir $LIBDIR
+ cp $JAVAPARSER_JAR_PATH $LIBDIR/javaparser.jar
+}
+
+write_manifest() {
+ rm -f $LIBDIR/manifest
+ echo "Main-Class: nu.validator.htmlparser.cpptranslate.Main" > $LIBDIR/manifest
+ echo "Class-Path: javaparser.jar" >> $LIBDIR/manifest
+}
+
+compile_translator() {
+ find $SRCDIR -name "*.java" | \
+ xargs javac -cp $LIBDIR/javaparser.jar -g -d $BINDIR
+}
+
+generate_jar() {
+ jar cvfm $LIBDIR/translator.jar $LIBDIR/manifest -C $BINDIR .
+}
+
+clean_up() {
+ rm -f $LIBDIR/manifest
+}
+
+success_message() {
+ echo
+ echo "Successfully generated directory \"$LIBDIR\" with contents:"
+ echo
+ ls -al $LIBDIR
+ echo
+ echo "Now run `dirname $0`/export-all.sh with no arguments and follow the usage instructions."
+ echo
+}
+
+set_up && \
+ compile_translator && \
+ write_manifest && \
+ generate_jar && \
+ clean_up && \
+ success_message
diff --git a/parser/html/java/htmlparser/mozilla-export-scripts/util.sh b/parser/html/java/htmlparser/mozilla-export-scripts/util.sh
new file mode 100644
index 000000000..348ca14f9
--- /dev/null
+++ b/parser/html/java/htmlparser/mozilla-export-scripts/util.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env sh
+
+abs() {
+ local rel
+ local p
+ if [ $# -ne 1 ]
+ then
+ rel=.
+ else
+ rel=$1
+ fi
+ if [ -d $rel ]
+ then
+ pushd $rel > /dev/null
+ p=`pwd`
+ popd > /dev/null
+ else
+ pushd `dirname $rel` > /dev/null
+ p=`pwd`/`basename $rel`
+ popd > /dev/null
+ fi
+ echo $p
+}