From 057d964561562fe4166d1c01e1f3553206693443 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Sun, 5 Oct 2014 18:06:06 +0900 Subject: [PATCH] forked from jhighlight 1.0 --- .gitignore | 7 + COPYING | 8 + LICENSE_CDDL.txt | 385 ++++++ LICENSE_LGPL.txt | 20 + README.md | 10 + pom.xml | 86 ++ .../java/com/uwyn/jhighlight/JHighlight.java | 253 ++++ .../uwyn/jhighlight/JHighlightVersion.java | 91 ++ .../JHighlightVersionSingleton.java | 18 + .../highlighter/CppHighlighter.flex | 395 ++++++ .../highlighter/CppHighlighter.java | 1228 +++++++++++++++++ .../highlighter/ExplicitStateHighlighter.java | 47 + .../highlighter/GroovyHighlighter.flex | 301 ++++ .../highlighter/GroovyHighlighter.java | 962 +++++++++++++ .../highlighter/JavaHighlighter.flex | 283 ++++ .../highlighter/JavaHighlighter.java | 953 +++++++++++++ .../highlighter/XmlHighlighter.flex | 274 ++++ .../highlighter/XmlHighlighter.java | 899 ++++++++++++ .../pcj/AbstractCharCollection.java | 208 +++ .../uwyn/jhighlight/pcj/CharCollection.java | 250 ++++ .../com/uwyn/jhighlight/pcj/CharIterator.java | 71 + .../jhighlight/pcj/hash/CharHashFunction.java | 51 + .../pcj/hash/DefaultCharHashFunction.java | 49 + .../com/uwyn/jhighlight/pcj/hash/Primes.java | 144 ++ .../pcj/map/AbstractCharKeyMap.java | 215 +++ .../uwyn/jhighlight/pcj/map/CharKeyMap.java | 193 +++ .../pcj/map/CharKeyMapIterator.java | 104 ++ .../pcj/map/CharKeyOpenHashMap.java | 974 +++++++++++++ .../uwyn/jhighlight/pcj/map/MapDefaults.java | 101 ++ .../pcj/map/NoSuchMappingException.java | 48 + .../jhighlight/pcj/set/AbstractCharSet.java | 64 + .../com/uwyn/jhighlight/pcj/set/CharSet.java | 34 + .../com/uwyn/jhighlight/pcj/util/Display.java | 89 ++ .../uwyn/jhighlight/pcj/util/Exceptions.java | 201 +++ .../jhighlight/renderer/CppXhtmlRenderer.java | 120 ++ .../renderer/GroovyXhtmlRenderer.java | 114 ++ .../renderer/JavaXhtmlRenderer.java | 117 ++ .../uwyn/jhighlight/renderer/Renderer.java | 58 + .../jhighlight/renderer/XhtmlRenderer.java | 325 +++++ .../renderer/XhtmlRendererFactory.java | 89 ++ .../jhighlight/renderer/XmlXhtmlRenderer.java | 120 ++ .../jhighlight/servlet/HighlightFilter.java | 236 ++++ .../uwyn/jhighlight/tools/ExceptionUtils.java | 61 + .../com/uwyn/jhighlight/tools/FileUtils.java | 141 ++ .../uwyn/jhighlight/tools/StringUtils.java | 706 ++++++++++ .../exceptions/FileUtilsErrorException.java | 29 + src/main/resources/JHIGHLIGHT_VERSION | 1 + src/main/resources/jhighlight.properties | 154 +++ 48 files changed, 11287 insertions(+) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 LICENSE_CDDL.txt create mode 100644 LICENSE_LGPL.txt create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/com/uwyn/jhighlight/JHighlight.java create mode 100644 src/main/java/com/uwyn/jhighlight/JHighlightVersion.java create mode 100644 src/main/java/com/uwyn/jhighlight/JHighlightVersionSingleton.java create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.flex create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.java create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/ExplicitStateHighlighter.java create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.flex create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.java create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.flex create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.java create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.flex create mode 100644 src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/AbstractCharCollection.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/CharCollection.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/CharIterator.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/hash/CharHashFunction.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/hash/DefaultCharHashFunction.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/hash/Primes.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/AbstractCharKeyMap.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMap.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMapIterator.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyOpenHashMap.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/MapDefaults.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/map/NoSuchMappingException.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/set/AbstractCharSet.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/set/CharSet.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/util/Display.java create mode 100644 src/main/java/com/uwyn/jhighlight/pcj/util/Exceptions.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/CppXhtmlRenderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/GroovyXhtmlRenderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/JavaXhtmlRenderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/Renderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/XhtmlRenderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/XhtmlRendererFactory.java create mode 100644 src/main/java/com/uwyn/jhighlight/renderer/XmlXhtmlRenderer.java create mode 100644 src/main/java/com/uwyn/jhighlight/servlet/HighlightFilter.java create mode 100644 src/main/java/com/uwyn/jhighlight/tools/ExceptionUtils.java create mode 100644 src/main/java/com/uwyn/jhighlight/tools/FileUtils.java create mode 100644 src/main/java/com/uwyn/jhighlight/tools/StringUtils.java create mode 100644 src/main/java/com/uwyn/jhighlight/tools/exceptions/FileUtilsErrorException.java create mode 100644 src/main/resources/JHIGHLIGHT_VERSION create mode 100644 src/main/resources/jhighlight.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f05707a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/target +/bin +/work +.settings +.classpath +.project +.idea diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..0443ce8 --- /dev/null +++ b/COPYING @@ -0,0 +1,8 @@ +JHighlight is Copyright (C) 2000-2006 +* Omnicore Software, Hans Kratz & Dennis Strein GbR, +* Geert Bevin +* Arnout Engelen + +It is distributed under the terms of either: +- the common development and distribution license (CDDL), v1.0; or +- the GNU Lesser General Public License, v2.1 or later diff --git a/LICENSE_CDDL.txt b/LICENSE_CDDL.txt new file mode 100644 index 0000000..dde88e3 --- /dev/null +++ b/LICENSE_CDDL.txt @@ -0,0 +1,385 @@ + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + + + 1. Definitions. + + 1.1. 'Contributor' means each individual or entity that + creates or contributes to the creation of Modifications. + + 1.2. 'Contributor Version' means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + + 1.3. 'Covered Software' means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + + 1.4. 'Executable' means the Covered Software in any form + other than Source Code. + + 1.5. 'Initial Developer' means the individual or entity + that first makes Original Software available under this + License. + + 1.6. 'Larger Work' means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + + 1.7. 'License' means this document. + + 1.8. 'Licensable' means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + + 1.9. 'Modifications' means the Source Code and Executable + form of any of the following: + + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + + B. Any new file that contains any part of the + Original Software or previous Modification; or + + C. Any new file that is contributed or otherwise made + available under the terms of this License. + + 1.10. 'Original Software' means the Source Code and + Executable form of computer software code that is + originally released under this License. + + 1.11. 'Patent Claims' means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + + 1.12. 'Source Code' means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + + 1.13. 'You' (or 'Your') means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, 'You' + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, 'control' means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + + 2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + + + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + + 3. Distribution Obligations. + + 3.1. Availability of Source Code. + + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + + 3.2. Modifications. + + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + + 3.3. Required Notices. + + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipientsÕ + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + + + 3.5. Distribution of Executable Versions. + + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipientÕs rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + + 3.6. Larger Works. + + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + + 4. Versions of the License. + + 4.1. New Versions. + + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + + 4.2. Effect of New Versions. + + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + + 4.3. Modified Versions. + + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + + + 5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN 'AS IS' + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + + 6. TERMINATION. + + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as 'Participant') + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + + 7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTYÕS NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + + 8. U.S. GOVERNMENT END USERS. + + The Covered Software is a 'commercial item,' as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of 'commercial + computer software' (as that term is defined at 48 C.F.R. ¤ + 252.227-7014(a)(1)) and 'commercial computer software + documentation' as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + + 9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdictionÕs conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneysÕ fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + + 10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. diff --git a/LICENSE_LGPL.txt b/LICENSE_LGPL.txt new file mode 100644 index 0000000..8365aea --- /dev/null +++ b/LICENSE_LGPL.txt @@ -0,0 +1,20 @@ +RIFE, + +Copyright 2001-2006 Geert Bevin , + +Distributed under the GNU Lesser General Public License v2.1. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Distributed under the GNU General Public License v2 or later. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dff1433 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +JHighlight +================== + +## Overview + +JHighlight is an embeddable pure Java syntax highlighting library that supports Java, HTML, XHTML, XML and LZX languages and outputs to XHTML. +It also supports RIFE templates tags and highlights them clearly so that you can easily identify the difference between your RIFE markup and the actual marked up source. + +This project is forked from https://jhighlight.dev.java.net/ to fix several bugs. + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fc6e16c --- /dev/null +++ b/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + org.codelibs + jhighlight + 1.0.1-SNAPSHOT + jar + JHighlight + JHighlight is an embeddable pure Java syntax highlighting library + that supports Java, HTML, XHTML, XML and LZX languages and outputs to XHTML. + It also supports RIFE templates tags and highlights them clearly + so that you can easily identify the difference between your RIFE markup + and the actual marked up source. + 2011 + https://github.com/codelibs/jhighlight + + + CDDL, v1.0 + http://www.opensource.org/licenses/cddl1.php + repo + + + LGPL, v2.1 or later + http://www.opensource.org/licenses/lgpl-license.php + repo + + + + scm:git:git@github.com:codelibs/jhighlight.git + scm:git:git@github.com:codelibs/jhighlight.git + git@github.com:codelibs/jhighlight.git + + + org.sonatype.oss + oss-parent + 7 + + + 1.2.1 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.11 + + + **/*Test.java + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + + jar + + + + + + + + + javax.servlet + servlet-api + 2.3 + provided + + + diff --git a/src/main/java/com/uwyn/jhighlight/JHighlight.java b/src/main/java/com/uwyn/jhighlight/JHighlight.java new file mode 100644 index 0000000..17986d1 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/JHighlight.java @@ -0,0 +1,253 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: JHighlight.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight; + +import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; +import com.uwyn.jhighlight.tools.FileUtils; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Set; +import java.util.regex.Pattern; + +/** + * Provides console access to the source code syntax highlighting for Java, + * HTML, XHTML, XML and LZX files. The rendering will be done in HTML. + *

The following file extensions will be processed: .java, + * .html, .htm, .xhtml, + * .xml and .lzx. + *

Execute the highlighting with the following syntax: + *

java com.uwyn.jhighlight.JHighlight [--verbose] [--fragment] [-d destdir] [-e encoding] file|dir ...
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
--verboseOutput messages about what the parser is doing.
--fragmentOutput fragments instead of complete documents.
-dSpecify the destination directory
-eSpecify the encoding of the files
+ *

RIFE template tags are also + * supported and will be clearly highlighted. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class JHighlight +{ + public static void main(String[] arguments) throws Throwable + { + String destdir_name = null; + boolean verbose = false; + String encoding = null; + boolean fragment = false; + ArrayList names = new ArrayList(); + + boolean valid_arguments = true; + if (arguments.length < 1) + { + valid_arguments = false; + } + else + { + boolean next_is_destdir = false; + boolean next_is_encoding = false; + String argument; + for (int i = 0; i < arguments.length; i++) + { + argument = arguments[i]; + if (next_is_destdir) + { + destdir_name = argument; + next_is_destdir = false; + continue; + } + + if (next_is_encoding) + { + encoding = argument; + next_is_encoding = false; + continue; + } + + if (argument.equals("-d")) + { + next_is_destdir = true; + continue; + } + + if (argument.equals("-e")) + { + next_is_encoding = true; + continue; + } + + if (argument.equals("--verbose")) + { + verbose = true; + continue; + } + + if (argument.equals("--fragment")) + { + fragment = true; + continue; + } + + names.add(argument); + } + } + + if (0 == names.size()) + { + valid_arguments = false; + } + + if (!valid_arguments) + { + System.err.println("Usage : java " + JHighlight.class.getName() + " [--verbose] [--fragment] [-d destdir] [-e encoding] file|dir ..."); + System.err.println("Generates highlighted XHTML files from all Java and XML source files"); + System.err.println("in the specified directories."); + System.err.println(" --verbose Output messages about what the parser is doing"); + System.err.println(" --fragment Output fragments instead of complete documents"); + System.err.println(" -d Specify the destination directory"); + System.err.println(" -e Specify the encoding of the files"); + System.exit(1); + } + + File destdir = null; + if (destdir_name != null) + { + destdir = new File(destdir_name); + if (!destdir.exists()) + { + throw new IOException("The destination directory '" + destdir_name + "' doesn't exist."); + } + if (!destdir.canWrite()) + { + throw new IOException("The destination directory '" + destdir_name + "' is not writable."); + } + if (!destdir.isDirectory()) + { + throw new IOException("The destination directory '" + destdir_name + "' is not a directory."); + } + } + + Iterator names_it = names.iterator(); + String name; + while (names_it.hasNext()) + { + name = (String)names_it.next(); + + File location = new File(name); + if (!location.exists()) + { + throw new IOException("The source location '" + name + "' doesn't exist."); + } + if (!location.canRead()) + { + throw new IOException("The source location '" + name + "' is not readable."); + } + + if (!location.isDirectory()) + { + File out = null; + if (null == destdir) + { + out = new File(location.getAbsolutePath() + ".html"); + } + else + { + out = new File(destdir, location.getName() + ".html"); + } + + highlightFile(location.getName(), location, out, encoding, fragment, verbose); + } + else + { + Set supported_types = XhtmlRendererFactory.getSupportedTypes(); + Pattern[] included = new Pattern[supported_types.size()]; + Pattern[] excluded = new Pattern[supported_types.size()+5]; + excluded[0] = Pattern.compile(".*SCCS.*"); + excluded[0] = Pattern.compile(".*svn.*"); + excluded[0] = Pattern.compile(".*CVS.*"); + excluded[0] = Pattern.compile(".*jetty.*"); + excluded[0] = Pattern.compile(".*tomcat.*"); + + Iterator types_it = supported_types.iterator(); + String type; + int counter = 0; + while (types_it.hasNext()) + { + type = (String)types_it.next(); + included[counter] = Pattern.compile(".*\\."+type+"$"); + excluded[counter+5] = Pattern.compile(".*\\."+type+"\\.html\\.*"); + + counter++; + } + + ArrayList file_names = FileUtils.getFileList(location, included, excluded); + + Iterator file_names_it = file_names.iterator(); + String file_name; + while (file_names_it.hasNext()) + { + file_name = (String)file_names_it.next(); + + File in = new File(location.getAbsolutePath() + File.separator + file_name); + File out = null; + if (null == destdir) + { + out = new File(location.getAbsolutePath() + File.separator + file_name + ".html"); + } + else + { + out = new File(destdir, location.getName() + File.separator + file_name + ".html"); + } + + highlightFile(location.getName() + File.separator + file_name, in, out, encoding, fragment, verbose); + } + } + } + } + + private static void highlightFile(String name, File in, File out, String encoding, boolean fragment, boolean verbose) + throws IOException + { + out.getParentFile().mkdirs(); + + if (verbose) + { + System.out.print(name + " ... "); + } + + XhtmlRendererFactory.getRenderer(FileUtils.getExtension(name)) + .highlight(name, + in.toURL().openStream(), + new FileOutputStream(out), + encoding, + fragment); + + if (verbose) + { + System.out.println("done."); + } + } +} diff --git a/src/main/java/com/uwyn/jhighlight/JHighlightVersion.java b/src/main/java/com/uwyn/jhighlight/JHighlightVersion.java new file mode 100644 index 0000000..a96253e --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/JHighlightVersion.java @@ -0,0 +1,91 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: JHighlightVersion.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * Provides acces to the version number of this JHighlight release. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class JHighlightVersion +{ + private String mVersion = null; + + JHighlightVersion() + { + URL version_url = getClass().getClassLoader().getResource("JHIGHLIGHT_VERSION"); + if (version_url != null) + { + try + { + URLConnection connection = version_url.openConnection(); + connection.setUseCaches(false); + InputStream inputStream = connection.getInputStream(); + + byte[] buffer = new byte[64]; + int return_value = -1; + ByteArrayOutputStream output_stream = new ByteArrayOutputStream(buffer.length); + + try + { + return_value = inputStream.read(buffer); + + while (-1 != return_value) + { + output_stream.write(buffer, 0, return_value); + return_value = inputStream.read(buffer); + } + } + finally + { + output_stream.close(); + inputStream.close(); + } + + mVersion = output_stream.toString("UTF-8"); + } + catch (IOException e) + { + mVersion = null; + } + } + + if (mVersion != null) + { + mVersion = mVersion.trim(); + } + if (null == mVersion) + { + mVersion = "(unknown version)"; + } + } + + private String getVersionString() + { + return mVersion; + } + + /** + * Returns the version number of this JHighlight release. + * + * @return the version number + * @since 1.0 + */ + public static String getVersion() + { + return JHighlightVersionSingleton.INSTANCE.getVersionString(); + } +} diff --git a/src/main/java/com/uwyn/jhighlight/JHighlightVersionSingleton.java b/src/main/java/com/uwyn/jhighlight/JHighlightVersionSingleton.java new file mode 100644 index 0000000..9e48a0f --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/JHighlightVersionSingleton.java @@ -0,0 +1,18 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: JHighlightVersionSingleton.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight; + +/** + * Helper class to avoid Double Check Locking + * and still have a thread-safe singleton pattern + */ +class JHighlightVersionSingleton +{ + static final JHighlightVersion INSTANCE = new JHighlightVersion(); +} + diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.flex b/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.flex new file mode 100644 index 0000000..3c62165 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.flex @@ -0,0 +1,395 @@ +/* + * Copyright 2006 Arnout Engelen . + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id$ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + +%% + +%class CppHighlighter +%implements ExplicitStateHighlighter + +%unicode +%pack + +%buffer 128 + +%public + +%int + +%{ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte CPP_COMMENT_STYLE = 7; + public static final byte DOXYGEN_COMMENT_STYLE = 8; + public static final byte DOXYGEN_TAG_STYLE = 9; + public static final byte PREPROC_STYLE = 10; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 10; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public CppHighlighter() + { + } +%} + +/* main character classes */ + +WhiteSpace = [ \t\f] + +/* identifiers */ + +ConstantIdentifier = {SimpleConstantIdentifier} +SimpleConstantIdentifier = [#A-Z0-9_]+ + +Identifier = [:jletter:][:jletterdigit:]* + +TypeIdentifier = {SimpleTypeIdentifier} +SimpleTypeIdentifier = [A-Z][:jletterdigit:]* + +/* int literals */ + +DecLiteral = 0 | [1-9][0-9]* {IntegerSuffix} + +HexLiteral = 0 [xX] 0* {HexDigit}* {IntegerSuffix} +HexDigit = [0-9a-fA-F] + +OctLiteral = 0+ {OctDigit}* {IntegerSuffix} +OctDigit = [0-7] + +IntegerSuffix = [uU]? [lL]? [uU]? + +/* float literals */ + +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? + +FLit1 = [0-9]+ \. [0-9]* {Exponent}? +FLit2 = \. [0-9]+ {Exponent}? +FLit3 = [0-9]+ {Exponent} +FLit4 = [0-9]+ {Exponent}? + +Exponent = [eE] [+\-]? [0-9]+ + +%state IN_COMMENT, IN_DOXYGEN_COMMENT + +%% + + { + + /* keywords */ + "__abstract" | + "abstract" | + "__alignof" | + "array" | + "__asm" | + "__assume" | + "__based" | + "__box" | + "break" | + "case" | + "catch" | + "__cdecl" | + "class" | + "const" | + "const_cast" | + "continue" | + "__declspec" | + "default" | + "__delegate" | + "delegate" | + "delete" | + "deprecated" | + "dllexport" | + "dllimport" | + "do" | + "double" | + "dynamic_cast" | + "else" | + "event" | + "__event" | + "__except" | + "explicit" | + "extern" | + "false" | + "__fastcall" | + "__finally" | + "finally" | + "for" | + "__forceinline" | + "friend" | + "friend_as" | + "__gc" | + "gcnew" | + "generic" | + "goto" | + "enum" | + "__hook" | + "__identifier" | + "if" | + "__if_exists" | + "__if_not_exists" | + "initonly" | + "__inline" | + "inline" | + "__int8" | + "__int16" | + "__int32" | + "__int64" | + "__interface" | + "interface" | + "interface" | + "interior_ptr" | + "__leave" | + "literal" | + "__m64" | + "__m128" | + "__m128d" | + "__m128i" | + "__multiple_inheritance" | + "mutable" | + "naked" | + "namespace" | + "new" | + "__nogc" | + "noinline" | + "__noop" | + "noreturn" | + "nothrow" | + "novtable" | + "nullptr" | + "operator" | + "__pin" | + "private" | + "__property" | + "property" | + "property" | + "protected" | + "public" | + "__raise" | + "register" | + "reinterpret_cast" | + "return" | + "safecast" | + "__sealed" | + "sealed" | + "selectany" | + "signed" | + "__single_inheritance" | + "sizeof" | + "static" | + "static_cast" | + "__stdcall" | + "struct" | + "__super" | + "switch" | + "template" | + "this" | + "thread" | + "throw" | + "true" | + "try" | + "__try" | + "__except" | + "__try_cast" | + "typedef" | + "typeid" | + "typeid" | + "typename" | + "__unaligned" | + "__unhook" | + "union" | + "unsigned" | + "using" | + "uuid" | + "__uuidof" | + "value" | + "__value" | + "virtual" | + "__virtual_inheritance" | + "void" | + "volatile" | + "__w64" | + "__wchar_t," | + "while" + { return KEYWORD_STYLE; } + + "bool" | + "char" | + "double" | + "int" | + "long" | + "float" | + "short" | + "void" { return TYPE_STYLE; } + + /* literals */ + "true" | + "false" | + + (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | + (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) | + + {DecLiteral} | + {OctLiteral} | + {HexLiteral} | + + {FloatLiteral} + { return LITERAL_STYLE; } + + /* preprocessor symbols */ + "#define" | + "#elif" | + "#else" | + "#endif" | + "#error" | + "#ifdef" | + "#ifndef" | + "#if" | + "#import" | + "#include" | + "#line" | + "#pragma" | + "#undef" | + "#using" + { return PREPROC_STYLE; } + + + /* separators */ + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." { return SEPARATOR_STYLE; } + + /* operators */ + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" { return OPERATOR_STYLE; } + + {ConstantIdentifier} { return PLAIN_STYLE; } + + {TypeIdentifier} { return TYPE_STYLE; } + + \n | + {Identifier} | + {WhiteSpace} { return PLAIN_STYLE; } + + + +// single line comment + + "//" [^\n]* \n | + +// short comment + + "/**/" { return CPP_COMMENT_STYLE; } + +// comment start + + "/**" { yybegin(IN_DOXYGEN_COMMENT); return DOXYGEN_COMMENT_STYLE;} + "/*" { yybegin(IN_COMMENT); return CPP_COMMENT_STYLE;} + +} + + +// normal comment mode + + { + + + // comment unterminated + + ([^\n*]|\*+[^\n*/])* (\n | \*+\n) { return CPP_COMMENT_STYLE; } + + // comment terminated + + ([^\n*]|\*+[^\n*/])* \*+ "/" { yybegin(YYINITIAL); return CPP_COMMENT_STYLE; } + +} + +// doc comment mode + + { + + // comment unterminated + + .|\n { return DOXYGEN_COMMENT_STYLE; } + + // comment terminated + + \* "/" { yybegin(YYINITIAL); return DOXYGEN_COMMENT_STYLE; } + + + "@" {Identifier} { return DOXYGEN_TAG_STYLE; } + +} + +/* error fallback */ + +.|\n { return PLAIN_STYLE; } diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.java b/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.java new file mode 100644 index 0000000..b866cd0 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/CppHighlighter.java @@ -0,0 +1,1228 @@ +/* The following code was generated by JFlex 1.4.1 on 3/13/06 6:15 PM */ + +/* + * Copyright 2006 Arnout Engelen . + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of the GNU Lesser General Public License, v2.1 or later + * $Id: CppHighlighter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + + +/** + * This class is a scanner generated by + * JFlex 1.4.1 + * on 3/13/06 6:15 PM from the specification file + * com/uwyn/jhighlight/highlighter/CppHighlighter.flex + */ +public class CppHighlighter implements ExplicitStateHighlighter { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 128; + + /** lexical states */ + public static final int YYINITIAL = 0; + public static final int IN_DOXYGEN_COMMENT = 2; + public static final int IN_COMMENT = 1; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\4\1\0\1\61\1\0\1\0\1\0\16\4\4\0\1\0\1\65"+ + "\1\60\1\1\1\2\1\65\1\65\1\63\1\64\1\64\1\66\1\27"+ + "\1\57\1\27\1\24\1\67\1\7\1\51\1\54\1\53\1\55\1\14"+ + "\1\52\1\14\1\50\1\5\1\65\1\64\1\65\1\65\1\65\1\65"+ + "\1\70\3\13\1\22\1\26\1\22\5\6\1\20\10\6\1\16\2\6"+ + "\1\11\2\6\1\64\1\62\1\64\1\65\1\3\1\0\1\30\1\31"+ + "\1\12\1\23\1\25\1\21\1\36\1\44\1\35\1\2\1\43\1\17"+ + "\1\42\1\37\1\40\1\45\1\2\1\34\1\32\1\33\1\15\1\46"+ + "\1\47\1\10\1\41\1\56\1\64\1\65\1\64\1\65\41\4\2\0"+ + "\4\2\4\0\1\2\12\0\1\2\4\0\1\2\5\0\27\2\1\0"+ + "\37\2\1\0\u0128\2\2\0\22\2\34\0\136\2\2\0\11\2\2\0"+ + "\7\2\16\0\2\2\16\0\5\2\11\0\1\2\21\0\117\4\21\0"+ + "\3\4\27\0\1\2\13\0\1\2\1\0\3\2\1\0\1\2\1\0"+ + "\24\2\1\0\54\2\1\0\10\2\2\0\32\2\14\0\202\2\1\0"+ + "\4\4\5\0\71\2\2\0\2\2\2\0\2\2\3\0\46\2\2\0"+ + "\2\2\67\0\46\2\2\0\1\2\7\0\47\2\11\0\21\4\1\0"+ + "\27\4\1\0\3\4\1\0\1\4\1\0\2\4\1\0\1\4\13\0"+ + "\33\2\5\0\3\2\56\0\32\2\5\0\13\2\13\4\12\0\12\4"+ + "\6\0\1\4\143\2\1\0\1\2\7\4\2\0\6\4\2\2\2\4"+ + "\1\0\4\4\2\0\12\4\3\2\22\0\1\4\1\2\1\4\33\2"+ + "\3\0\33\4\65\0\46\2\13\4\u0150\0\3\4\1\0\65\2\2\0"+ + "\1\4\1\2\20\4\2\0\1\2\4\4\3\0\12\2\2\4\2\0"+ + "\12\4\21\0\3\4\1\0\10\2\2\0\2\2\2\0\26\2\1\0"+ + "\7\2\1\0\1\2\3\0\4\2\2\0\1\4\1\0\7\4\2\0"+ + "\2\4\2\0\3\4\11\0\1\4\4\0\2\2\1\0\3\2\2\4"+ + "\2\0\12\4\4\2\16\0\1\4\2\0\6\2\4\0\2\2\2\0"+ + "\26\2\1\0\7\2\1\0\2\2\1\0\2\2\1\0\2\2\2\0"+ + "\1\4\1\0\5\4\4\0\2\4\2\0\3\4\13\0\4\2\1\0"+ + "\1\2\7\0\14\4\3\2\14\0\3\4\1\0\7\2\1\0\1\2"+ + "\1\0\3\2\1\0\26\2\1\0\7\2\1\0\2\2\1\0\5\2"+ + "\2\0\1\4\1\2\10\4\1\0\3\4\1\0\3\4\2\0\1\2"+ + "\17\0\1\2\5\0\12\4\21\0\3\4\1\0\10\2\2\0\2\2"+ + "\2\0\26\2\1\0\7\2\1\0\2\2\2\0\4\2\2\0\1\4"+ + "\1\2\6\4\3\0\2\4\2\0\3\4\10\0\2\4\4\0\2\2"+ + "\1\0\3\2\4\0\12\4\22\0\2\4\1\0\6\2\3\0\3\2"+ + "\1\0\4\2\3\0\2\2\1\0\1\2\1\0\2\2\3\0\2\2"+ + "\3\0\3\2\3\0\10\2\1\0\3\2\4\0\5\4\3\0\3\4"+ + "\1\0\4\4\11\0\1\4\17\0\11\4\21\0\3\4\1\0\10\2"+ + "\1\0\3\2\1\0\27\2\1\0\12\2\1\0\5\2\4\0\7\4"+ + "\1\0\3\4\1\0\4\4\7\0\2\4\11\0\2\2\4\0\12\4"+ + "\22\0\2\4\1\0\10\2\1\0\3\2\1\0\27\2\1\0\12\2"+ + "\1\0\5\2\4\0\7\4\1\0\3\4\1\0\4\4\7\0\2\4"+ + "\7\0\1\2\1\0\2\2\4\0\12\4\22\0\2\4\1\0\10\2"+ + "\1\0\3\2\1\0\27\2\1\0\20\2\4\0\6\4\2\0\3\4"+ + "\1\0\4\4\11\0\1\4\10\0\2\2\4\0\12\4\22\0\2\4"+ + "\1\0\22\2\3\0\30\2\1\0\11\2\1\0\1\2\2\0\7\2"+ + "\3\0\1\4\4\0\6\4\1\0\1\4\1\0\10\4\22\0\2\4"+ + "\15\0\60\2\1\4\2\2\7\4\4\0\10\2\10\4\1\0\12\4"+ + "\47\0\2\2\1\0\1\2\2\0\2\2\1\0\1\2\2\0\1\2"+ + "\6\0\4\2\1\0\7\2\1\0\3\2\1\0\1\2\1\0\1\2"+ + "\2\0\2\2\1\0\4\2\1\4\2\2\6\4\1\0\2\4\1\2"+ + "\2\0\5\2\1\0\1\2\1\0\6\4\2\0\12\4\2\0\2\2"+ + "\42\0\1\2\27\0\2\4\6\0\12\4\13\0\1\4\1\0\1\4"+ + "\1\0\1\4\4\0\2\4\10\2\1\0\42\2\6\0\24\4\1\0"+ + "\2\4\4\2\4\0\10\4\1\0\44\4\11\0\1\4\71\0\42\2"+ + "\1\0\5\2\1\0\2\2\1\0\7\4\3\0\4\4\6\0\12\4"+ + "\6\0\6\2\4\4\106\0\46\2\12\0\47\2\11\0\132\2\5\0"+ + "\104\2\5\0\122\2\6\0\7\2\1\0\77\2\1\0\1\2\1\0"+ + "\4\2\2\0\7\2\1\0\1\2\1\0\4\2\2\0\47\2\1\0"+ + "\1\2\1\0\4\2\2\0\37\2\1\0\1\2\1\0\4\2\2\0"+ + "\7\2\1\0\1\2\1\0\4\2\2\0\7\2\1\0\7\2\1\0"+ + "\27\2\1\0\37\2\1\0\1\2\1\0\4\2\2\0\7\2\1\0"+ + "\47\2\1\0\23\2\16\0\11\4\56\0\125\2\14\0\u026c\2\2\0"+ + "\10\2\12\0\32\2\5\0\113\2\225\0\64\2\40\4\7\0\1\2"+ + "\4\0\12\4\41\0\4\4\1\0\12\4\6\0\130\2\10\0\51\2"+ + "\1\4\u0556\0\234\2\4\0\132\2\6\0\26\2\2\0\6\2\2\0"+ + "\46\2\2\0\6\2\2\0\10\2\1\0\1\2\1\0\1\2\1\0"+ + "\1\2\1\0\37\2\2\0\65\2\1\0\7\2\1\0\1\2\3\0"+ + "\3\2\1\0\7\2\3\0\4\2\2\0\6\2\4\0\15\2\5\0"+ + "\3\2\1\0\7\2\17\0\4\4\32\0\5\4\20\0\2\2\51\0"+ + "\6\4\17\0\1\2\40\0\20\2\40\0\15\4\4\0\1\4\40\0"+ + "\1\2\4\0\1\2\2\0\12\2\1\0\1\2\3\0\5\2\6\0"+ + "\1\2\1\0\1\2\1\0\1\2\1\0\4\2\1\0\3\2\1\0"+ + "\7\2\46\0\44\2\u0e81\0\3\2\31\0\11\2\6\4\1\0\5\2"+ + "\2\0\3\2\6\0\124\2\4\0\2\4\2\0\2\2\2\0\136\2"+ + "\6\0\50\2\4\0\136\2\21\0\30\2\u0248\0\u19b6\2\112\0\u51a6\2"+ + "\132\0\u048d\2\u0773\0\u2ba4\2\u215c\0\u012e\2\322\0\7\2\14\0\5\2"+ + "\5\0\1\2\1\4\12\2\1\0\15\2\1\0\5\2\1\0\1\2"+ + "\1\0\2\2\1\0\2\2\1\0\154\2\41\0\u016b\2\22\0\100\2"+ + "\2\0\66\2\50\0\14\2\44\0\4\4\17\0\2\2\30\0\3\2"+ + "\31\0\1\2\6\0\3\2\1\0\1\2\1\0\207\2\2\0\1\4"+ + "\4\0\1\2\13\0\12\4\7\0\32\2\4\0\1\2\1\0\32\2"+ + "\12\0\132\2\3\0\6\2\2\0\6\2\2\0\6\2\2\0\3\2"+ + "\3\0\2\2\3\0\2\2\22\0\3\4\4\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\3\0\4\1\1\2\1\1\1\2\5\1\1\3\1\1"+ + "\1\4\15\1\1\3\2\1\1\4\1\1\1\5\1\1"+ + "\3\6\1\1\6\0\2\1\7\2\1\0\1\1\1\7"+ + "\4\2\20\1\1\10\24\1\1\10\20\1\4\0\1\11"+ + "\3\0\1\12\1\13\1\14\7\0\1\15\3\0\23\1"+ + "\1\2\1\0\1\2\55\1\1\7\23\1\1\16\11\0"+ + "\41\1\1\7\54\1\1\0\1\15\4\0\16\1\1\10"+ + "\44\1\3\0\20\1\1\10\2\1\1\10\56\1\1\10"+ + "\10\1"; + + private static int [] zzUnpackAction() { + int [] result = new int[450]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\71\0\162\0\253\0\344\0\u011d\0\u0156\0\u018f"+ + "\0\u01c8\0\u0201\0\u023a\0\u0273\0\u02ac\0\u02e5\0\u031e\0\u0357"+ + "\0\u0390\0\253\0\u03c9\0\u0402\0\u043b\0\u0474\0\u04ad\0\u04e6"+ + "\0\u051f\0\u0558\0\u0591\0\u05ca\0\u0603\0\u063c\0\u0675\0\253"+ + "\0\u06ae\0\u06e7\0\u0720\0\u0759\0\253\0\u0792\0\253\0\u07cb"+ + "\0\u0804\0\u083d\0\u0876\0\u08af\0\u08e8\0\u0921\0\u095a\0\u0993"+ + "\0\u09cc\0\u0a05\0\u0a3e\0\u0a77\0\u0ab0\0\u0ae9\0\253\0\u083d"+ + "\0\u0b22\0\u0b5b\0\u0b94\0\u0bcd\0\u0c06\0\u0c3f\0\u0c78\0\u0cb1"+ + "\0\u0cea\0\u0d23\0\u0d5c\0\u0d95\0\u0dce\0\u0e07\0\u0e40\0\u0e79"+ + "\0\u0eb2\0\u0eeb\0\u0f24\0\u0f5d\0\u0f96\0\u0fcf\0\u1008\0\u1041"+ + "\0\u107a\0\u10b3\0\u10ec\0\u1125\0\u115e\0\u1197\0\u11d0\0\u1209"+ + "\0\u1242\0\u127b\0\u12b4\0\u12ed\0\u1326\0\u135f\0\u1398\0\u13d1"+ + "\0\u140a\0\u1443\0\u147c\0\u14b5\0\u14ee\0\u011d\0\u1527\0\u1560"+ + "\0\u1599\0\u15d2\0\u160b\0\u1644\0\u167d\0\u16b6\0\u16ef\0\u1728"+ + "\0\u1761\0\u179a\0\u17d3\0\u180c\0\u1845\0\u187e\0\u06ae\0\u18b7"+ + "\0\u06e7\0\u18f0\0\u1929\0\u1962\0\u0759\0\u0792\0\253\0\253"+ + "\0\u199b\0\u19d4\0\u1a0d\0\u1a46\0\u1a7f\0\u1ab8\0\u1af1\0\u1b2a"+ + "\0\u1b63\0\u1b9c\0\u1bd5\0\u1c0e\0\u1c47\0\u1c80\0\u1cb9\0\u1cf2"+ + "\0\u1d2b\0\u1d64\0\u1d9d\0\u1dd6\0\u1e0f\0\u1e48\0\u1e81\0\u1eba"+ + "\0\u1ef3\0\u1f2c\0\u1f65\0\u1f9e\0\u1fd7\0\u2010\0\u2049\0\u2082"+ + "\0\u20bb\0\u20f4\0\u212d\0\u2166\0\u219f\0\u21d8\0\u2211\0\u224a"+ + "\0\u2283\0\u22bc\0\u22f5\0\u232e\0\u2367\0\u23a0\0\u23d9\0\u2412"+ + "\0\u244b\0\u2484\0\u24bd\0\u24f6\0\u252f\0\u2568\0\u25a1\0\u25da"+ + "\0\u2613\0\u264c\0\u2685\0\u26be\0\u26f7\0\u2730\0\u2769\0\u27a2"+ + "\0\u27db\0\u2814\0\u284d\0\u2886\0\u28bf\0\u28f8\0\u2931\0\u296a"+ + "\0\u29a3\0\u29dc\0\u2a15\0\u2a4e\0\u2a87\0\u2ac0\0\u2af9\0\u2b32"+ + "\0\u2b6b\0\u2ba4\0\u2bdd\0\u2c16\0\u2c4f\0\u2c88\0\u2cc1\0\u2cfa"+ + "\0\u2d33\0\u2d6c\0\u2da5\0\u2dde\0\u2e17\0\u2e50\0\u2e89\0\u2ec2"+ + "\0\u2efb\0\u2f34\0\u2f6d\0\u2fa6\0\u2fdf\0\u3018\0\u3051\0\u308a"+ + "\0\u30c3\0\u30fc\0\u3135\0\u316e\0\u31a7\0\u31e0\0\u3219\0\u3252"+ + "\0\u328b\0\u32c4\0\u32fd\0\u3336\0\u336f\0\u33a8\0\u33e1\0\u341a"+ + "\0\u3453\0\u348c\0\u34c5\0\u34fe\0\u3537\0\u3570\0\u35a9\0\u35e2"+ + "\0\u361b\0\u3654\0\u368d\0\u36c6\0\u36ff\0\u3738\0\u3771\0\u37aa"+ + "\0\u37e3\0\u381c\0\u3855\0\u388e\0\u38c7\0\u3900\0\u011d\0\u3939"+ + "\0\u3972\0\u39ab\0\u39e4\0\u3a1d\0\u3a56\0\u3a8f\0\u3ac8\0\u3b01"+ + "\0\u3b3a\0\u3b73\0\u3bac\0\u3be5\0\u3c1e\0\u3c57\0\u3c90\0\u3cc9"+ + "\0\u3d02\0\u3d3b\0\u3d74\0\u3dad\0\u3de6\0\u3e1f\0\u3e58\0\u3e91"+ + "\0\u3eca\0\u3f03\0\u3f3c\0\u3f75\0\u3fae\0\u3fe7\0\u4020\0\u4059"+ + "\0\u4092\0\u40cb\0\u4104\0\u413d\0\u4176\0\u41af\0\u41e8\0\u4221"+ + "\0\u425a\0\u4293\0\u42cc\0\u4305\0\253\0\u433e\0\u4377\0\u43b0"+ + "\0\u43e9\0\u4422\0\u445b\0\u4494\0\u44cd\0\u4506\0\u453f\0\u4578"+ + "\0\u45b1\0\u45ea\0\u4623\0\u465c\0\u4695\0\u46ce\0\u4707\0\u4740"+ + "\0\u4779\0\u47b2\0\u47eb\0\u4824\0\u485d\0\u4896\0\u48cf\0\u4908"+ + "\0\u4941\0\u497a\0\u49b3\0\u49ec\0\u4a25\0\u4a5e\0\u4a97\0\u4ad0"+ + "\0\u4b09\0\u4b42\0\u4b7b\0\u4bb4\0\u4bed\0\u4c26\0\u4c5f\0\u4c98"+ + "\0\u4cd1\0\u4d0a\0\u4d43\0\u4d7c\0\u4db5\0\u4dee\0\u4e27\0\u4e60"+ + "\0\u4e99\0\u4ed2\0\u4f0b\0\u4f44\0\u4f7d\0\u4fb6\0\u4fef\0\u5028"+ + "\0\u5061\0\u509a\0\u50d3\0\u510c\0\u5145\0\u517e\0\u51b7\0\u51f0"+ + "\0\u5229\0\u5262\0\u529b\0\u52d4\0\u530d\0\u5346\0\u537f\0\u53b8"+ + "\0\u53f1\0\u542a\0\u5463\0\u549c\0\u54d5\0\u550e\0\u5547\0\u5580"+ + "\0\u55b9\0\u55f2\0\u562b\0\u5664\0\u569d\0\u56d6\0\u570f\0\u5748"+ + "\0\u5781\0\u57ba\0\u57f3\0\u582c\0\u5865\0\u589e\0\u58d7\0\u5910"+ + "\0\u5949\0\u5982\0\u59bb\0\u59f4\0\u4740\0\u5a2d\0\u5a66\0\u5a9f"+ + "\0\u5ad8\0\u5b11\0\u5b4a\0\u5b83\0\u5bbc\0\u5bf5\0\u5c2e\0\u5c67"+ + "\0\u5ca0\0\u5cd9\0\u5d12\0\u5d4b\0\u5d84\0\u5dbd\0\u5df6\0\u5e2f"+ + "\0\u5e68\0\253\0\u5ea1\0\u5eda\0\u5f13\0\u5f4c\0\u5f85\0\u5fbe"+ + "\0\u5ff7\0\u6030"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[450]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\4\1\5\1\6\1\7\1\4\1\10\1\11\1\12"+ + "\1\6\1\11\1\13\1\11\1\10\1\14\1\11\1\15"+ + "\1\11\1\16\1\11\1\17\1\20\1\21\1\11\1\22"+ + "\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+ + "\1\33\1\6\1\34\2\6\1\35\1\36\1\37\6\10"+ + "\1\6\1\40\1\41\2\4\1\42\1\40\2\22\1\43"+ + "\1\4\61\44\1\45\4\44\1\46\2\44\66\47\1\50"+ + "\1\47\1\51\72\0\1\52\1\0\1\52\1\0\3\52"+ + "\1\0\1\52\1\0\2\52\1\53\1\52\1\54\1\52"+ + "\1\0\1\52\1\55\1\0\1\56\1\52\6\0\1\57"+ + "\7\0\1\60\2\0\6\52\15\0\22\6\1\0\2\6"+ + "\1\0\27\6\13\0\1\52\1\6\1\61\1\6\3\62"+ + "\1\6\1\62\1\6\2\62\1\6\1\62\1\6\1\62"+ + "\1\6\1\62\1\6\1\0\1\6\1\62\1\0\20\6"+ + "\6\62\1\6\13\0\1\52\1\0\1\52\1\0\1\10"+ + "\1\52\1\10\1\0\1\52\1\0\1\52\1\10\1\63"+ + "\1\64\1\65\1\66\1\67\1\70\1\67\1\71\1\72"+ + "\1\73\21\0\6\10\14\0\1\52\1\74\1\11\1\74"+ + "\3\11\1\74\1\11\1\74\2\11\1\74\1\11\1\74"+ + "\1\11\1\74\1\11\1\74\1\0\1\74\1\11\1\0"+ + "\20\74\6\11\1\74\13\0\1\52\1\0\1\52\1\0"+ + "\1\75\1\52\1\76\1\77\1\100\1\0\1\52\1\76"+ + "\1\63\1\64\1\65\1\66\1\67\1\70\1\67\1\71"+ + "\1\72\1\73\21\0\1\75\5\76\15\0\15\6\1\101"+ + "\4\6\1\0\2\6\1\0\1\102\7\6\1\103\3\6"+ + "\1\104\12\6\14\0\13\6\1\105\6\6\1\0\2\6"+ + "\1\0\2\6\1\106\4\6\1\107\17\6\14\0\22\6"+ + "\1\0\2\6\1\0\5\6\1\110\2\6\1\111\16\6"+ + "\14\0\15\6\1\112\4\6\1\0\2\6\1\0\1\113"+ + "\3\6\1\114\1\115\2\6\1\116\16\6\14\0\15\6"+ + "\1\117\4\6\1\0\1\120\1\6\1\0\10\6\1\121"+ + "\1\122\15\6\17\0\1\71\1\0\1\71\4\0\1\71"+ + "\33\0\6\71\15\0\6\6\1\123\6\6\1\124\4\6"+ + "\1\0\2\6\1\0\7\6\1\125\6\6\1\126\10\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\6\1\127\2\6"+ + "\1\130\22\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\131\3\6\1\132\16\6\14\0\22\6\1\0\1\133"+ + "\1\6\1\0\1\134\2\6\1\135\1\6\1\136\6\6"+ + "\1\137\2\6\1\140\7\6\14\0\22\6\1\0\1\141"+ + "\1\6\1\0\4\6\1\142\4\6\1\143\2\6\1\144"+ + "\12\6\14\0\22\6\1\0\1\145\1\6\1\0\27\6"+ + "\14\0\17\6\1\146\2\6\1\0\2\6\1\0\7\6"+ + "\1\147\17\6\14\0\10\6\1\150\11\6\1\0\1\151"+ + "\1\6\1\0\10\6\1\152\16\6\14\0\13\6\1\153"+ + "\6\6\1\0\1\154\1\6\1\0\1\155\7\6\1\156"+ + "\16\6\14\0\22\6\1\0\2\6\1\0\15\6\1\157"+ + "\11\6\14\0\13\6\1\160\6\6\1\0\2\6\1\0"+ + "\27\6\14\0\13\6\1\161\6\6\1\0\2\6\1\0"+ + "\4\6\1\162\22\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\163\4\6\1\164\2\6\1\165\16\6\14\0\22\6"+ + "\1\0\2\6\1\0\14\6\1\166\12\6\12\0\60\167"+ + "\2\67\1\170\6\167\61\171\1\67\1\172\1\67\5\171"+ + "\66\0\1\173\1\174\1\0\61\175\1\45\4\175\1\176"+ + "\63\175\1\45\4\175\1\176\1\177\1\175\67\0\1\200"+ + "\3\0\2\201\2\0\1\201\1\0\4\201\1\0\7\201"+ + "\1\0\2\201\1\0\20\201\6\0\1\201\13\0\1\52"+ + "\1\0\1\52\1\0\3\52\1\0\1\52\1\0\2\52"+ + "\1\0\1\52\1\0\1\52\1\0\1\52\3\0\1\52"+ + "\21\0\6\52\45\0\1\202\4\0\1\203\66\0\1\204"+ + "\60\0\1\205\62\0\1\206\14\0\1\207\2\0\1\210"+ + "\52\0\1\211\15\0\1\212\2\0\1\213\62\0\1\214"+ + "\35\0\1\52\1\6\1\62\1\6\3\62\1\6\1\62"+ + "\1\215\2\62\1\216\1\62\1\217\1\62\1\220\1\62"+ + "\1\221\1\0\1\222\1\62\1\0\1\223\1\224\1\225"+ + "\1\226\1\227\1\230\1\231\1\232\2\6\1\233\1\6"+ + "\1\234\1\235\1\236\1\237\6\62\1\6\13\0\1\52"+ + "\1\6\1\62\1\6\3\62\1\6\1\62\1\6\2\62"+ + "\1\6\1\62\1\6\1\62\1\6\1\62\1\6\1\0"+ + "\1\6\1\62\1\0\20\6\6\62\1\6\27\0\2\67"+ + "\2\65\51\0\1\52\1\0\1\52\1\0\3\52\1\0"+ + "\1\52\1\0\2\52\1\67\1\70\1\65\1\66\1\0"+ + "\1\52\3\0\1\52\21\0\6\52\30\0\2\67\53\0"+ + "\1\52\1\0\1\52\1\0\3\52\1\0\1\52\1\0"+ + "\2\52\1\67\1\70\1\0\1\52\1\0\1\52\3\0"+ + "\1\52\21\0\6\52\20\0\1\71\1\0\1\71\4\0"+ + "\1\71\4\0\3\67\1\0\2\72\21\0\6\71\20\0"+ + "\1\240\1\0\1\240\4\0\1\240\12\0\1\241\20\0"+ + "\6\240\14\0\1\52\1\0\1\52\1\0\1\242\1\52"+ + "\1\242\1\0\1\52\1\0\1\52\1\242\1\0\1\52"+ + "\1\0\1\52\1\0\1\52\3\0\1\52\1\241\20\0"+ + "\6\242\15\0\22\74\1\0\2\74\1\0\27\74\13\0"+ + "\1\52\1\0\1\52\1\0\1\75\1\52\1\75\1\0"+ + "\1\52\1\0\1\52\1\75\1\0\1\52\1\0\1\52"+ + "\1\67\1\70\1\67\1\71\1\72\1\73\21\0\6\75"+ + "\14\0\1\52\1\0\1\52\1\0\1\75\1\52\1\76"+ + "\1\0\1\52\1\0\1\52\1\76\1\63\1\64\1\65"+ + "\1\66\1\67\1\70\1\67\1\71\1\72\1\73\21\0"+ + "\1\75\5\76\20\0\1\77\1\0\1\77\2\0\3\77"+ + "\2\63\2\65\3\77\1\0\2\77\1\0\2\77\16\0"+ + "\6\77\14\0\1\52\1\0\1\52\1\0\1\100\1\52"+ + "\1\100\1\0\1\52\1\77\2\100\1\63\1\64\1\65"+ + "\1\66\1\77\1\100\1\77\1\0\1\77\1\100\1\0"+ + "\2\77\16\0\6\100\15\0\22\6\1\0\2\6\1\0"+ + "\1\243\26\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\244\1\245\23\6\14\0\22\6\1\0\2\6\1\0"+ + "\7\6\1\246\17\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\247\26\6\14\0\22\6\1\0\2\6\1\0\5\6"+ + "\1\250\21\6\14\0\22\6\1\0\2\6\1\0\5\6"+ + "\1\251\21\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\252\2\6\1\253\21\6\14\0\22\6\1\0\2\6"+ + "\1\0\3\6\1\254\23\6\14\0\22\6\1\0\2\6"+ + "\1\0\7\6\1\255\17\6\14\0\22\6\1\0\2\6"+ + "\1\0\10\6\1\256\16\6\14\0\15\6\1\124\4\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\5\6\1\257\21\6\14\0\22\6\1\0\2\6"+ + "\1\0\7\6\1\260\17\6\14\0\22\6\1\0\2\6"+ + "\1\0\4\6\1\146\22\6\14\0\15\6\1\261\4\6"+ + "\1\0\2\6\1\0\27\6\14\0\15\6\1\262\1\6"+ + "\1\263\2\6\1\0\2\6\1\0\15\6\1\264\11\6"+ + "\14\0\13\6\1\265\6\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\7\6\1\266\17\6"+ + "\14\0\22\6\1\0\2\6\1\0\3\6\1\267\11\6"+ + "\1\270\11\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\244\24\6\14\0\13\6\1\271\6\6\1\0\2\6"+ + "\1\0\27\6\14\0\22\6\1\0\1\272\1\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\2\6\1\273"+ + "\24\6\14\0\22\6\1\0\2\6\1\0\4\6\1\274"+ + "\22\6\14\0\22\6\1\0\1\275\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\10\6\1\276\16\6"+ + "\14\0\15\6\1\277\4\6\1\0\2\6\1\0\1\300"+ + "\26\6\14\0\17\6\1\301\2\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\1\302\3\6"+ + "\1\303\22\6\14\0\22\6\1\0\2\6\1\0\6\6"+ + "\1\304\17\6\1\305\14\0\22\6\1\0\2\6\1\0"+ + "\10\6\1\306\16\6\14\0\22\6\1\0\2\6\1\0"+ + "\5\6\1\307\21\6\14\0\22\6\1\0\2\6\1\0"+ + "\12\6\1\310\14\6\14\0\13\6\1\244\6\6\1\0"+ + "\2\6\1\0\11\6\1\146\15\6\14\0\22\6\1\0"+ + "\2\6\1\0\15\6\1\311\11\6\14\0\22\6\1\0"+ + "\2\6\1\0\4\6\1\312\1\313\21\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\314\1\6\1\315\1\316"+ + "\20\6\14\0\15\6\1\317\4\6\1\0\2\6\1\0"+ + "\3\6\1\320\1\6\1\321\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\7\6\1\322\17\6\14\0\22\6\1\0"+ + "\2\6\1\0\7\6\1\323\17\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\324\23\6\14\0\15\6\1\325"+ + "\4\6\1\0\2\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\17\6\1\146\7\6\14\0\22\6\1\0"+ + "\2\6\1\0\12\6\1\326\1\327\13\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\330\1\331\1\332\10\6"+ + "\1\160\10\6\14\0\22\6\1\0\1\333\1\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\3\6\1\334"+ + "\23\6\14\0\22\6\1\0\2\6\1\0\1\6\1\335"+ + "\25\6\14\0\22\6\1\0\2\6\1\0\5\6\1\336"+ + "\2\6\1\337\16\6\14\0\15\6\1\340\4\6\1\0"+ + "\2\6\1\0\27\6\14\0\22\6\1\0\2\6\1\0"+ + "\4\6\1\341\22\6\14\0\15\6\1\342\4\6\1\0"+ + "\2\6\1\0\5\6\1\250\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\5\6\1\343\21\6\12\0\61\167\1\67"+ + "\7\167\61\171\1\67\7\171\66\0\1\344\2\0\61\174"+ + "\1\45\7\174\2\0\22\201\1\0\2\201\1\0\27\201"+ + "\47\0\1\345\56\0\1\346\104\0\1\347\52\0\1\54"+ + "\101\0\1\347\2\0\1\350\67\0\1\351\57\0\1\352"+ + "\70\0\1\346\13\0\1\203\43\0\1\353\123\0\1\354"+ + "\53\0\1\355\42\0\21\6\1\356\1\0\2\6\1\0"+ + "\27\6\14\0\13\6\1\357\6\6\1\0\2\6\1\0"+ + "\7\6\1\360\17\6\14\0\22\6\1\0\1\361\1\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\1\362"+ + "\4\6\1\115\2\6\1\363\16\6\14\0\22\6\1\0"+ + "\1\364\1\6\1\0\27\6\14\0\6\6\1\365\13\6"+ + "\1\0\2\6\1\0\16\6\1\126\10\6\14\0\15\6"+ + "\1\366\4\6\1\0\2\6\1\0\1\6\1\127\1\367"+ + "\24\6\14\0\22\6\1\0\2\6\1\0\1\370\7\6"+ + "\1\371\16\6\14\0\13\6\1\372\6\6\1\0\1\373"+ + "\1\6\1\0\3\6\1\374\1\6\1\375\21\6\14\0"+ + "\22\6\1\0\2\6\1\0\4\6\1\376\22\6\14\0"+ + "\22\6\1\0\2\6\1\0\1\377\26\6\14\0\17\6"+ + "\1\u0100\1\6\1\u0101\1\0\2\6\1\0\7\6\1\u0102"+ + "\17\6\14\0\10\6\1\146\11\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\10\6\1\u0103"+ + "\16\6\14\0\13\6\1\u0104\6\6\1\0\2\6\1\0"+ + "\21\6\1\u0105\1\u0106\4\6\14\0\22\6\1\0\2\6"+ + "\1\0\10\6\1\u0107\16\6\14\0\22\6\1\0\2\6"+ + "\1\0\4\6\1\u0108\1\u0109\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\1\163\4\6\1\u010a\21\6\14\0\10\6"+ + "\1\u010b\11\6\1\0\2\6\1\0\22\6\1\u0106\4\6"+ + "\17\0\1\240\1\0\1\240\4\0\1\240\4\0\3\67"+ + "\24\0\6\240\20\0\1\240\1\0\1\240\4\0\1\240"+ + "\33\0\6\240\14\0\1\52\1\0\1\52\1\0\1\242"+ + "\1\52\1\242\1\0\1\52\1\0\1\52\1\242\1\0"+ + "\1\52\1\0\1\52\1\67\1\70\1\67\2\0\1\52"+ + "\21\0\6\242\15\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\313\24\6\14\0\22\6\1\0\1\146\1\6\1\0"+ + "\27\6\14\0\10\6\1\u010c\11\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\2\6\1\u010d"+ + "\1\u010e\23\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u010f\22\6\14\0\21\6\1\146\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\7\6\1\u0110"+ + "\17\6\14\0\22\6\1\0\2\6\1\0\5\6\1\u0111"+ + "\21\6\14\0\22\6\1\0\2\6\1\0\10\6\1\u0109"+ + "\16\6\14\0\22\6\1\0\1\u0112\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\6\6\1\u010f\20\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\u0113\26\6\14\0"+ + "\22\6\1\0\1\u0114\1\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\1\u0115\26\6\14\0\22\6\1\0"+ + "\1\u0116\1\6\1\0\5\6\1\u0117\21\6\14\0\22\6"+ + "\1\0\1\u0118\1\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\1\u0119\26\6\14\0\22\6\1\0\2\6"+ + "\1\0\4\6\1\u011a\22\6\14\0\22\6\1\0\2\6"+ + "\1\0\1\6\1\343\25\6\14\0\22\6\1\0\2\6"+ + "\1\0\1\u011b\26\6\14\0\22\6\1\0\1\u011c\1\6"+ + "\1\0\27\6\14\0\15\6\1\u011d\4\6\1\0\2\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\12\6"+ + "\1\146\14\6\14\0\22\6\1\0\2\6\1\0\7\6"+ + "\1\u011e\17\6\14\0\22\6\1\0\2\6\1\0\3\6"+ + "\1\u011f\23\6\14\0\22\6\1\0\2\6\1\0\1\u0120"+ + "\26\6\14\0\22\6\1\0\2\6\1\0\1\u0121\26\6"+ + "\14\0\15\6\1\u010f\4\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\1\u0122\1\6\1\0\27\6\14\0"+ + "\15\6\1\327\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\1\u0123\1\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\u0124\23\6\14\0\13\6"+ + "\1\u0125\6\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\7\6\1\327\17\6\14\0\22\6"+ + "\1\0\1\u0126\1\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\4\6\1\u0113\22\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\245\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\15\6\1\u0127\11\6\14\0\22\6\1\0"+ + "\1\u0128\1\6\1\0\27\6\14\0\22\6\1\0\1\u0129"+ + "\1\6\1\0\10\6\1\154\16\6\14\0\22\6\1\0"+ + "\2\6\1\0\2\6\1\146\24\6\14\0\13\6\1\u011c"+ + "\6\6\1\0\2\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\7\6\1\u012a\17\6\14\0\22\6\1\0"+ + "\2\6\1\0\5\6\1\u012b\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\5\6\1\u012c\21\6\14\0\22\6\1\0"+ + "\1\u012d\1\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\3\6\1\u012e\23\6\14\0\22\6\1\0\1\154"+ + "\1\6\1\0\27\6\14\0\22\6\1\0\1\u012f\1\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\10\6"+ + "\1\146\16\6\14\0\15\6\1\u0130\4\6\1\0\2\6"+ + "\1\0\27\6\14\0\22\6\1\0\1\u0131\1\6\1\0"+ + "\27\6\14\0\22\6\1\0\1\250\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\14\6\1\u0132\12\6"+ + "\14\0\22\6\1\0\1\u0133\1\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\7\6\1\u0134\17\6\14\0"+ + "\22\6\1\0\2\6\1\0\4\6\1\u0135\22\6\14\0"+ + "\22\6\1\0\2\6\1\0\1\265\26\6\14\0\15\6"+ + "\1\u0136\4\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\16\6\1\u0137\10\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\u0138\11\6\1\u0139\11\6"+ + "\14\0\13\6\1\244\6\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\3\6\1\u013a\23\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\u013b\26\6\14\0"+ + "\15\6\1\244\4\6\1\0\2\6\1\0\27\6\101\0"+ + "\1\45\40\0\1\u013c\56\0\1\350\70\0\1\u013d\64\0"+ + "\1\u013d\107\0\1\u013e\65\0\1\350\52\0\1\u013f\111\0"+ + "\1\u0140\66\0\1\u0141\34\0\22\6\1\0\1\u0142\1\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\5\6"+ + "\1\u0143\21\6\14\0\22\6\1\0\2\6\1\0\1\u0144"+ + "\13\6\1\234\12\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\u0145\26\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\u0146\24\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u0147\22\6\14\0\10\6\1\u0148\4\6\1\u0149\4\6"+ + "\1\0\2\6\1\0\27\6\14\0\10\6\1\u014a\11\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\5\6\1\u014b\21\6\14\0\22\6\1\0\2\6"+ + "\1\0\2\6\1\u014c\7\6\1\146\14\6\14\0\22\6"+ + "\1\0\2\6\1\0\2\6\1\327\24\6\14\0\6\6"+ + "\1\146\13\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\15\6\1\u014d\11\6\14\0\22\6"+ + "\1\0\2\6\1\0\1\300\26\6\14\0\21\6\1\u014e"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\7\6\1\u014f\17\6\14\0\22\6\1\0\2\6"+ + "\1\0\11\6\1\u0150\15\6\14\0\22\6\1\0\2\6"+ + "\1\0\5\6\1\124\21\6\14\0\1\6\1\u0151\20\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\1\u0152"+ + "\1\6\1\0\27\6\14\0\15\6\1\317\4\6\1\0"+ + "\2\6\1\0\3\6\1\u0153\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\6\6\1\231\1\6\1\u0154\16\6\14\0"+ + "\15\6\1\u0155\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\24\6\1\u0156\2\6\14\0"+ + "\22\6\1\0\2\6\1\0\25\6\1\146\1\6\14\0"+ + "\22\6\1\0\2\6\1\0\10\6\1\u0121\16\6\14\0"+ + "\22\6\1\0\2\6\1\0\10\6\1\u0157\16\6\14\0"+ + "\22\6\1\0\2\6\1\0\7\6\1\146\17\6\14\0"+ + "\22\6\1\0\2\6\1\0\4\6\1\u0158\22\6\14\0"+ + "\22\6\1\0\2\6\1\0\14\6\1\u0159\12\6\14\0"+ + "\22\6\1\0\2\6\1\0\14\6\1\146\12\6\14\0"+ + "\22\6\1\0\2\6\1\0\3\6\1\u0150\23\6\14\0"+ + "\22\6\1\0\2\6\1\0\5\6\1\u015a\21\6\14\0"+ + "\22\6\1\0\2\6\1\0\6\6\1\146\20\6\14\0"+ + "\22\6\1\0\2\6\1\0\6\6\1\304\20\6\14\0"+ + "\22\6\1\0\2\6\1\0\4\6\1\u015b\22\6\14\0"+ + "\22\6\1\0\2\6\1\0\3\6\1\u010f\23\6\14\0"+ + "\22\6\1\0\2\6\1\0\7\6\1\u015c\17\6\14\0"+ + "\15\6\1\u015d\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\6\6\1\u015e\13\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\12\6\1\u015e\14\6\14\0"+ + "\22\6\1\0\2\6\1\0\3\6\1\244\2\6\1\u0137"+ + "\20\6\14\0\13\6\1\u015f\6\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\1\u0160\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\12\6\1\u0161\14\6"+ + "\14\0\22\6\1\0\2\6\1\0\4\6\1\u0109\22\6"+ + "\14\0\22\6\1\0\2\6\1\0\5\6\1\u0162\21\6"+ + "\14\0\22\6\1\0\2\6\1\0\3\6\1\146\23\6"+ + "\14\0\22\6\1\0\2\6\1\0\4\6\1\u0163\22\6"+ + "\14\0\22\6\1\0\2\6\1\0\11\6\1\146\15\6"+ + "\14\0\22\6\1\0\2\6\1\0\13\6\1\146\13\6"+ + "\14\0\10\6\1\u0164\11\6\1\0\2\6\1\0\27\6"+ + "\14\0\10\6\1\u0165\11\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\5\6\1\u0166\21\6"+ + "\14\0\10\6\1\u011e\11\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\10\6\1\u0167\16\6"+ + "\14\0\15\6\1\u0137\4\6\1\0\2\6\1\0\27\6"+ + "\14\0\21\6\1\u0168\1\0\2\6\1\0\5\6\1\250"+ + "\1\6\1\u0169\17\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\250\26\6\14\0\22\6\1\0\2\6\1\0\3\6"+ + "\1\u016a\23\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\u016b\24\6\14\0\22\6\1\0\2\6\1\0\7\6"+ + "\1\244\17\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u016c\22\6\14\0\22\6\1\0\2\6\1\0\10\6"+ + "\1\u016d\16\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u0136\22\6\14\0\22\6\1\0\2\6\1\0\15\6"+ + "\1\u016e\11\6\14\0\22\6\1\0\2\6\1\0\2\6"+ + "\1\u016f\24\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u0170\22\6\14\0\22\6\1\0\2\6\1\0\3\6"+ + "\1\314\23\6\14\0\15\6\1\317\4\6\1\0\2\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\1\u0171"+ + "\26\6\14\0\22\6\1\0\2\6\1\0\5\6\1\231"+ + "\21\6\14\0\22\6\1\0\2\6\1\0\1\u0172\26\6"+ + "\14\0\22\6\1\0\1\u0173\1\6\1\0\27\6\14\0"+ + "\22\6\1\0\1\u0174\1\6\1\0\27\6\14\0\13\6"+ + "\1\u015b\6\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\166\23\6\50\0\1\u013d"+ + "\66\0\1\u013d\51\0\1\u0175\107\0\1\u0176\76\0\1\u0177"+ + "\30\0\10\6\1\u0178\11\6\1\0\2\6\1\0\27\6"+ + "\14\0\21\6\1\u0126\1\0\2\6\1\0\27\6\14\0"+ + "\15\6\1\252\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\16\6\1\244\10\6\14\0"+ + "\22\6\1\0\2\6\1\0\3\6\1\u014e\23\6\14\0"+ + "\10\6\1\u0179\11\6\1\0\2\6\1\0\27\6\14\0"+ + "\15\6\1\u017a\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\1\u017b\1\6\1\0\27\6\14\0\22\6"+ + "\1\0\1\u017c\1\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\6\6\1\u017d\20\6\14\0\13\6\1\u017e"+ + "\6\6\1\0\2\6\1\0\27\6\14\0\22\6\1\0"+ + "\1\116\1\6\1\0\27\6\14\0\10\6\1\u017f\11\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\6\6\1\u0180\20\6\14\0\1\6\1\u0123\20\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\1\u0181"+ + "\1\6\1\0\7\6\1\u0182\17\6\14\0\22\6\1\0"+ + "\2\6\1\0\7\6\1\u0183\17\6\14\0\22\6\1\0"+ + "\1\u0184\1\6\1\0\20\6\1\146\1\u0185\1\u0106\1\u0186"+ + "\3\6\14\0\22\6\1\0\2\6\1\0\15\6\1\146"+ + "\11\6\14\0\22\6\1\0\2\6\1\0\3\6\1\u0187"+ + "\23\6\14\0\22\6\1\0\2\6\1\0\20\6\1\u0188"+ + "\6\6\14\0\22\6\1\0\2\6\1\0\15\6\1\u0139"+ + "\11\6\14\0\22\6\1\0\2\6\1\0\3\6\1\u0189"+ + "\23\6\14\0\22\6\1\0\2\6\1\0\1\u018a\26\6"+ + "\14\0\22\6\1\0\2\6\1\0\7\6\1\340\17\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\u0178\26\6\14\0"+ + "\21\6\1\u018b\1\0\2\6\1\0\27\6\14\0\15\6"+ + "\1\u0120\4\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\15\6\1\u018c\11\6\14\0\15\6"+ + "\1\u011e\4\6\1\0\2\6\1\0\27\6\14\0\10\6"+ + "\1\u018d\11\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\5\6\1\u018e\21\6\14\0\10\6"+ + "\1\u018f\11\6\1\0\2\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\1\u0125\26\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\u0190\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\1\u0191\26\6\14\0\10\6\1\u0150\11\6"+ + "\1\0\2\6\1\0\27\6\14\0\17\6\1\146\2\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\1\u0167"+ + "\1\6\1\0\27\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\u017e\26\6\14\0\22\6\1\0\1\u0192\1\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\3\6\1\u014d"+ + "\23\6\14\0\17\6\1\u0193\2\6\1\0\2\6\1\0"+ + "\5\6\1\u0194\21\6\14\0\22\6\1\0\2\6\1\0"+ + "\7\6\1\u015d\17\6\14\0\22\6\1\0\2\6\1\0"+ + "\3\6\1\116\23\6\14\0\22\6\1\0\2\6\1\0"+ + "\15\6\1\u0193\11\6\14\0\22\6\1\0\2\6\1\0"+ + "\10\6\1\154\16\6\14\0\22\6\1\0\2\6\1\0"+ + "\3\6\1\u0195\23\6\14\0\22\6\1\0\2\6\1\0"+ + "\3\6\1\244\23\6\14\0\10\6\1\u0196\11\6\1\0"+ + "\2\6\1\0\27\6\14\0\22\6\1\0\2\6\1\0"+ + "\4\6\1\u0197\22\6\35\0\1\347\100\0\1\u013d\65\0"+ + "\1\u013d\42\0\15\6\1\146\4\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\1\u0198\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\2\6\1\u0199\24\6"+ + "\14\0\22\6\1\0\2\6\1\0\6\6\1\u0137\20\6"+ + "\14\0\22\6\1\0\2\6\1\0\15\6\1\u011e\11\6"+ + "\14\0\22\6\1\0\2\6\1\0\7\6\1\u0126\17\6"+ + "\14\0\22\6\1\0\2\6\1\0\12\6\1\244\14\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\u019a\26\6\14\0"+ + "\15\6\1\u019b\4\6\1\0\2\6\1\0\27\6\14\0"+ + "\6\6\1\u019c\13\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\10\6\1\u019d\16\6\14\0"+ + "\22\6\1\0\2\6\1\0\3\6\1\u019e\23\6\14\0"+ + "\22\6\1\0\2\6\1\0\4\6\1\u019f\22\6\14\0"+ + "\22\6\1\0\2\6\1\0\22\6\1\146\4\6\14\0"+ + "\22\6\1\0\2\6\1\0\24\6\1\146\2\6\14\0"+ + "\22\6\1\0\2\6\1\0\5\6\1\u01a0\21\6\14\0"+ + "\21\6\1\146\1\0\2\6\1\0\5\6\1\146\21\6"+ + "\14\0\13\6\1\u01a1\6\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\4\6\1\u01a2\22\6"+ + "\14\0\1\6\1\u01a3\20\6\1\0\2\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\10\6\1\u01a4\16\6"+ + "\14\0\22\6\1\0\2\6\1\0\1\u0196\26\6\14\0"+ + "\10\6\1\u01a5\11\6\1\0\2\6\1\0\27\6\14\0"+ + "\22\6\1\0\2\6\1\0\5\6\1\u011e\21\6\14\0"+ + "\22\6\1\0\2\6\1\0\1\u01a6\26\6\14\0\22\6"+ + "\1\0\2\6\1\0\2\6\1\u011e\24\6\14\0\22\6"+ + "\1\0\2\6\1\0\4\6\1\u01a7\22\6\14\0\22\6"+ + "\1\0\2\6\1\0\1\u01a8\26\6\14\0\22\6\1\0"+ + "\2\6\1\0\10\6\1\u01a9\16\6\14\0\22\6\1\0"+ + "\2\6\1\0\10\6\1\116\16\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\327\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\u0120\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\5\6\1\332\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\15\6\1\u01aa\11\6\14\0\15\6\1\u0178"+ + "\4\6\1\0\2\6\1\0\27\6\14\0\22\6\1\0"+ + "\1\u01ab\1\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\5\6\1\u01ac\21\6\14\0\22\6\1\0\2\6"+ + "\1\0\3\6\1\u01ad\23\6\14\0\22\6\1\0\2\6"+ + "\1\0\5\6\1\u01ae\21\6\14\0\17\6\1\u0193\2\6"+ + "\1\0\2\6\1\0\27\6\14\0\22\6\1\0\2\6"+ + "\1\0\15\6\1\u0180\11\6\14\0\22\6\1\0\2\6"+ + "\1\0\1\u01af\26\6\14\0\1\6\1\u01b0\20\6\1\0"+ + "\2\6\1\0\27\6\14\0\22\6\1\0\2\6\1\0"+ + "\1\313\26\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u011e\22\6\14\0\22\6\1\0\2\6\1\0\7\6"+ + "\1\u0120\17\6\14\0\22\6\1\0\2\6\1\0\15\6"+ + "\1\u01b1\11\6\14\0\10\6\1\244\11\6\1\0\2\6"+ + "\1\0\27\6\14\0\22\6\1\0\2\6\1\0\4\6"+ + "\1\u01b2\22\6\14\0\22\6\1\0\1\231\1\6\1\0"+ + "\27\6\14\0\1\6\1\u01b3\20\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\2\6\1\u01b4"+ + "\24\6\14\0\1\6\1\u01b5\20\6\1\0\2\6\1\0"+ + "\27\6\14\0\17\6\1\u01b6\2\6\1\0\2\6\1\0"+ + "\27\6\14\0\15\6\1\u01ab\4\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\3\6\1\u01b7"+ + "\23\6\14\0\22\6\1\0\2\6\1\0\4\6\1\u01b8"+ + "\22\6\14\0\1\6\1\u0130\20\6\1\0\2\6\1\0"+ + "\27\6\14\0\22\6\1\0\2\6\1\0\5\6\1\u01b9"+ + "\21\6\14\0\22\6\1\0\2\6\1\0\3\6\1\313"+ + "\23\6\14\0\22\6\1\0\1\u0181\1\6\1\0\27\6"+ + "\14\0\22\6\1\0\2\6\1\0\5\6\1\u014d\21\6"+ + "\14\0\22\6\1\0\2\6\1\0\27\6\1\u01ba\13\0"+ + "\22\6\1\0\1\u01bb\1\6\1\0\27\6\14\0\22\6"+ + "\1\0\2\6\1\0\7\6\1\u01bc\17\6\14\0\22\6"+ + "\1\0\2\6\1\0\3\6\1\u01a5\23\6\14\0\22\6"+ + "\1\0\2\6\1\0\14\6\1\u01bd\12\6\14\0\22\6"+ + "\1\0\1\u01be\1\6\1\0\27\6\14\0\22\6\1\0"+ + "\2\6\1\0\4\6\1\u01bf\22\6\14\0\22\6\1\0"+ + "\2\6\1\0\5\6\1\u01c0\21\6\14\0\22\6\1\0"+ + "\2\6\1\0\3\6\1\u01c1\23\6\14\0\22\6\1\0"+ + "\2\6\1\0\1\u01c2\26\6\14\0\22\6\1\0\2\6"+ + "\1\0\7\6\1\u01a8\17\6\12\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[24681]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\3\0\1\11\15\1\1\11\15\1\1\11\4\1\1\11"+ + "\1\1\1\11\3\1\6\0\6\1\1\11\2\1\1\0"+ + "\74\1\4\0\1\1\3\0\2\11\1\1\7\0\1\1"+ + "\3\0\24\1\1\0\103\1\11\0\116\1\1\0\1\11"+ + "\4\0\63\1\3\0\102\1\1\11\10\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[450]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte CPP_COMMENT_STYLE = 7; + public static final byte DOXYGEN_COMMENT_STYLE = 8; + public static final byte DOXYGEN_TAG_STYLE = 9; + public static final byte PREPROC_STYLE = 10; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 10; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public CppHighlighter() + { + } + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public CppHighlighter(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public CppHighlighter(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1674) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzPushbackPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead < 0) { + return true; + } + else { + zzEndRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public int yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 12: + { return DOXYGEN_TAG_STYLE; + } + case 15: break; + case 6: + { return DOXYGEN_COMMENT_STYLE; + } + case 16: break; + case 1: + { return PLAIN_STYLE; + } + case 17: break; + case 8: + { return KEYWORD_STYLE; + } + case 18: break; + case 14: + { yybegin(IN_DOXYGEN_COMMENT); return DOXYGEN_COMMENT_STYLE; + } + case 19: break; + case 4: + { return OPERATOR_STYLE; + } + case 20: break; + case 2: + { return LITERAL_STYLE; + } + case 21: break; + case 3: + { return SEPARATOR_STYLE; + } + case 22: break; + case 7: + { return TYPE_STYLE; + } + case 23: break; + case 5: + { return CPP_COMMENT_STYLE; + } + case 24: break; + case 11: + { yybegin(YYINITIAL); return DOXYGEN_COMMENT_STYLE; + } + case 25: break; + case 9: + { yybegin(IN_COMMENT); return CPP_COMMENT_STYLE; + } + case 26: break; + case 10: + { yybegin(YYINITIAL); return CPP_COMMENT_STYLE; + } + case 27: break; + case 13: + { return PREPROC_STYLE; + } + case 28: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return YYEOF; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/ExplicitStateHighlighter.java b/src/main/java/com/uwyn/jhighlight/highlighter/ExplicitStateHighlighter.java new file mode 100644 index 0000000..21c8028 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/ExplicitStateHighlighter.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: ExplicitStateHighlighter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.IOException; +import java.io.Reader; + +/** + * Provides access to the lexical scanning of a highlighted language. + * + * @author Omnicore Software + * @author Hans Kratz & Dennis Strein GbR + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public interface ExplicitStateHighlighter +{ + /** + * Sets the reader that will be used to receive the text data. + * + * @param reader the Reader that has to be used + */ + void setReader(Reader reader); + + /** + * Obtain the next token from the scanner. + * + * @return one of the tokens that are define in the scanner + * @exception IOException when an error occurred during the parsing of + * the reader + */ + byte getNextToken() throws IOException; + + /** + * Returns the length of the matched text region. + * + * @return the length of the matched text region + */ + int getTokenLength(); +} diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.flex b/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.flex new file mode 100644 index 0000000..51fee62 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.flex @@ -0,0 +1,301 @@ +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id$ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + +%% + +%class GroovyHighlighter +%implements ExplicitStateHighlighter + +%unicode +%pack + +%buffer 128 + +%public + +%int + +%{ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte JAVA_COMMENT_STYLE = 7; + public static final byte JAVADOC_COMMENT_STYLE = 8; + public static final byte JAVADOC_TAG_STYLE = 9; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 9; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public GroovyHighlighter() + { + } +%} + +/* main character classes */ + +WhiteSpace = [ \t\f] + +/* identifiers */ + +ConstantIdentifier = {SimpleConstantIdentifier} +SimpleConstantIdentifier = [A-Z0-9_]+ + +Identifier = [:jletter:][:jletterdigit:]* + +TypeIdentifier = {SimpleTypeIdentifier} +SimpleTypeIdentifier = [A-Z][:jletterdigit:]* + +/* int literals */ + +DecLiteral = 0 | [1-9][0-9]* [lL]? + +HexLiteral = 0 [xX] 0* {HexDigit}* [lL]? +HexDigit = [0-9a-fA-F] + +OctLiteral = 0+ {OctDigit}* [lL]? +OctDigit = [0-7] + +/* float literals */ + +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? + +FLit1 = [0-9]+ \. [0-9]* {Exponent}? +FLit2 = \. [0-9]+ {Exponent}? +FLit3 = [0-9]+ {Exponent} +FLit4 = [0-9]+ {Exponent}? + +Exponent = [eE] [+\-]? [0-9]+ + +%state IN_HEREDOC, IN_COMMENT, IN_JAVA_DOC_COMMENT + +%% + + { + + /* keywords */ + "abstract" | + "as" | + "assert" | + "break" | + "case" | + "catch" | + "class" | + "const" | + "continue" | + "def" | + "do" | + "else" | + "extends" | + "final" | + "finally" | + "for" | + "default" | + "implements" | + "import" | + "in" | + "instanceof" | + "interface" | + "mixin" | + "native" | + "new" | + "goto" | + "if" | + "public" | + "super" | + "switch" | + "synchronized" | + "package" | + "private" | + "protected" | + "transient" | + "return" | + "static" | + "while" | + "this" | + "throw" | + "throws" | + "try" | + "volatile" | + "strictfp" { return KEYWORD_STYLE; } + + "boolean" | + "byte" | + "char" | + "double" | + "int" | + "long" | + "float" | + "short" | + "void" { return TYPE_STYLE; } + + /* literals */ + "true" | + "false" | + "null" | + + (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | + (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) | + + {DecLiteral} | + {HexLiteral} | + {OctLiteral} | + + {FloatLiteral} + { return LITERAL_STYLE; } + + "\"\"\"" { yybegin(IN_HEREDOC); return LITERAL_STYLE;} + + /* separators */ + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." { return SEPARATOR_STYLE; } + + /* operators */ + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" { return OPERATOR_STYLE; } + + {ConstantIdentifier} { return PLAIN_STYLE; } + + {TypeIdentifier} { return TYPE_STYLE; } + + \n | + {Identifier} | + {WhiteSpace} { return PLAIN_STYLE; } + + + +// single line comment + + "//" [^\n]* \n | + +// short comment + + "/**/" { return JAVA_COMMENT_STYLE; } + +// comment start + + "/**" { yybegin(IN_JAVA_DOC_COMMENT); return JAVADOC_COMMENT_STYLE;} + "/*" { yybegin(IN_COMMENT); return JAVA_COMMENT_STYLE;} + +} + + +// normal comment mode + + { + + + // comment unterminated + + .|\n { return LITERAL_STYLE; } + + // comment terminated + + \"\"\" { yybegin(YYINITIAL); return LITERAL_STYLE; } + +} + +// normal comment mode + + { + + + // comment unterminated + + ([^\n*]|\*+[^\n*/])* (\n | \*+\n) { return JAVA_COMMENT_STYLE; } + + // comment terminated + + ([^\n*]|\*+[^\n*/])* \*+ "/" { yybegin(YYINITIAL); return JAVA_COMMENT_STYLE; } + +} + +// doc comment mode + + { + + // comment unterminated + + .|\n { return JAVADOC_COMMENT_STYLE; } + + // comment terminated + + \* "/" { yybegin(YYINITIAL); return JAVADOC_COMMENT_STYLE; } + + + "@" {Identifier} { return JAVADOC_TAG_STYLE; } + +} + +/* error fallback */ + +.|\n { return PLAIN_STYLE; } diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.java b/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.java new file mode 100644 index 0000000..979f0a2 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/GroovyHighlighter.java @@ -0,0 +1,962 @@ +/* The following code was generated by JFlex 1.4.1 on 3/13/06 6:15 PM */ + +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of the GNU Lesser General Public License, v2.1 or later + * $Id: GroovyHighlighter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + + +/** + * This class is a scanner generated by + * JFlex 1.4.1 + * on 3/13/06 6:15 PM from the specification file + * com/uwyn/jhighlight/highlighter/GroovyHighlighter.flex + */ +public class GroovyHighlighter implements ExplicitStateHighlighter { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 128; + + /** lexical states */ + public static final int IN_HEREDOC = 1; + public static final int YYINITIAL = 0; + public static final int IN_COMMENT = 2; + public static final int IN_JAVA_DOC_COMMENT = 3; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\4\1\0\1\50\1\0\1\0\1\0\16\4\4\0\1\0\1\54"+ + "\1\47\1\0\1\2\1\54\1\54\1\52\1\53\1\53\1\55\1\24"+ + "\1\53\1\24\1\21\1\56\1\6\7\15\2\1\1\54\1\53\1\54"+ + "\1\54\1\54\1\54\1\57\3\14\1\17\1\23\1\17\5\5\1\10"+ + "\13\5\1\12\2\5\1\53\1\51\1\53\1\54\1\3\1\0\1\25"+ + "\1\26\1\13\1\20\1\22\1\16\1\45\1\33\1\36\1\2\1\32"+ + "\1\7\1\41\1\35\1\34\1\42\1\2\1\31\1\27\1\30\1\37"+ + "\1\43\1\44\1\11\1\40\1\46\1\53\1\54\1\53\1\54\41\4"+ + "\2\0\4\2\4\0\1\2\12\0\1\2\4\0\1\2\5\0\27\2"+ + "\1\0\37\2\1\0\u0128\2\2\0\22\2\34\0\136\2\2\0\11\2"+ + "\2\0\7\2\16\0\2\2\16\0\5\2\11\0\1\2\21\0\117\4"+ + "\21\0\3\4\27\0\1\2\13\0\1\2\1\0\3\2\1\0\1\2"+ + "\1\0\24\2\1\0\54\2\1\0\10\2\2\0\32\2\14\0\202\2"+ + "\1\0\4\4\5\0\71\2\2\0\2\2\2\0\2\2\3\0\46\2"+ + "\2\0\2\2\67\0\46\2\2\0\1\2\7\0\47\2\11\0\21\4"+ + "\1\0\27\4\1\0\3\4\1\0\1\4\1\0\2\4\1\0\1\4"+ + "\13\0\33\2\5\0\3\2\56\0\32\2\5\0\13\2\13\4\12\0"+ + "\12\4\6\0\1\4\143\2\1\0\1\2\7\4\2\0\6\4\2\2"+ + "\2\4\1\0\4\4\2\0\12\4\3\2\22\0\1\4\1\2\1\4"+ + "\33\2\3\0\33\4\65\0\46\2\13\4\u0150\0\3\4\1\0\65\2"+ + "\2\0\1\4\1\2\20\4\2\0\1\2\4\4\3\0\12\2\2\4"+ + "\2\0\12\4\21\0\3\4\1\0\10\2\2\0\2\2\2\0\26\2"+ + "\1\0\7\2\1\0\1\2\3\0\4\2\2\0\1\4\1\0\7\4"+ + "\2\0\2\4\2\0\3\4\11\0\1\4\4\0\2\2\1\0\3\2"+ + "\2\4\2\0\12\4\4\2\16\0\1\4\2\0\6\2\4\0\2\2"+ + "\2\0\26\2\1\0\7\2\1\0\2\2\1\0\2\2\1\0\2\2"+ + "\2\0\1\4\1\0\5\4\4\0\2\4\2\0\3\4\13\0\4\2"+ + "\1\0\1\2\7\0\14\4\3\2\14\0\3\4\1\0\7\2\1\0"+ + "\1\2\1\0\3\2\1\0\26\2\1\0\7\2\1\0\2\2\1\0"+ + "\5\2\2\0\1\4\1\2\10\4\1\0\3\4\1\0\3\4\2\0"+ + "\1\2\17\0\1\2\5\0\12\4\21\0\3\4\1\0\10\2\2\0"+ + "\2\2\2\0\26\2\1\0\7\2\1\0\2\2\2\0\4\2\2\0"+ + "\1\4\1\2\6\4\3\0\2\4\2\0\3\4\10\0\2\4\4\0"+ + "\2\2\1\0\3\2\4\0\12\4\22\0\2\4\1\0\6\2\3\0"+ + "\3\2\1\0\4\2\3\0\2\2\1\0\1\2\1\0\2\2\3\0"+ + "\2\2\3\0\3\2\3\0\10\2\1\0\3\2\4\0\5\4\3\0"+ + "\3\4\1\0\4\4\11\0\1\4\17\0\11\4\21\0\3\4\1\0"+ + "\10\2\1\0\3\2\1\0\27\2\1\0\12\2\1\0\5\2\4\0"+ + "\7\4\1\0\3\4\1\0\4\4\7\0\2\4\11\0\2\2\4\0"+ + "\12\4\22\0\2\4\1\0\10\2\1\0\3\2\1\0\27\2\1\0"+ + "\12\2\1\0\5\2\4\0\7\4\1\0\3\4\1\0\4\4\7\0"+ + "\2\4\7\0\1\2\1\0\2\2\4\0\12\4\22\0\2\4\1\0"+ + "\10\2\1\0\3\2\1\0\27\2\1\0\20\2\4\0\6\4\2\0"+ + "\3\4\1\0\4\4\11\0\1\4\10\0\2\2\4\0\12\4\22\0"+ + "\2\4\1\0\22\2\3\0\30\2\1\0\11\2\1\0\1\2\2\0"+ + "\7\2\3\0\1\4\4\0\6\4\1\0\1\4\1\0\10\4\22\0"+ + "\2\4\15\0\60\2\1\4\2\2\7\4\4\0\10\2\10\4\1\0"+ + "\12\4\47\0\2\2\1\0\1\2\2\0\2\2\1\0\1\2\2\0"+ + "\1\2\6\0\4\2\1\0\7\2\1\0\3\2\1\0\1\2\1\0"+ + "\1\2\2\0\2\2\1\0\4\2\1\4\2\2\6\4\1\0\2\4"+ + "\1\2\2\0\5\2\1\0\1\2\1\0\6\4\2\0\12\4\2\0"+ + "\2\2\42\0\1\2\27\0\2\4\6\0\12\4\13\0\1\4\1\0"+ + "\1\4\1\0\1\4\4\0\2\4\10\2\1\0\42\2\6\0\24\4"+ + "\1\0\2\4\4\2\4\0\10\4\1\0\44\4\11\0\1\4\71\0"+ + "\42\2\1\0\5\2\1\0\2\2\1\0\7\4\3\0\4\4\6\0"+ + "\12\4\6\0\6\2\4\4\106\0\46\2\12\0\47\2\11\0\132\2"+ + "\5\0\104\2\5\0\122\2\6\0\7\2\1\0\77\2\1\0\1\2"+ + "\1\0\4\2\2\0\7\2\1\0\1\2\1\0\4\2\2\0\47\2"+ + "\1\0\1\2\1\0\4\2\2\0\37\2\1\0\1\2\1\0\4\2"+ + "\2\0\7\2\1\0\1\2\1\0\4\2\2\0\7\2\1\0\7\2"+ + "\1\0\27\2\1\0\37\2\1\0\1\2\1\0\4\2\2\0\7\2"+ + "\1\0\47\2\1\0\23\2\16\0\11\4\56\0\125\2\14\0\u026c\2"+ + "\2\0\10\2\12\0\32\2\5\0\113\2\225\0\64\2\40\4\7\0"+ + "\1\2\4\0\12\4\41\0\4\4\1\0\12\4\6\0\130\2\10\0"+ + "\51\2\1\4\u0556\0\234\2\4\0\132\2\6\0\26\2\2\0\6\2"+ + "\2\0\46\2\2\0\6\2\2\0\10\2\1\0\1\2\1\0\1\2"+ + "\1\0\1\2\1\0\37\2\2\0\65\2\1\0\7\2\1\0\1\2"+ + "\3\0\3\2\1\0\7\2\3\0\4\2\2\0\6\2\4\0\15\2"+ + "\5\0\3\2\1\0\7\2\17\0\4\4\32\0\5\4\20\0\2\2"+ + "\51\0\6\4\17\0\1\2\40\0\20\2\40\0\15\4\4\0\1\4"+ + "\40\0\1\2\4\0\1\2\2\0\12\2\1\0\1\2\3\0\5\2"+ + "\6\0\1\2\1\0\1\2\1\0\1\2\1\0\4\2\1\0\3\2"+ + "\1\0\7\2\46\0\44\2\u0e81\0\3\2\31\0\11\2\6\4\1\0"+ + "\5\2\2\0\3\2\6\0\124\2\4\0\2\4\2\0\2\2\2\0"+ + "\136\2\6\0\50\2\4\0\136\2\21\0\30\2\u0248\0\u19b6\2\112\0"+ + "\u51a6\2\132\0\u048d\2\u0773\0\u2ba4\2\u215c\0\u012e\2\322\0\7\2\14\0"+ + "\5\2\5\0\1\2\1\4\12\2\1\0\15\2\1\0\5\2\1\0"+ + "\1\2\1\0\2\2\1\0\2\2\1\0\154\2\41\0\u016b\2\22\0"+ + "\100\2\2\0\66\2\50\0\14\2\44\0\4\4\17\0\2\2\30\0"+ + "\3\2\31\0\1\2\6\0\3\2\1\0\1\2\1\0\207\2\2\0"+ + "\1\4\4\0\1\2\13\0\12\4\7\0\32\2\4\0\1\2\1\0"+ + "\32\2\12\0\132\2\3\0\6\2\2\0\6\2\2\0\6\2\2\0"+ + "\3\2\3\0\2\2\3\0\2\2\22\0\3\4\4\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\4\0\1\1\1\2\2\1\1\2\4\1\1\3\1\1"+ + "\1\4\16\1\1\3\1\4\2\2\1\1\1\5\1\1"+ + "\3\6\1\1\2\2\1\0\1\1\1\7\4\2\12\1"+ + "\1\10\3\1\1\10\16\1\2\10\10\1\1\0\1\2"+ + "\3\0\1\11\4\0\1\12\1\13\1\14\1\2\1\0"+ + "\1\2\11\1\1\10\25\1\1\7\12\1\1\15\1\16"+ + "\1\17\1\7\20\1\1\2\14\1\1\10\10\1\1\10"+ + "\36\1"; + + private static int [] zzUnpackAction() { + int [] result = new int[220]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150"+ + "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\u02a0\0\300"+ + "\0\u02d0\0\u0300\0\u0330\0\u0360\0\u0390\0\u03c0\0\u03f0\0\u0420"+ + "\0\u0450\0\u0480\0\u04b0\0\u04e0\0\u0510\0\u0540\0\300\0\u0570"+ + "\0\300\0\u05a0\0\u05d0\0\300\0\u0600\0\300\0\u0630\0\u0660"+ + "\0\u0690\0\u0690\0\u06c0\0\u06f0\0\u0720\0\u0750\0\u0780\0\u07b0"+ + "\0\u07e0\0\u0810\0\u0840\0\u0870\0\u08a0\0\u08d0\0\u0900\0\u0930"+ + "\0\u0960\0\u0990\0\u09c0\0\u09f0\0\u0a20\0\u0a50\0\u0a80\0\u0ab0"+ + "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\u0ba0\0\u0bd0\0\u0c00\0\u0c30"+ + "\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\u0d20\0\u0d50\0\u0d80\0\u0120"+ + "\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u0ea0\0\u0ed0\0\u0f00"+ + "\0\u0f30\0\u0f60\0\u0f90\0\u0fc0\0\u0540\0\u0ff0\0\u1020\0\u1050"+ + "\0\u1080\0\u05d0\0\u0600\0\300\0\300\0\u10b0\0\u10e0\0\u1110"+ + "\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200\0\u1230\0\u1260\0\u1290"+ + "\0\u12c0\0\u12f0\0\u1320\0\u1350\0\u1380\0\u13b0\0\u13e0\0\u1410"+ + "\0\u1440\0\u1470\0\u14a0\0\u14d0\0\u1500\0\u1530\0\u1560\0\u1590"+ + "\0\u15c0\0\u15f0\0\u1620\0\u1650\0\u1680\0\u16b0\0\u16e0\0\u1710"+ + "\0\u1740\0\u1770\0\u17a0\0\u17d0\0\u1800\0\u1830\0\u1860\0\u1890"+ + "\0\u18c0\0\u18f0\0\u1920\0\300\0\u1950\0\300\0\u0120\0\u1980"+ + "\0\u19b0\0\u19e0\0\u1a10\0\u1a40\0\u1a70\0\u1aa0\0\u1ad0\0\u1b00"+ + "\0\u1b30\0\u1b60\0\u1b90\0\u1bc0\0\u1bf0\0\u1c20\0\u1c50\0\u0120"+ + "\0\u1c80\0\u1cb0\0\u1ce0\0\u1d10\0\u1d40\0\u1d70\0\u1da0\0\u1dd0"+ + "\0\u1e00\0\u1e30\0\u1e60\0\u1e90\0\u1ec0\0\u1ef0\0\u1f20\0\u1f50"+ + "\0\u1f80\0\u1fb0\0\u1fe0\0\u2010\0\u2040\0\u1650\0\u2070\0\u20a0"+ + "\0\u20d0\0\u2100\0\u2130\0\u2160\0\u2190\0\u21c0\0\u21f0\0\u2220"+ + "\0\u2250\0\u2280\0\u22b0\0\u22e0\0\u2310\0\u2340\0\u2370\0\u23a0"+ + "\0\u23d0\0\u2400\0\u2430\0\u2460\0\u2490\0\u24c0\0\u24f0\0\u2520"+ + "\0\u2550\0\u2580\0\u25b0\0\u25e0"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[220]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\5\1\6\2\7\1\5\1\10\1\11\1\12\1\10"+ + "\1\7\1\10\1\13\1\10\1\6\1\14\1\10\1\15"+ + "\1\16\1\17\1\10\1\20\1\21\1\22\1\23\1\24"+ + "\1\25\3\7\1\26\1\27\2\7\1\30\1\31\1\32"+ + "\1\33\1\34\1\7\1\35\2\5\1\36\1\37\2\20"+ + "\1\40\1\5\47\41\1\42\10\41\50\43\1\44\4\43"+ + "\1\45\2\43\55\46\1\47\1\46\1\50\61\0\1\6"+ + "\1\0\1\51\1\0\1\51\1\6\1\41\1\52\1\0"+ + "\1\51\1\0\1\51\1\6\1\41\1\52\1\41\1\53"+ + "\1\54\1\55\35\0\20\7\1\0\2\7\1\0\22\7"+ + "\12\0\1\10\1\56\1\10\1\56\2\10\1\56\1\10"+ + "\1\56\1\10\1\56\2\10\1\56\1\10\1\56\1\0"+ + "\1\56\1\10\1\0\22\56\12\0\1\57\1\0\1\51"+ + "\1\0\1\51\1\60\1\41\1\52\1\61\1\62\1\0"+ + "\1\51\1\60\1\41\1\52\1\41\1\53\1\54\1\55"+ + "\35\0\20\7\1\0\2\7\1\0\7\7\1\63\12\7"+ + "\12\0\6\7\1\64\11\7\1\0\2\7\1\0\1\65"+ + "\5\7\1\66\1\67\12\7\12\0\6\7\1\70\11\7"+ + "\1\0\2\7\1\0\1\71\6\7\1\72\1\7\1\73"+ + "\10\7\12\0\20\7\1\0\1\74\1\7\1\0\7\7"+ + "\1\75\12\7\12\0\1\53\4\0\1\53\6\0\1\53"+ + "\43\0\6\7\1\76\1\7\1\77\7\7\1\0\2\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\1\7"+ + "\1\100\1\101\17\7\12\0\20\7\1\0\2\7\1\0"+ + "\4\7\1\102\2\7\1\103\3\7\1\104\6\7\12\0"+ + "\20\7\1\0\2\7\1\0\3\7\1\105\2\7\1\106"+ + "\3\7\1\107\1\110\3\7\1\111\2\7\12\0\20\7"+ + "\1\0\2\7\1\0\4\7\1\112\1\7\1\113\13\7"+ + "\12\0\20\7\1\0\1\114\1\7\1\0\22\7\12\0"+ + "\20\7\1\0\1\115\1\7\1\0\1\116\11\7\1\117"+ + "\7\7\12\0\15\7\1\120\2\7\1\0\2\7\1\0"+ + "\10\7\1\121\3\7\1\122\5\7\12\0\20\7\1\0"+ + "\2\7\1\0\11\7\1\123\10\7\12\0\20\7\1\0"+ + "\2\7\1\0\1\124\3\7\1\125\5\7\1\126\7\7"+ + "\12\0\20\7\1\0\2\7\1\0\7\7\1\127\12\7"+ + "\12\0\20\7\1\0\2\7\1\0\6\7\1\130\13\7"+ + "\12\0\20\7\1\0\2\7\1\0\7\7\1\131\12\7"+ + "\11\0\47\132\1\133\1\41\1\134\6\132\50\135\1\41"+ + "\1\136\1\41\5\135\55\0\1\137\1\140\50\0\1\141"+ + "\10\0\50\142\1\44\4\142\1\143\52\142\1\44\4\142"+ + "\1\143\1\144\1\142\56\0\1\145\3\0\2\146\1\0"+ + "\1\146\1\0\6\146\1\0\3\146\1\0\2\146\1\0"+ + "\22\146\12\0\1\51\1\0\1\51\1\0\2\51\1\0"+ + "\1\51\1\0\1\51\1\0\2\51\1\0\1\51\3\0"+ + "\1\51\35\0\1\53\4\0\1\53\6\0\1\53\3\41"+ + "\1\0\2\54\35\0\1\147\4\0\1\147\6\0\1\147"+ + "\6\0\1\150\34\0\1\151\1\0\1\51\1\0\1\51"+ + "\1\151\1\0\1\51\1\0\1\51\1\0\1\51\1\151"+ + "\1\0\1\51\3\0\1\51\1\150\34\0\20\56\1\0"+ + "\2\56\1\0\22\56\12\0\1\57\1\0\1\51\1\0"+ + "\1\51\1\57\1\0\1\51\1\0\1\51\1\0\1\51"+ + "\1\57\1\41\1\52\1\41\1\53\1\54\1\55\35\0"+ + "\1\57\1\0\1\51\1\0\1\51\1\60\1\41\1\52"+ + "\1\0\1\51\1\0\1\51\1\60\1\41\1\52\1\41"+ + "\1\53\1\54\1\55\35\0\1\61\4\0\1\61\2\41"+ + "\2\0\6\61\1\0\2\61\1\0\2\61\32\0\1\62"+ + "\1\0\1\51\1\0\1\51\1\62\1\41\1\52\1\0"+ + "\1\51\1\61\2\62\1\61\1\62\1\61\1\0\1\61"+ + "\1\62\1\0\2\61\32\0\20\7\1\0\2\7\1\0"+ + "\10\7\1\152\11\7\12\0\20\7\1\0\2\7\1\0"+ + "\1\153\21\7\12\0\20\7\1\0\2\7\1\0\2\7"+ + "\1\154\1\155\16\7\12\0\20\7\1\0\2\7\1\0"+ + "\1\156\21\7\12\0\20\7\1\0\2\7\1\0\10\7"+ + "\1\157\11\7\12\0\20\7\1\0\2\7\1\0\7\7"+ + "\1\160\12\7\12\0\6\7\1\161\11\7\1\0\2\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\4\7"+ + "\1\120\15\7\12\0\20\7\1\0\2\7\1\0\10\7"+ + "\1\162\11\7\12\0\15\7\1\163\2\7\1\0\2\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\12\7"+ + "\1\164\7\7\12\0\20\7\1\0\2\7\1\0\2\7"+ + "\1\154\17\7\12\0\20\7\1\0\2\7\1\0\3\7"+ + "\1\165\16\7\12\0\20\7\1\0\2\7\1\0\2\7"+ + "\1\166\17\7\12\0\20\7\1\0\2\7\1\0\2\7"+ + "\1\167\17\7\12\0\20\7\1\0\1\170\1\7\1\0"+ + "\22\7\12\0\20\7\1\0\2\7\1\0\7\7\1\171"+ + "\12\7\12\0\20\7\1\0\2\7\1\0\3\7\1\172"+ + "\16\7\12\0\20\7\1\0\2\7\1\0\1\173\3\7"+ + "\1\174\15\7\12\0\20\7\1\0\2\7\1\0\7\7"+ + "\1\175\12\7\12\0\20\7\1\0\2\7\1\0\15\7"+ + "\1\176\4\7\12\0\20\7\1\0\2\7\1\0\10\7"+ + "\1\177\11\7\12\0\20\7\1\0\2\7\1\0\11\7"+ + "\1\200\10\7\12\0\20\7\1\0\2\7\1\0\1\201"+ + "\11\7\1\202\1\120\6\7\12\0\20\7\1\0\2\7"+ + "\1\0\4\7\1\203\4\7\1\204\10\7\12\0\20\7"+ + "\1\0\2\7\1\0\3\7\1\205\16\7\12\0\20\7"+ + "\1\0\2\7\1\0\17\7\1\120\2\7\12\0\20\7"+ + "\1\0\2\7\1\0\3\7\1\206\16\7\12\0\6\7"+ + "\1\207\11\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\2\7\1\210\1\211\16\7\12\0"+ + "\20\7\1\0\2\7\1\0\15\7\1\212\4\7\12\0"+ + "\10\7\1\213\7\7\1\0\2\7\1\0\22\7\12\0"+ + "\12\7\1\214\5\7\1\0\2\7\1\0\22\7\12\0"+ + "\20\7\1\0\2\7\1\0\7\7\1\215\1\7\1\216"+ + "\10\7\12\0\20\7\1\0\2\7\1\0\1\7\1\217"+ + "\20\7\12\0\6\7\1\220\11\7\1\0\2\7\1\0"+ + "\11\7\1\221\10\7\12\0\20\7\1\0\2\7\1\0"+ + "\11\7\1\222\10\7\12\0\20\7\1\0\2\7\1\0"+ + "\3\7\1\223\16\7\11\0\47\132\2\41\1\134\6\132"+ + "\47\0\1\224\10\0\50\132\1\41\7\132\50\135\1\41"+ + "\7\135\55\0\1\225\2\0\50\140\1\44\7\140\47\0"+ + "\1\226\11\0\20\146\1\0\2\146\1\0\22\146\12\0"+ + "\1\147\4\0\1\147\6\0\1\147\3\41\40\0\1\147"+ + "\4\0\1\147\6\0\1\147\43\0\1\151\1\0\1\51"+ + "\1\0\1\51\1\151\1\0\1\51\1\0\1\51\1\0"+ + "\1\51\1\151\1\41\1\52\1\41\2\0\1\51\35\0"+ + "\20\7\1\0\2\7\1\0\20\7\1\227\1\7\12\0"+ + "\20\7\1\0\2\7\1\0\2\7\1\204\17\7\12\0"+ + "\20\7\1\0\1\120\1\7\1\0\22\7\12\0\12\7"+ + "\1\230\5\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\4\7\1\227\15\7\12\0\20\7"+ + "\1\0\2\7\1\0\2\7\1\231\1\232\16\7\12\0"+ + "\20\7\1\0\2\7\1\0\1\233\21\7\12\0\20\7"+ + "\1\0\2\7\1\0\2\7\1\202\17\7\12\0\20\7"+ + "\1\0\2\7\1\0\1\234\21\7\12\0\20\7\1\0"+ + "\2\7\1\0\1\235\21\7\12\0\20\7\1\0\2\7"+ + "\1\0\1\7\1\236\20\7\12\0\20\7\1\0\1\237"+ + "\1\7\1\0\22\7\12\0\20\7\1\0\2\7\1\0"+ + "\3\7\1\240\16\7\12\0\20\7\1\0\1\241\1\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\1\242"+ + "\21\7\12\0\6\7\1\243\11\7\1\0\2\7\1\0"+ + "\22\7\12\0\20\7\1\0\1\227\1\7\1\0\22\7"+ + "\12\0\20\7\1\0\2\7\1\0\3\7\1\244\16\7"+ + "\12\0\20\7\1\0\2\7\1\0\11\7\1\245\10\7"+ + "\12\0\20\7\1\0\2\7\1\0\4\7\1\233\15\7"+ + "\12\0\20\7\1\0\1\72\1\7\1\0\22\7\12\0"+ + "\12\7\1\246\5\7\1\0\2\7\1\0\22\7\12\0"+ + "\20\7\1\0\2\7\1\0\3\7\1\155\16\7\12\0"+ + "\20\7\1\0\2\7\1\0\10\7\1\247\11\7\12\0"+ + "\20\7\1\0\1\250\1\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\7\7\1\251\12\7\12\0\20\7"+ + "\1\0\2\7\1\0\2\7\1\120\17\7\12\0\20\7"+ + "\1\0\2\7\1\0\12\7\1\252\7\7\12\0\20\7"+ + "\1\0\2\7\1\0\11\7\1\253\10\7\12\0\6\7"+ + "\1\250\11\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\3\7\1\254\16\7\12\0\20\7"+ + "\1\0\1\255\1\7\1\0\22\7\12\0\6\7\1\256"+ + "\11\7\1\0\2\7\1\0\7\7\1\241\12\7\12\0"+ + "\20\7\1\0\2\7\1\0\11\7\1\257\10\7\12\0"+ + "\20\7\1\0\2\7\1\0\5\7\1\260\14\7\12\0"+ + "\20\7\1\0\2\7\1\0\3\7\1\261\16\7\12\0"+ + "\20\7\1\0\2\7\1\0\16\7\1\262\3\7\12\0"+ + "\6\7\1\244\11\7\1\0\2\7\1\0\22\7\12\0"+ + "\20\7\1\0\2\7\1\0\1\263\21\7\12\0\17\7"+ + "\1\227\1\0\2\7\1\0\22\7\12\0\6\7\1\154"+ + "\11\7\1\0\2\7\1\0\22\7\12\0\20\7\1\0"+ + "\2\7\1\0\7\7\1\120\12\7\67\0\1\44\2\0"+ + "\20\7\1\0\2\7\1\0\6\7\1\120\13\7\12\0"+ + "\20\7\1\0\2\7\1\0\3\7\1\120\16\7\12\0"+ + "\20\7\1\0\2\7\1\0\11\7\1\264\10\7\12\0"+ + "\20\7\1\0\2\7\1\0\3\7\1\227\16\7\12\0"+ + "\6\7\1\265\11\7\1\0\2\7\1\0\22\7\12\0"+ + "\20\7\1\0\2\7\1\0\12\7\1\266\7\7\12\0"+ + "\6\7\1\172\11\7\1\0\2\7\1\0\22\7\12\0"+ + "\20\7\1\0\2\7\1\0\10\7\1\267\11\7\12\0"+ + "\20\7\1\0\2\7\1\0\4\7\1\270\15\7\12\0"+ + "\20\7\1\0\2\7\1\0\4\7\1\231\15\7\12\0"+ + "\20\7\1\0\2\7\1\0\5\7\1\120\14\7\12\0"+ + "\20\7\1\0\1\271\1\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\11\7\1\272\10\7\12\0\12\7"+ + "\1\273\5\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\6\7\1\274\13\7\12\0\20\7"+ + "\1\0\2\7\1\0\2\7\1\275\17\7\12\0\20\7"+ + "\1\0\2\7\1\0\17\7\1\276\2\7\12\0\20\7"+ + "\1\0\2\7\1\0\4\7\1\257\15\7\12\0\20\7"+ + "\1\0\2\7\1\0\16\7\1\154\3\7\12\0\20\7"+ + "\1\0\2\7\1\0\1\277\21\7\12\0\20\7\1\0"+ + "\2\7\1\0\4\7\1\300\15\7\12\0\20\7\1\0"+ + "\1\301\1\7\1\0\22\7\12\0\20\7\1\0\2\7"+ + "\1\0\10\7\1\120\11\7\12\0\20\7\1\0\2\7"+ + "\1\0\1\302\21\7\12\0\20\7\1\0\1\303\1\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\1\304"+ + "\21\7\12\0\20\7\1\0\2\7\1\0\3\7\1\130"+ + "\16\7\12\0\20\7\1\0\2\7\1\0\10\7\1\305"+ + "\11\7\12\0\6\7\1\306\11\7\1\0\2\7\1\0"+ + "\22\7\12\0\6\7\1\231\11\7\1\0\2\7\1\0"+ + "\22\7\12\0\17\7\1\204\1\0\2\7\1\0\22\7"+ + "\12\0\20\7\1\0\2\7\1\0\1\307\21\7\12\0"+ + "\20\7\1\0\2\7\1\0\1\310\21\7\12\0\12\7"+ + "\1\120\5\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\3\7\1\311\16\7\12\0\20\7"+ + "\1\0\2\7\1\0\4\7\1\312\15\7\12\0\20\7"+ + "\1\0\2\7\1\0\11\7\1\313\10\7\12\0\20\7"+ + "\1\0\2\7\1\0\10\7\1\314\11\7\12\0\15\7"+ + "\1\315\2\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\14\7\1\316\5\7\12\0\20\7"+ + "\1\0\2\7\1\0\20\7\1\154\1\7\12\0\12\7"+ + "\1\317\5\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\3\7\1\154\16\7\12\0\20\7"+ + "\1\0\2\7\1\0\12\7\1\154\7\7\12\0\20\7"+ + "\1\0\2\7\1\0\13\7\1\120\6\7\12\0\12\7"+ + "\1\231\5\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\10\7\1\227\11\7\12\0\15\7"+ + "\1\320\2\7\1\0\2\7\1\0\22\7\12\0\20\7"+ + "\1\0\2\7\1\0\7\7\1\321\12\7\12\0\20\7"+ + "\1\0\1\322\1\7\1\0\22\7\12\0\12\7\1\323"+ + "\5\7\1\0\2\7\1\0\22\7\12\0\20\7\1\0"+ + "\2\7\1\0\1\324\21\7\12\0\20\7\1\0\1\325"+ + "\1\7\1\0\22\7\12\0\20\7\1\0\2\7\1\0"+ + "\3\7\1\326\16\7\12\0\20\7\1\0\2\7\1\0"+ + "\15\7\1\120\4\7\12\0\20\7\1\0\2\7\1\0"+ + "\10\7\1\327\11\7\12\0\20\7\1\0\2\7\1\0"+ + "\10\7\1\231\11\7\12\0\20\7\1\0\1\330\1\7"+ + "\1\0\22\7\12\0\12\7\1\154\5\7\1\0\2\7"+ + "\1\0\22\7\12\0\20\7\1\0\2\7\1\0\10\7"+ + "\1\331\11\7\12\0\20\7\1\0\1\332\1\7\1\0"+ + "\22\7\12\0\20\7\1\0\2\7\1\0\11\7\1\333"+ + "\10\7\12\0\20\7\1\0\2\7\1\0\7\7\1\334"+ + "\12\7\12\0\20\7\1\0\2\7\1\0\3\7\1\204"+ + "\16\7\12\0\17\7\1\120\1\0\2\7\1\0\22\7"+ + "\12\0\20\7\1\0\2\7\1\0\21\7\1\326\12\0"+ + "\15\7\1\120\2\7\1\0\2\7\1\0\22\7\11\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[9744]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\4\0\1\11\12\1\1\11\16\1\1\11\1\1\1\11"+ + "\2\1\1\11\1\1\1\11\5\1\1\0\55\1\1\0"+ + "\1\1\3\0\1\1\4\0\2\11\2\1\1\0\53\1"+ + "\1\11\1\1\1\11\106\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[220]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte JAVA_COMMENT_STYLE = 7; + public static final byte JAVADOC_COMMENT_STYLE = 8; + public static final byte JAVADOC_TAG_STYLE = 9; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 9; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public GroovyHighlighter() + { + } + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public GroovyHighlighter(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public GroovyHighlighter(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1656) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzPushbackPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead < 0) { + return true; + } + else { + zzEndRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public int yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 5: + { return JAVA_COMMENT_STYLE; + } + case 16: break; + case 1: + { return PLAIN_STYLE; + } + case 17: break; + case 8: + { return KEYWORD_STYLE; + } + case 18: break; + case 4: + { return OPERATOR_STYLE; + } + case 19: break; + case 2: + { return LITERAL_STYLE; + } + case 20: break; + case 11: + { yybegin(YYINITIAL); return JAVADOC_COMMENT_STYLE; + } + case 21: break; + case 10: + { yybegin(YYINITIAL); return JAVA_COMMENT_STYLE; + } + case 22: break; + case 3: + { return SEPARATOR_STYLE; + } + case 23: break; + case 7: + { return TYPE_STYLE; + } + case 24: break; + case 9: + { yybegin(IN_COMMENT); return JAVA_COMMENT_STYLE; + } + case 25: break; + case 15: + { yybegin(YYINITIAL); return LITERAL_STYLE; + } + case 26: break; + case 14: + { yybegin(IN_JAVA_DOC_COMMENT); return JAVADOC_COMMENT_STYLE; + } + case 27: break; + case 12: + { return JAVADOC_TAG_STYLE; + } + case 28: break; + case 13: + { yybegin(IN_HEREDOC); return LITERAL_STYLE; + } + case 29: break; + case 6: + { return JAVADOC_COMMENT_STYLE; + } + case 30: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return YYEOF; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.flex b/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.flex new file mode 100644 index 0000000..1d0a610 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.flex @@ -0,0 +1,283 @@ +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id$ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + +%% + +%class JavaHighlighter +%implements ExplicitStateHighlighter + +%unicode +%pack + +%buffer 128 + +%public + +%int + +%{ + public static boolean ASSERT_IS_KEYWORD = false; + + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte JAVA_COMMENT_STYLE = 7; + public static final byte JAVADOC_COMMENT_STYLE = 8; + public static final byte JAVADOC_TAG_STYLE = 9; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 9; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public JavaHighlighter() + { + } +%} + +/* main character classes */ + +WhiteSpace = [ \t\f] + +/* identifiers */ + +ConstantIdentifier = {SimpleConstantIdentifier} +SimpleConstantIdentifier = [A-Z0-9_]+ + +Identifier = [:jletter:][:jletterdigit:]* + +TypeIdentifier = {SimpleTypeIdentifier} +SimpleTypeIdentifier = [A-Z][:jletterdigit:]* + +/* int literals */ + +DecLiteral = 0 | [1-9][0-9]* [lL]? + +HexLiteral = 0 [xX] 0* {HexDigit}* [lL]? +HexDigit = [0-9a-fA-F] + +OctLiteral = 0+ {OctDigit}* [lL]? +OctDigit = [0-7] + +/* float literals */ + +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}|{FLit4}) ([fF]|[dD])? + +FLit1 = [0-9]+ \. [0-9]* {Exponent}? +FLit2 = \. [0-9]+ {Exponent}? +FLit3 = [0-9]+ {Exponent} +FLit4 = [0-9]+ {Exponent}? + +Exponent = [eE] [+\-]? [0-9]+ + +%state IN_COMMENT, IN_JAVA_DOC_COMMENT + +%% + + { + + /* keywords */ + "abstract" | + "break" | + "case" | + "catch" | + "class" | + "const" | + "continue" | + "do" | + "else" | + "extends" | + "final" | + "finally" | + "for" | + "default" | + "implements" | + "import" | + "instanceof" | + "interface" | + "native" | + "new" | + "goto" | + "if" | + "public" | + "super" | + "switch" | + "synchronized" | + "package" | + "private" | + "protected" | + "transient" | + "return" | + "static" | + "while" | + "this" | + "throw" | + "throws" | + "try" | + "volatile" | + "strictfp" { return KEYWORD_STYLE; } + + "boolean" | + "byte" | + "char" | + "double" | + "int" | + "long" | + "float" | + "short" | + "void" { return TYPE_STYLE; } + + "assert" { return ASSERT_IS_KEYWORD ? KEYWORD_STYLE : PLAIN_STYLE; } + + /* literals */ + "true" | + "false" | + "null" | + + (\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) | + (\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \')) | + + {DecLiteral} | + {HexLiteral} | + {OctLiteral} | + + {FloatLiteral} + { return LITERAL_STYLE; } + + /* separators */ + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." { return SEPARATOR_STYLE; } + + /* operators */ + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" { return OPERATOR_STYLE; } + + {ConstantIdentifier} { return PLAIN_STYLE; } + + {TypeIdentifier} { return TYPE_STYLE; } + + \n | + {Identifier} | + {WhiteSpace} { return PLAIN_STYLE; } + + + +// single line comment + + "//" [^\n]* \n | + +// short comment + + "/**/" { return JAVA_COMMENT_STYLE; } + +// comment start + + "/**" { yybegin(IN_JAVA_DOC_COMMENT); return JAVADOC_COMMENT_STYLE;} + "/*" { yybegin(IN_COMMENT); return JAVA_COMMENT_STYLE;} + +} + + +// normal comment mode + + { + + + // comment unterminated + + ([^\n*]|\*+[^\n*/])* (\n | \*+\n) { return JAVA_COMMENT_STYLE; } + + // comment terminated + + ([^\n*]|\*+[^\n*/])* \*+ "/" { yybegin(YYINITIAL); return JAVA_COMMENT_STYLE; } + +} + +// doc comment mode + + { + + // comment unterminated + + .|\n { return JAVADOC_COMMENT_STYLE; } + + // comment terminated + + \* "/" { yybegin(YYINITIAL); return JAVADOC_COMMENT_STYLE; } + + + "@" {Identifier} { return JAVADOC_TAG_STYLE; } + +} + +/* error fallback */ + +.|\n { return PLAIN_STYLE; } diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.java b/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.java new file mode 100644 index 0000000..d24f970 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/JavaHighlighter.java @@ -0,0 +1,953 @@ +/* The following code was generated by JFlex 1.4.1 on 3/13/06 6:15 PM */ + +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of the GNU Lesser General Public License, v2.1 or later + * $Id: JavaHighlighter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + + +/** + * This class is a scanner generated by + * JFlex 1.4.1 + * on 3/13/06 6:15 PM from the specification file + * com/uwyn/jhighlight/highlighter/JavaHighlighter.flex + */ +public class JavaHighlighter implements ExplicitStateHighlighter { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 128; + + /** lexical states */ + public static final int YYINITIAL = 0; + public static final int IN_COMMENT = 1; + public static final int IN_JAVA_DOC_COMMENT = 2; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\4\1\0\1\50\1\0\1\0\1\0\16\4\4\0\1\0\1\54"+ + "\1\47\1\0\1\2\1\54\1\54\1\52\1\53\1\53\1\55\1\24"+ + "\1\53\1\24\1\21\1\56\1\6\7\15\2\1\1\54\1\53\1\54"+ + "\1\54\1\54\1\54\1\57\3\14\1\17\1\23\1\17\5\5\1\10"+ + "\13\5\1\12\2\5\1\53\1\51\1\53\1\54\1\3\1\0\1\25"+ + "\1\26\1\13\1\20\1\22\1\16\1\45\1\33\1\36\1\2\1\32"+ + "\1\7\1\41\1\35\1\34\1\42\1\2\1\31\1\27\1\30\1\37"+ + "\1\43\1\44\1\11\1\40\1\46\1\53\1\54\1\53\1\54\41\4"+ + "\2\0\4\2\4\0\1\2\12\0\1\2\4\0\1\2\5\0\27\2"+ + "\1\0\37\2\1\0\u0128\2\2\0\22\2\34\0\136\2\2\0\11\2"+ + "\2\0\7\2\16\0\2\2\16\0\5\2\11\0\1\2\21\0\117\4"+ + "\21\0\3\4\27\0\1\2\13\0\1\2\1\0\3\2\1\0\1\2"+ + "\1\0\24\2\1\0\54\2\1\0\10\2\2\0\32\2\14\0\202\2"+ + "\1\0\4\4\5\0\71\2\2\0\2\2\2\0\2\2\3\0\46\2"+ + "\2\0\2\2\67\0\46\2\2\0\1\2\7\0\47\2\11\0\21\4"+ + "\1\0\27\4\1\0\3\4\1\0\1\4\1\0\2\4\1\0\1\4"+ + "\13\0\33\2\5\0\3\2\56\0\32\2\5\0\13\2\13\4\12\0"+ + "\12\4\6\0\1\4\143\2\1\0\1\2\7\4\2\0\6\4\2\2"+ + "\2\4\1\0\4\4\2\0\12\4\3\2\22\0\1\4\1\2\1\4"+ + "\33\2\3\0\33\4\65\0\46\2\13\4\u0150\0\3\4\1\0\65\2"+ + "\2\0\1\4\1\2\20\4\2\0\1\2\4\4\3\0\12\2\2\4"+ + "\2\0\12\4\21\0\3\4\1\0\10\2\2\0\2\2\2\0\26\2"+ + "\1\0\7\2\1\0\1\2\3\0\4\2\2\0\1\4\1\0\7\4"+ + "\2\0\2\4\2\0\3\4\11\0\1\4\4\0\2\2\1\0\3\2"+ + "\2\4\2\0\12\4\4\2\16\0\1\4\2\0\6\2\4\0\2\2"+ + "\2\0\26\2\1\0\7\2\1\0\2\2\1\0\2\2\1\0\2\2"+ + "\2\0\1\4\1\0\5\4\4\0\2\4\2\0\3\4\13\0\4\2"+ + "\1\0\1\2\7\0\14\4\3\2\14\0\3\4\1\0\7\2\1\0"+ + "\1\2\1\0\3\2\1\0\26\2\1\0\7\2\1\0\2\2\1\0"+ + "\5\2\2\0\1\4\1\2\10\4\1\0\3\4\1\0\3\4\2\0"+ + "\1\2\17\0\1\2\5\0\12\4\21\0\3\4\1\0\10\2\2\0"+ + "\2\2\2\0\26\2\1\0\7\2\1\0\2\2\2\0\4\2\2\0"+ + "\1\4\1\2\6\4\3\0\2\4\2\0\3\4\10\0\2\4\4\0"+ + "\2\2\1\0\3\2\4\0\12\4\22\0\2\4\1\0\6\2\3\0"+ + "\3\2\1\0\4\2\3\0\2\2\1\0\1\2\1\0\2\2\3\0"+ + "\2\2\3\0\3\2\3\0\10\2\1\0\3\2\4\0\5\4\3\0"+ + "\3\4\1\0\4\4\11\0\1\4\17\0\11\4\21\0\3\4\1\0"+ + "\10\2\1\0\3\2\1\0\27\2\1\0\12\2\1\0\5\2\4\0"+ + "\7\4\1\0\3\4\1\0\4\4\7\0\2\4\11\0\2\2\4\0"+ + "\12\4\22\0\2\4\1\0\10\2\1\0\3\2\1\0\27\2\1\0"+ + "\12\2\1\0\5\2\4\0\7\4\1\0\3\4\1\0\4\4\7\0"+ + "\2\4\7\0\1\2\1\0\2\2\4\0\12\4\22\0\2\4\1\0"+ + "\10\2\1\0\3\2\1\0\27\2\1\0\20\2\4\0\6\4\2\0"+ + "\3\4\1\0\4\4\11\0\1\4\10\0\2\2\4\0\12\4\22\0"+ + "\2\4\1\0\22\2\3\0\30\2\1\0\11\2\1\0\1\2\2\0"+ + "\7\2\3\0\1\4\4\0\6\4\1\0\1\4\1\0\10\4\22\0"+ + "\2\4\15\0\60\2\1\4\2\2\7\4\4\0\10\2\10\4\1\0"+ + "\12\4\47\0\2\2\1\0\1\2\2\0\2\2\1\0\1\2\2\0"+ + "\1\2\6\0\4\2\1\0\7\2\1\0\3\2\1\0\1\2\1\0"+ + "\1\2\2\0\2\2\1\0\4\2\1\4\2\2\6\4\1\0\2\4"+ + "\1\2\2\0\5\2\1\0\1\2\1\0\6\4\2\0\12\4\2\0"+ + "\2\2\42\0\1\2\27\0\2\4\6\0\12\4\13\0\1\4\1\0"+ + "\1\4\1\0\1\4\4\0\2\4\10\2\1\0\42\2\6\0\24\4"+ + "\1\0\2\4\4\2\4\0\10\4\1\0\44\4\11\0\1\4\71\0"+ + "\42\2\1\0\5\2\1\0\2\2\1\0\7\4\3\0\4\4\6\0"+ + "\12\4\6\0\6\2\4\4\106\0\46\2\12\0\47\2\11\0\132\2"+ + "\5\0\104\2\5\0\122\2\6\0\7\2\1\0\77\2\1\0\1\2"+ + "\1\0\4\2\2\0\7\2\1\0\1\2\1\0\4\2\2\0\47\2"+ + "\1\0\1\2\1\0\4\2\2\0\37\2\1\0\1\2\1\0\4\2"+ + "\2\0\7\2\1\0\1\2\1\0\4\2\2\0\7\2\1\0\7\2"+ + "\1\0\27\2\1\0\37\2\1\0\1\2\1\0\4\2\2\0\7\2"+ + "\1\0\47\2\1\0\23\2\16\0\11\4\56\0\125\2\14\0\u026c\2"+ + "\2\0\10\2\12\0\32\2\5\0\113\2\225\0\64\2\40\4\7\0"+ + "\1\2\4\0\12\4\41\0\4\4\1\0\12\4\6\0\130\2\10\0"+ + "\51\2\1\4\u0556\0\234\2\4\0\132\2\6\0\26\2\2\0\6\2"+ + "\2\0\46\2\2\0\6\2\2\0\10\2\1\0\1\2\1\0\1\2"+ + "\1\0\1\2\1\0\37\2\2\0\65\2\1\0\7\2\1\0\1\2"+ + "\3\0\3\2\1\0\7\2\3\0\4\2\2\0\6\2\4\0\15\2"+ + "\5\0\3\2\1\0\7\2\17\0\4\4\32\0\5\4\20\0\2\2"+ + "\51\0\6\4\17\0\1\2\40\0\20\2\40\0\15\4\4\0\1\4"+ + "\40\0\1\2\4\0\1\2\2\0\12\2\1\0\1\2\3\0\5\2"+ + "\6\0\1\2\1\0\1\2\1\0\1\2\1\0\4\2\1\0\3\2"+ + "\1\0\7\2\46\0\44\2\u0e81\0\3\2\31\0\11\2\6\4\1\0"+ + "\5\2\2\0\3\2\6\0\124\2\4\0\2\4\2\0\2\2\2\0"+ + "\136\2\6\0\50\2\4\0\136\2\21\0\30\2\u0248\0\u19b6\2\112\0"+ + "\u51a6\2\132\0\u048d\2\u0773\0\u2ba4\2\u215c\0\u012e\2\322\0\7\2\14\0"+ + "\5\2\5\0\1\2\1\4\12\2\1\0\15\2\1\0\5\2\1\0"+ + "\1\2\1\0\2\2\1\0\2\2\1\0\154\2\41\0\u016b\2\22\0"+ + "\100\2\2\0\66\2\50\0\14\2\44\0\4\4\17\0\2\2\30\0"+ + "\3\2\31\0\1\2\6\0\3\2\1\0\1\2\1\0\207\2\2\0"+ + "\1\4\4\0\1\2\13\0\12\4\7\0\32\2\4\0\1\2\1\0"+ + "\32\2\12\0\132\2\3\0\6\2\2\0\6\2\2\0\6\2\2\0"+ + "\3\2\3\0\2\2\3\0\2\2\22\0\3\4\4\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\3\0\1\1\1\2\2\1\1\2\4\1\1\3\1\1"+ + "\1\4\15\1\1\3\1\4\1\1\1\5\1\1\3\6"+ + "\1\1\3\2\1\0\1\1\1\7\4\2\12\1\1\10"+ + "\22\1\1\10\10\1\4\0\1\11\3\0\1\12\1\13"+ + "\1\14\1\2\1\0\1\2\37\1\1\7\11\1\1\15"+ + "\1\7\20\1\1\2\14\1\1\10\11\1\1\10\12\1"+ + "\1\16\25\1"; + + private static int [] zzUnpackAction() { + int [] result = new int[214]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150"+ + "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\220\0\u02a0"+ + "\0\u02d0\0\u0300\0\u0330\0\u0360\0\u0390\0\u03c0\0\u03f0\0\u0420"+ + "\0\u0450\0\u0480\0\u04b0\0\u04e0\0\220\0\u0510\0\u0540\0\220"+ + "\0\u0570\0\220\0\u05a0\0\u05d0\0\u0600\0\220\0\u0600\0\u0630"+ + "\0\u0660\0\u0690\0\u06c0\0\u06f0\0\u0720\0\u0750\0\u0780\0\u07b0"+ + "\0\u07e0\0\u0810\0\u0840\0\u0870\0\u08a0\0\u08d0\0\u0900\0\u0930"+ + "\0\u0960\0\u0990\0\u09c0\0\u09f0\0\u0a20\0\u0a50\0\u0a80\0\u0ab0"+ + "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\u0ba0\0\u0bd0\0\u0c00\0\u0c30"+ + "\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\360\0\u0d20\0\u0d50\0\u0d80"+ + "\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u04b0\0\u0ea0\0\u04e0"+ + "\0\u0ed0\0\u0f00\0\u0f30\0\u0540\0\u0570\0\220\0\220\0\u0f60"+ + "\0\u0f90\0\u0fc0\0\u0ff0\0\u1020\0\u1050\0\u1080\0\u10b0\0\u10e0"+ + "\0\u1110\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200\0\u1230\0\u1260"+ + "\0\u1290\0\u12c0\0\u12f0\0\u1320\0\u1350\0\u1380\0\u13b0\0\u13e0"+ + "\0\u1410\0\u1440\0\u1470\0\u14a0\0\u14d0\0\u1500\0\u1530\0\u1560"+ + "\0\u1590\0\u15c0\0\u15f0\0\u1620\0\u1650\0\u1680\0\u16b0\0\u16e0"+ + "\0\u1710\0\u1740\0\u1770\0\u17a0\0\u17d0\0\360\0\u1800\0\u1830"+ + "\0\u1860\0\u1890\0\u18c0\0\u18f0\0\u1920\0\u1950\0\u1980\0\u19b0"+ + "\0\u19e0\0\u1a10\0\u1a40\0\u1a70\0\u1aa0\0\u1ad0\0\360\0\u1b00"+ + "\0\u1b30\0\u1b60\0\u1b90\0\u1bc0\0\u1bf0\0\u1c20\0\u1c50\0\u1c80"+ + "\0\u1cb0\0\u1ce0\0\u1d10\0\u1d40\0\u1d70\0\u1da0\0\u1dd0\0\u1e00"+ + "\0\u1e30\0\u1e60\0\u1e90\0\u1ec0\0\u1ef0\0\u1500\0\u1f20\0\u1f50"+ + "\0\u1f80\0\u1fb0\0\u1fe0\0\u2010\0\u2040\0\u2070\0\u20a0\0\u20d0"+ + "\0\360\0\u2100\0\u2130\0\u2160\0\u2190\0\u21c0\0\u21f0\0\u2220"+ + "\0\u2250\0\u2280\0\u22b0\0\u22e0\0\u2310\0\u2340\0\u2370\0\u23a0"+ + "\0\u23d0\0\u2400\0\u2430\0\u2460\0\u2490\0\u24c0"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[214]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\4\1\5\2\6\1\4\1\7\1\10\1\11\1\7"+ + "\1\6\1\7\1\12\1\7\1\5\1\13\1\7\1\14"+ + "\1\15\1\16\1\7\1\17\1\20\1\21\1\22\1\23"+ + "\1\24\3\6\1\25\1\26\3\6\1\27\1\30\1\31"+ + "\1\32\1\6\1\33\2\4\1\34\1\35\2\17\1\36"+ + "\1\4\50\37\1\40\4\37\1\41\2\37\55\42\1\43"+ + "\1\42\1\44\61\0\1\5\1\0\1\45\1\0\1\45"+ + "\1\5\1\46\1\47\1\0\1\45\1\0\1\45\1\5"+ + "\1\46\1\47\1\46\1\50\1\51\1\52\35\0\20\6"+ + "\1\0\2\6\1\0\22\6\12\0\1\7\1\53\1\7"+ + "\1\53\2\7\1\53\1\7\1\53\1\7\1\53\2\7"+ + "\1\53\1\7\1\53\1\0\1\53\1\7\1\0\22\53"+ + "\12\0\1\54\1\0\1\45\1\0\1\45\1\55\1\46"+ + "\1\47\1\56\1\57\1\0\1\45\1\55\1\46\1\47"+ + "\1\46\1\50\1\51\1\52\35\0\20\6\1\0\2\6"+ + "\1\0\7\6\1\60\12\6\12\0\6\6\1\61\11\6"+ + "\1\0\2\6\1\0\1\62\5\6\1\63\1\64\12\6"+ + "\12\0\6\6\1\65\11\6\1\0\2\6\1\0\1\66"+ + "\6\6\1\67\1\6\1\70\10\6\12\0\20\6\1\0"+ + "\1\71\1\6\1\0\7\6\1\72\12\6\12\0\1\50"+ + "\4\0\1\50\6\0\1\50\43\0\6\6\1\73\1\6"+ + "\1\74\7\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\1\6\1\75\1\76\17\6\12\0"+ + "\20\6\1\0\2\6\1\0\4\6\1\77\2\6\1\100"+ + "\3\6\1\101\6\6\12\0\20\6\1\0\2\6\1\0"+ + "\3\6\1\102\2\6\1\103\3\6\1\104\1\105\3\6"+ + "\1\106\2\6\12\0\20\6\1\0\2\6\1\0\4\6"+ + "\1\107\1\6\1\110\13\6\12\0\20\6\1\0\1\111"+ + "\1\6\1\0\22\6\12\0\20\6\1\0\1\112\1\6"+ + "\1\0\1\113\11\6\1\114\7\6\12\0\15\6\1\115"+ + "\2\6\1\0\2\6\1\0\10\6\1\116\3\6\1\117"+ + "\5\6\12\0\20\6\1\0\2\6\1\0\1\120\3\6"+ + "\1\121\5\6\1\122\7\6\12\0\20\6\1\0\2\6"+ + "\1\0\7\6\1\123\12\6\12\0\20\6\1\0\2\6"+ + "\1\0\6\6\1\124\13\6\12\0\20\6\1\0\2\6"+ + "\1\0\7\6\1\125\12\6\11\0\47\126\2\46\1\127"+ + "\6\126\50\130\1\46\1\131\1\46\5\130\55\0\1\132"+ + "\1\133\1\0\50\134\1\40\4\134\1\135\52\134\1\40"+ + "\4\134\1\135\1\136\1\134\56\0\1\137\3\0\2\140"+ + "\1\0\1\140\1\0\6\140\1\0\3\140\1\0\2\140"+ + "\1\0\22\140\12\0\1\45\1\0\1\45\1\0\2\45"+ + "\1\0\1\45\1\0\1\45\1\0\2\45\1\0\1\45"+ + "\3\0\1\45\35\0\1\50\4\0\1\50\6\0\1\50"+ + "\3\46\1\0\2\51\35\0\1\141\4\0\1\141\6\0"+ + "\1\141\6\0\1\142\34\0\1\143\1\0\1\45\1\0"+ + "\1\45\1\143\1\0\1\45\1\0\1\45\1\0\1\45"+ + "\1\143\1\0\1\45\3\0\1\45\1\142\34\0\20\53"+ + "\1\0\2\53\1\0\22\53\12\0\1\54\1\0\1\45"+ + "\1\0\1\45\1\54\1\0\1\45\1\0\1\45\1\0"+ + "\1\45\1\54\1\46\1\47\1\46\1\50\1\51\1\52"+ + "\35\0\1\54\1\0\1\45\1\0\1\45\1\55\1\46"+ + "\1\47\1\0\1\45\1\0\1\45\1\55\1\46\1\47"+ + "\1\46\1\50\1\51\1\52\35\0\1\56\4\0\1\56"+ + "\2\46\2\0\6\56\1\0\2\56\1\0\2\56\32\0"+ + "\1\57\1\0\1\45\1\0\1\45\1\57\1\46\1\47"+ + "\1\0\1\45\1\56\2\57\1\56\1\57\1\56\1\0"+ + "\1\56\1\57\1\0\2\56\32\0\20\6\1\0\2\6"+ + "\1\0\10\6\1\144\11\6\12\0\20\6\1\0\2\6"+ + "\1\0\1\145\21\6\12\0\20\6\1\0\2\6\1\0"+ + "\2\6\1\146\1\147\16\6\12\0\20\6\1\0\2\6"+ + "\1\0\1\150\21\6\12\0\20\6\1\0\2\6\1\0"+ + "\10\6\1\151\11\6\12\0\20\6\1\0\2\6\1\0"+ + "\7\6\1\152\12\6\12\0\6\6\1\153\11\6\1\0"+ + "\2\6\1\0\22\6\12\0\20\6\1\0\2\6\1\0"+ + "\4\6\1\115\15\6\12\0\20\6\1\0\2\6\1\0"+ + "\10\6\1\154\11\6\12\0\15\6\1\155\2\6\1\0"+ + "\2\6\1\0\22\6\12\0\20\6\1\0\2\6\1\0"+ + "\12\6\1\156\7\6\12\0\20\6\1\0\2\6\1\0"+ + "\2\6\1\146\17\6\12\0\20\6\1\0\2\6\1\0"+ + "\3\6\1\157\16\6\12\0\20\6\1\0\2\6\1\0"+ + "\2\6\1\160\17\6\12\0\20\6\1\0\2\6\1\0"+ + "\2\6\1\161\17\6\12\0\20\6\1\0\1\162\1\6"+ + "\1\0\22\6\12\0\20\6\1\0\2\6\1\0\7\6"+ + "\1\163\12\6\12\0\20\6\1\0\2\6\1\0\3\6"+ + "\1\164\16\6\12\0\20\6\1\0\2\6\1\0\1\165"+ + "\3\6\1\166\15\6\12\0\20\6\1\0\2\6\1\0"+ + "\7\6\1\167\12\6\12\0\20\6\1\0\2\6\1\0"+ + "\15\6\1\170\4\6\12\0\20\6\1\0\2\6\1\0"+ + "\10\6\1\171\11\6\12\0\20\6\1\0\2\6\1\0"+ + "\11\6\1\172\10\6\12\0\20\6\1\0\2\6\1\0"+ + "\1\173\11\6\1\174\1\115\6\6\12\0\20\6\1\0"+ + "\2\6\1\0\4\6\1\175\4\6\1\176\10\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\177\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\17\6\1\115\2\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\200\16\6\12\0"+ + "\6\6\1\201\11\6\1\0\2\6\1\0\22\6\12\0"+ + "\20\6\1\0\2\6\1\0\2\6\1\202\1\203\16\6"+ + "\12\0\20\6\1\0\2\6\1\0\15\6\1\204\4\6"+ + "\12\0\12\6\1\205\5\6\1\0\2\6\1\0\22\6"+ + "\12\0\20\6\1\0\2\6\1\0\7\6\1\206\1\6"+ + "\1\207\10\6\12\0\20\6\1\0\2\6\1\0\1\6"+ + "\1\210\20\6\12\0\6\6\1\211\11\6\1\0\2\6"+ + "\1\0\11\6\1\212\10\6\12\0\20\6\1\0\2\6"+ + "\1\0\11\6\1\213\10\6\12\0\20\6\1\0\2\6"+ + "\1\0\3\6\1\214\16\6\11\0\50\126\1\46\7\126"+ + "\50\130\1\46\7\130\55\0\1\215\2\0\50\133\1\40"+ + "\7\133\1\0\20\140\1\0\2\140\1\0\22\140\12\0"+ + "\1\141\4\0\1\141\6\0\1\141\3\46\40\0\1\141"+ + "\4\0\1\141\6\0\1\141\43\0\1\143\1\0\1\45"+ + "\1\0\1\45\1\143\1\0\1\45\1\0\1\45\1\0"+ + "\1\45\1\143\1\46\1\47\1\46\2\0\1\45\35\0"+ + "\20\6\1\0\2\6\1\0\20\6\1\216\1\6\12\0"+ + "\20\6\1\0\2\6\1\0\2\6\1\176\17\6\12\0"+ + "\20\6\1\0\1\115\1\6\1\0\22\6\12\0\12\6"+ + "\1\217\5\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\4\6\1\216\15\6\12\0\20\6"+ + "\1\0\2\6\1\0\2\6\1\220\1\221\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\1\222\21\6\12\0\20\6"+ + "\1\0\2\6\1\0\2\6\1\174\17\6\12\0\20\6"+ + "\1\0\2\6\1\0\1\223\21\6\12\0\20\6\1\0"+ + "\2\6\1\0\1\224\21\6\12\0\20\6\1\0\2\6"+ + "\1\0\1\6\1\225\20\6\12\0\20\6\1\0\1\226"+ + "\1\6\1\0\22\6\12\0\20\6\1\0\2\6\1\0"+ + "\3\6\1\227\16\6\12\0\20\6\1\0\1\230\1\6"+ + "\1\0\22\6\12\0\20\6\1\0\2\6\1\0\1\231"+ + "\21\6\12\0\6\6\1\232\11\6\1\0\2\6\1\0"+ + "\22\6\12\0\20\6\1\0\1\216\1\6\1\0\22\6"+ + "\12\0\20\6\1\0\2\6\1\0\3\6\1\233\16\6"+ + "\12\0\20\6\1\0\2\6\1\0\11\6\1\234\10\6"+ + "\12\0\20\6\1\0\2\6\1\0\4\6\1\222\15\6"+ + "\12\0\20\6\1\0\1\67\1\6\1\0\22\6\12\0"+ + "\12\6\1\235\5\6\1\0\2\6\1\0\22\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\147\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\10\6\1\236\11\6\12\0"+ + "\20\6\1\0\1\237\1\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\7\6\1\240\12\6\12\0\20\6"+ + "\1\0\2\6\1\0\2\6\1\115\17\6\12\0\20\6"+ + "\1\0\2\6\1\0\12\6\1\241\7\6\12\0\20\6"+ + "\1\0\2\6\1\0\11\6\1\242\10\6\12\0\6\6"+ + "\1\237\11\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\3\6\1\243\16\6\12\0\20\6"+ + "\1\0\1\244\1\6\1\0\22\6\12\0\6\6\1\245"+ + "\11\6\1\0\2\6\1\0\7\6\1\246\12\6\12\0"+ + "\20\6\1\0\2\6\1\0\5\6\1\247\14\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\250\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\16\6\1\251\3\6\12\0"+ + "\6\6\1\233\11\6\1\0\2\6\1\0\22\6\12\0"+ + "\20\6\1\0\2\6\1\0\1\252\21\6\12\0\17\6"+ + "\1\216\1\0\2\6\1\0\22\6\12\0\6\6\1\146"+ + "\11\6\1\0\2\6\1\0\22\6\12\0\20\6\1\0"+ + "\2\6\1\0\7\6\1\115\12\6\67\0\1\40\2\0"+ + "\20\6\1\0\2\6\1\0\6\6\1\115\13\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\115\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\11\6\1\253\10\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\216\16\6\12\0"+ + "\6\6\1\254\11\6\1\0\2\6\1\0\22\6\12\0"+ + "\20\6\1\0\2\6\1\0\12\6\1\255\7\6\12\0"+ + "\6\6\1\164\11\6\1\0\2\6\1\0\22\6\12\0"+ + "\20\6\1\0\2\6\1\0\10\6\1\256\11\6\12\0"+ + "\20\6\1\0\2\6\1\0\4\6\1\257\15\6\12\0"+ + "\20\6\1\0\2\6\1\0\4\6\1\260\15\6\12\0"+ + "\20\6\1\0\2\6\1\0\5\6\1\115\14\6\12\0"+ + "\20\6\1\0\1\261\1\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\11\6\1\262\10\6\12\0\12\6"+ + "\1\263\5\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\6\6\1\264\13\6\12\0\20\6"+ + "\1\0\2\6\1\0\2\6\1\265\17\6\12\0\20\6"+ + "\1\0\2\6\1\0\17\6\1\266\2\6\12\0\20\6"+ + "\1\0\2\6\1\0\4\6\1\267\15\6\12\0\20\6"+ + "\1\0\2\6\1\0\16\6\1\146\3\6\12\0\20\6"+ + "\1\0\2\6\1\0\1\270\21\6\12\0\20\6\1\0"+ + "\2\6\1\0\4\6\1\271\15\6\12\0\20\6\1\0"+ + "\1\272\1\6\1\0\22\6\12\0\20\6\1\0\2\6"+ + "\1\0\4\6\1\220\15\6\12\0\20\6\1\0\2\6"+ + "\1\0\1\273\21\6\12\0\20\6\1\0\1\274\1\6"+ + "\1\0\22\6\12\0\20\6\1\0\2\6\1\0\1\275"+ + "\21\6\12\0\20\6\1\0\2\6\1\0\3\6\1\124"+ + "\16\6\12\0\20\6\1\0\2\6\1\0\10\6\1\276"+ + "\11\6\12\0\6\6\1\277\11\6\1\0\2\6\1\0"+ + "\22\6\12\0\6\6\1\220\11\6\1\0\2\6\1\0"+ + "\22\6\12\0\17\6\1\176\1\0\2\6\1\0\22\6"+ + "\12\0\20\6\1\0\2\6\1\0\1\300\21\6\12\0"+ + "\20\6\1\0\2\6\1\0\3\6\1\301\16\6\12\0"+ + "\20\6\1\0\2\6\1\0\1\302\21\6\12\0\12\6"+ + "\1\115\5\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\3\6\1\303\16\6\12\0\20\6"+ + "\1\0\2\6\1\0\4\6\1\304\15\6\12\0\20\6"+ + "\1\0\2\6\1\0\11\6\1\305\10\6\12\0\20\6"+ + "\1\0\2\6\1\0\10\6\1\115\11\6\12\0\20\6"+ + "\1\0\2\6\1\0\10\6\1\306\11\6\12\0\15\6"+ + "\1\307\2\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\14\6\1\310\5\6\12\0\20\6"+ + "\1\0\2\6\1\0\20\6\1\146\1\6\12\0\12\6"+ + "\1\311\5\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\3\6\1\146\16\6\12\0\20\6"+ + "\1\0\2\6\1\0\12\6\1\146\7\6\12\0\20\6"+ + "\1\0\2\6\1\0\13\6\1\115\6\6\12\0\12\6"+ + "\1\220\5\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\10\6\1\216\11\6\12\0\15\6"+ + "\1\312\2\6\1\0\2\6\1\0\22\6\12\0\20\6"+ + "\1\0\2\6\1\0\7\6\1\313\12\6\12\0\20\6"+ + "\1\0\1\314\1\6\1\0\22\6\12\0\12\6\1\315"+ + "\5\6\1\0\2\6\1\0\22\6\12\0\20\6\1\0"+ + "\2\6\1\0\1\316\21\6\12\0\20\6\1\0\1\317"+ + "\1\6\1\0\22\6\12\0\20\6\1\0\2\6\1\0"+ + "\3\6\1\320\16\6\12\0\20\6\1\0\2\6\1\0"+ + "\15\6\1\115\4\6\12\0\20\6\1\0\2\6\1\0"+ + "\10\6\1\321\11\6\12\0\20\6\1\0\2\6\1\0"+ + "\10\6\1\220\11\6\12\0\20\6\1\0\1\322\1\6"+ + "\1\0\22\6\12\0\12\6\1\146\5\6\1\0\2\6"+ + "\1\0\22\6\12\0\20\6\1\0\2\6\1\0\10\6"+ + "\1\323\11\6\12\0\20\6\1\0\1\324\1\6\1\0"+ + "\22\6\12\0\20\6\1\0\2\6\1\0\11\6\1\325"+ + "\10\6\12\0\20\6\1\0\2\6\1\0\7\6\1\326"+ + "\12\6\12\0\20\6\1\0\2\6\1\0\3\6\1\176"+ + "\16\6\12\0\17\6\1\115\1\0\2\6\1\0\22\6"+ + "\12\0\20\6\1\0\2\6\1\0\21\6\1\320\12\0"+ + "\15\6\1\115\2\6\1\0\2\6\1\0\22\6\11\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[9456]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\3\0\1\11\12\1\1\11\15\1\1\11\2\1\1\11"+ + "\1\1\1\11\3\1\1\11\2\1\1\0\54\1\4\0"+ + "\1\1\3\0\2\11\2\1\1\0\164\1"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[214]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + public static boolean ASSERT_IS_KEYWORD = false; + + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte KEYWORD_STYLE = 2; + public static final byte TYPE_STYLE = 3; + public static final byte OPERATOR_STYLE = 4; + public static final byte SEPARATOR_STYLE = 5; + public static final byte LITERAL_STYLE = 6; + public static final byte JAVA_COMMENT_STYLE = 7; + public static final byte JAVADOC_COMMENT_STYLE = 8; + public static final byte JAVADOC_TAG_STYLE = 9; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 9; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + throws IOException + { + return (byte) yylex(); + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public JavaHighlighter() + { + } + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public JavaHighlighter(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public JavaHighlighter(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1656) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzPushbackPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead < 0) { + return true; + } + else { + zzEndRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public int yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 14: + { return ASSERT_IS_KEYWORD ? KEYWORD_STYLE : PLAIN_STYLE; + } + case 15: break; + case 5: + { return JAVA_COMMENT_STYLE; + } + case 16: break; + case 1: + { return PLAIN_STYLE; + } + case 17: break; + case 8: + { return KEYWORD_STYLE; + } + case 18: break; + case 4: + { return OPERATOR_STYLE; + } + case 19: break; + case 2: + { return LITERAL_STYLE; + } + case 20: break; + case 11: + { yybegin(YYINITIAL); return JAVADOC_COMMENT_STYLE; + } + case 21: break; + case 10: + { yybegin(YYINITIAL); return JAVA_COMMENT_STYLE; + } + case 22: break; + case 3: + { return SEPARATOR_STYLE; + } + case 23: break; + case 7: + { return TYPE_STYLE; + } + case 24: break; + case 9: + { yybegin(IN_COMMENT); return JAVA_COMMENT_STYLE; + } + case 25: break; + case 13: + { yybegin(IN_JAVA_DOC_COMMENT); return JAVADOC_COMMENT_STYLE; + } + case 26: break; + case 12: + { return JAVADOC_TAG_STYLE; + } + case 27: break; + case 6: + { return JAVADOC_COMMENT_STYLE; + } + case 28: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return YYEOF; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.flex b/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.flex new file mode 100644 index 0000000..e3b176f --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.flex @@ -0,0 +1,274 @@ +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id$ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + +%% + +%class XmlHighlighter +%implements ExplicitStateHighlighter + +%unicode +%pack +%buffer 128 +%public + +%int + +%{ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte CHAR_DATA = 2; + public static final byte TAG_SYMBOLS = 3; + public static final byte COMMENT = 4; + public static final byte ATTRIBUTE_VALUE = 5; + public static final byte ATTRIBUTE_NAME = 6; + public static final byte PROCESSING_INSTRUCTION = 7; + public static final byte TAG_NAME = 8; + public static final byte RIFE_TAG = 9; + public static final byte RIFE_NAME = 10; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 10; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + { + try + { + return (byte) yylex(); + } + catch (IOException e) + { + throw new InternalError(); + } + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public XmlHighlighter() + { + } + + private int mReturningState; + private int mReturningStateTag; +%} + +/* main character classes */ +WhiteSpace = [ \t\f] +WhiteSpaceNewline = [ \t\f\n\r] + +/* identifiers */ +Letter = ([:jletterdigit:]|"."|"-"|"_"|":") +Name = ([:jletter:]|"_"|":") {Letter}* + +RifeBeginStartComment = ("") +RifeEndComment = ("") + +RifeBeginStartCompact = ("[!"{WhiteSpaceNewline}*("V"|"B"|"BV"|"I"){WhiteSpace}) +RifeBeginStopCompact = ("]") +RifeEndCompact = ("[!/"{WhiteSpaceNewline}*("V"|"B"|"BV"){WhiteSpaceNewline}*"]") + +RifeBeginStartVelocity = ("${"{WhiteSpaceNewline}*("v"|"b"|"bv"|"i"){WhiteSpace}) +RifeBeginStopVelocity = ("/"? "}") +RifeEndVelocity = ("${/"{WhiteSpaceNewline}*("v"|"b"|"bv"){WhiteSpaceNewline}*"}") + +RifeBeginStartRegular = ("") +RifeEndRegular = ("") + +%state IN_RIFE_TAG_COMMENT, IN_RIFE_TAG_COMPACT, IN_RIFE_TAG_VELOCITY, IN_RIFE_TAG_REGULAR, IN_RIFE_NAME_SINGLEQUOTED, IN_RIFE_NAME_QUOTED, IN_RIFE_NAME, IN_COMMENT, TAG_START, IN_TAG, IN_SINGLE_QUOTE_STRING, IN_DOUBLE_QUOTE_STRING, IN_PROCESSING_INSTRUCTION, IN_CDATA_SECTION + +%% + + { + +// tokens... + + "<" { yybegin(TAG_START); return TAG_SYMBOLS; } + " { + {Name} { yybegin(IN_TAG); return TAG_NAME; } + + ">" { yybegin(YYINITIAL); return TAG_SYMBOLS; } + . { yybegin(IN_TAG); return PLAIN_STYLE; } +} + + { + {RifeBeginStartComment} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMMENT); return RIFE_TAG; } + {RifeEndComment} { return RIFE_TAG; } + {RifeBeginStartCompact} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMPACT); return RIFE_TAG; } + {RifeEndCompact} { return RIFE_TAG; } + {RifeBeginStartVelocity} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_VELOCITY); return RIFE_TAG; } + {RifeEndVelocity} { return RIFE_TAG; } + {RifeBeginStartRegular} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_REGULAR); return RIFE_TAG; } + {RifeEndRegular} { return RIFE_TAG; } + + "/>" { yybegin(YYINITIAL); return TAG_SYMBOLS; } + ">" { yybegin(YYINITIAL); return TAG_SYMBOLS; } + "=" { return TAG_SYMBOLS; } + + {Name} { return ATTRIBUTE_NAME; } + + "\'" { yybegin(IN_SINGLE_QUOTE_STRING); return ATTRIBUTE_VALUE; } + "\"" { yybegin(IN_DOUBLE_QUOTE_STRING); return ATTRIBUTE_VALUE; } + . { return PLAIN_STYLE; } +} + + { + {RifeBeginStartComment} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMMENT); return RIFE_TAG; } + {RifeEndComment} { return RIFE_TAG; } + {RifeBeginStartCompact} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMPACT); return RIFE_TAG; } + {RifeEndCompact} { return RIFE_TAG; } + {RifeBeginStartVelocity} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_VELOCITY); return RIFE_TAG; } + {RifeEndVelocity} { return RIFE_TAG; } + {RifeBeginStartRegular} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_REGULAR); return RIFE_TAG; } + {RifeEndRegular} { return RIFE_TAG; } + + [^\'\n\[\]<>{}]* { return ATTRIBUTE_VALUE; } + \[ { return ATTRIBUTE_VALUE; } + \] { return ATTRIBUTE_VALUE; } + \{ { return ATTRIBUTE_VALUE; } + \} { return ATTRIBUTE_VALUE; } + \n { return ATTRIBUTE_VALUE; } + \' { yybegin(IN_TAG); return ATTRIBUTE_VALUE; } + . { yybegin(IN_TAG); return TAG_SYMBOLS; } +} + + { + {RifeBeginStartComment} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMMENT); return RIFE_TAG; } + {RifeEndComment} { return RIFE_TAG; } + {RifeBeginStartCompact} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMPACT); return RIFE_TAG; } + {RifeEndCompact} { return RIFE_TAG; } + {RifeBeginStartVelocity} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_VELOCITY); return RIFE_TAG; } + {RifeEndVelocity} { return RIFE_TAG; } + {RifeBeginStartRegular} { mReturningState = yystate(); yybegin(IN_RIFE_TAG_REGULAR); return RIFE_TAG; } + {RifeEndRegular} { return RIFE_TAG; } + + [^\"\n\[\]<>{}]* { return ATTRIBUTE_VALUE; } + \[ { return ATTRIBUTE_VALUE; } + \] { return ATTRIBUTE_VALUE; } + \{ { return ATTRIBUTE_VALUE; } + \} { return ATTRIBUTE_VALUE; } + \n { return ATTRIBUTE_VALUE; } + \" { yybegin(IN_TAG); return ATTRIBUTE_VALUE; } + . { yybegin(IN_TAG); return TAG_SYMBOLS; } +} + + { + ([^?\n]| "?"+ [^>?\n])* (\n | "?"\n) { return PROCESSING_INSTRUCTION; } + ([^?\n]| "?"+ [^>?\n])* "?"+ ">" { yybegin(YYINITIAL); return PROCESSING_INSTRUCTION; } +} + + { + [^\]\n]* { return CHAR_DATA; } + "]]>" { yybegin(YYINITIAL); return CHAR_DATA; } + . { return CHAR_DATA; } +} + + { + [^\-\n]* { return COMMENT; } + "-->" { yybegin(YYINITIAL); return COMMENT; } + . { return COMMENT; } +} + + { + [^\-\>\']* { return RIFE_TAG; } + {RifeBeginStopComment} { yybegin(mReturningState); return RIFE_TAG; } + "\'" { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME_SINGLEQUOTED); return RIFE_NAME; } + . { return RIFE_TAG; } +} + + { + [^\]\']* { return RIFE_TAG; } + {RifeBeginStopCompact} { yybegin(mReturningState); return RIFE_TAG; } + "\'" { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME_SINGLEQUOTED); return RIFE_NAME; } + . { return RIFE_TAG; } +} + + { + {RifeBeginStopVelocity} { yybegin(mReturningState); return RIFE_TAG; } + [^\s\t\}]* { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME); return RIFE_NAME; } + . { return RIFE_TAG; } +} + + { + [^\>\"]* { return RIFE_TAG; } + {RifeBeginStopRegular} { yybegin(mReturningState); return RIFE_TAG; } + "\"" { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME_QUOTED); return RIFE_NAME; } + . { return RIFE_TAG; } +} + + { + \' { yybegin(mReturningStateTag); return RIFE_NAME; } + . { return RIFE_NAME; } +} + + { + \" { yybegin(mReturningStateTag); return RIFE_NAME; } + . { return RIFE_NAME; } +} + + { + {RifeBeginStopVelocity} { yybegin(mReturningState); return RIFE_TAG; } + . { return RIFE_NAME; } +} + +/* error fallback */ + +.|\n { return PLAIN_STYLE; } diff --git a/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.java b/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.java new file mode 100644 index 0000000..b8e763f --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/highlighter/XmlHighlighter.java @@ -0,0 +1,899 @@ +/* The following code was generated by JFlex 1.4.1 on 3/13/06 6:15 PM */ + +/* + * Copyright 2000-2006 Omnicore Software, Hans Kratz & Dennis Strein GbR, + * Geert Bevin . + * Distributed under the terms of the GNU Lesser General Public License, v2.1 or later + * $Id: XmlHighlighter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.highlighter; + +import java.io.Reader; +import java.io.IOException; + + +/** + * This class is a scanner generated by + * JFlex 1.4.1 + * on 3/13/06 6:15 PM from the specification file + * com/uwyn/jhighlight/highlighter/XmlHighlighter.flex + */ +public class XmlHighlighter implements ExplicitStateHighlighter { + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 128; + + /** lexical states */ + public static final int TAG_START = 9; + public static final int IN_CDATA_SECTION = 14; + public static final int IN_RIFE_NAME_QUOTED = 6; + public static final int IN_SINGLE_QUOTE_STRING = 11; + public static final int IN_RIFE_TAG_REGULAR = 4; + public static final int IN_PROCESSING_INSTRUCTION = 13; + public static final int IN_DOUBLE_QUOTE_STRING = 12; + public static final int IN_RIFE_NAME = 7; + public static final int IN_TAG = 10; + public static final int IN_RIFE_NAME_SINGLEQUOTED = 5; + public static final int IN_RIFE_TAG_VELOCITY = 3; + public static final int IN_COMMENT = 8; + public static final int YYINITIAL = 0; + public static final int IN_RIFE_TAG_COMMENT = 1; + public static final int IN_RIFE_TAG_COMPACT = 2; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\3\1\40\1\34\1\0\1\1\1\2\16\3\4\0\1\1\1\10"+ + "\1\37\1\0\1\20\2\0\1\36\5\0\1\4\1\3\1\15\12\3"+ + "\1\6\1\0\1\7\1\35\1\14\1\27\1\0\1\32\1\12\1\30"+ + "\1\31\4\5\1\13\12\5\1\33\1\5\1\11\4\5\1\16\1\0"+ + "\1\17\1\0\1\5\1\0\1\5\1\23\6\5\1\24\10\5\1\26"+ + "\1\41\2\5\1\22\4\5\1\21\1\0\1\25\1\0\41\3\2\0"+ + "\4\5\4\0\1\5\12\0\1\5\4\0\1\5\5\0\27\5\1\0"+ + "\37\5\1\0\u0128\5\2\0\22\5\34\0\136\5\2\0\11\5\2\0"+ + "\7\5\16\0\2\5\16\0\5\5\11\0\1\5\21\0\117\3\21\0"+ + "\3\3\27\0\1\5\13\0\1\5\1\0\3\5\1\0\1\5\1\0"+ + "\24\5\1\0\54\5\1\0\10\5\2\0\32\5\14\0\202\5\1\0"+ + "\4\3\5\0\71\5\2\0\2\5\2\0\2\5\3\0\46\5\2\0"+ + "\2\5\67\0\46\5\2\0\1\5\7\0\47\5\11\0\21\3\1\0"+ + "\27\3\1\0\3\3\1\0\1\3\1\0\2\3\1\0\1\3\13\0"+ + "\33\5\5\0\3\5\56\0\32\5\5\0\13\5\13\3\12\0\12\3"+ + "\6\0\1\3\143\5\1\0\1\5\7\3\2\0\6\3\2\5\2\3"+ + "\1\0\4\3\2\0\12\3\3\5\22\0\1\3\1\5\1\3\33\5"+ + "\3\0\33\3\65\0\46\5\13\3\u0150\0\3\3\1\0\65\5\2\0"+ + "\1\3\1\5\20\3\2\0\1\5\4\3\3\0\12\5\2\3\2\0"+ + "\12\3\21\0\3\3\1\0\10\5\2\0\2\5\2\0\26\5\1\0"+ + "\7\5\1\0\1\5\3\0\4\5\2\0\1\3\1\0\7\3\2\0"+ + "\2\3\2\0\3\3\11\0\1\3\4\0\2\5\1\0\3\5\2\3"+ + "\2\0\12\3\4\5\16\0\1\3\2\0\6\5\4\0\2\5\2\0"+ + "\26\5\1\0\7\5\1\0\2\5\1\0\2\5\1\0\2\5\2\0"+ + "\1\3\1\0\5\3\4\0\2\3\2\0\3\3\13\0\4\5\1\0"+ + "\1\5\7\0\14\3\3\5\14\0\3\3\1\0\7\5\1\0\1\5"+ + "\1\0\3\5\1\0\26\5\1\0\7\5\1\0\2\5\1\0\5\5"+ + "\2\0\1\3\1\5\10\3\1\0\3\3\1\0\3\3\2\0\1\5"+ + "\17\0\1\5\5\0\12\3\21\0\3\3\1\0\10\5\2\0\2\5"+ + "\2\0\26\5\1\0\7\5\1\0\2\5\2\0\4\5\2\0\1\3"+ + "\1\5\6\3\3\0\2\3\2\0\3\3\10\0\2\3\4\0\2\5"+ + "\1\0\3\5\4\0\12\3\22\0\2\3\1\0\6\5\3\0\3\5"+ + "\1\0\4\5\3\0\2\5\1\0\1\5\1\0\2\5\3\0\2\5"+ + "\3\0\3\5\3\0\10\5\1\0\3\5\4\0\5\3\3\0\3\3"+ + "\1\0\4\3\11\0\1\3\17\0\11\3\21\0\3\3\1\0\10\5"+ + "\1\0\3\5\1\0\27\5\1\0\12\5\1\0\5\5\4\0\7\3"+ + "\1\0\3\3\1\0\4\3\7\0\2\3\11\0\2\5\4\0\12\3"+ + "\22\0\2\3\1\0\10\5\1\0\3\5\1\0\27\5\1\0\12\5"+ + "\1\0\5\5\4\0\7\3\1\0\3\3\1\0\4\3\7\0\2\3"+ + "\7\0\1\5\1\0\2\5\4\0\12\3\22\0\2\3\1\0\10\5"+ + "\1\0\3\5\1\0\27\5\1\0\20\5\4\0\6\3\2\0\3\3"+ + "\1\0\4\3\11\0\1\3\10\0\2\5\4\0\12\3\22\0\2\3"+ + "\1\0\22\5\3\0\30\5\1\0\11\5\1\0\1\5\2\0\7\5"+ + "\3\0\1\3\4\0\6\3\1\0\1\3\1\0\10\3\22\0\2\3"+ + "\15\0\60\5\1\3\2\5\7\3\4\0\10\5\10\3\1\0\12\3"+ + "\47\0\2\5\1\0\1\5\2\0\2\5\1\0\1\5\2\0\1\5"+ + "\6\0\4\5\1\0\7\5\1\0\3\5\1\0\1\5\1\0\1\5"+ + "\2\0\2\5\1\0\4\5\1\3\2\5\6\3\1\0\2\3\1\5"+ + "\2\0\5\5\1\0\1\5\1\0\6\3\2\0\12\3\2\0\2\5"+ + "\42\0\1\5\27\0\2\3\6\0\12\3\13\0\1\3\1\0\1\3"+ + "\1\0\1\3\4\0\2\3\10\5\1\0\42\5\6\0\24\3\1\0"+ + "\2\3\4\5\4\0\10\3\1\0\44\3\11\0\1\3\71\0\42\5"+ + "\1\0\5\5\1\0\2\5\1\0\7\3\3\0\4\3\6\0\12\3"+ + "\6\0\6\5\4\3\106\0\46\5\12\0\47\5\11\0\132\5\5\0"+ + "\104\5\5\0\122\5\6\0\7\5\1\0\77\5\1\0\1\5\1\0"+ + "\4\5\2\0\7\5\1\0\1\5\1\0\4\5\2\0\47\5\1\0"+ + "\1\5\1\0\4\5\2\0\37\5\1\0\1\5\1\0\4\5\2\0"+ + "\7\5\1\0\1\5\1\0\4\5\2\0\7\5\1\0\7\5\1\0"+ + "\27\5\1\0\37\5\1\0\1\5\1\0\4\5\2\0\7\5\1\0"+ + "\47\5\1\0\23\5\16\0\11\3\56\0\125\5\14\0\u026c\5\2\0"+ + "\10\5\12\0\32\5\5\0\113\5\225\0\64\5\40\3\7\0\1\5"+ + "\4\0\12\3\41\0\4\3\1\0\12\3\6\0\130\5\10\0\51\5"+ + "\1\3\u0556\0\234\5\4\0\132\5\6\0\26\5\2\0\6\5\2\0"+ + "\46\5\2\0\6\5\2\0\10\5\1\0\1\5\1\0\1\5\1\0"+ + "\1\5\1\0\37\5\2\0\65\5\1\0\7\5\1\0\1\5\3\0"+ + "\3\5\1\0\7\5\3\0\4\5\2\0\6\5\4\0\15\5\5\0"+ + "\3\5\1\0\7\5\17\0\4\3\32\0\5\3\20\0\2\5\51\0"+ + "\6\3\17\0\1\5\40\0\20\5\40\0\15\3\4\0\1\3\40\0"+ + "\1\5\4\0\1\5\2\0\12\5\1\0\1\5\3\0\5\5\6\0"+ + "\1\5\1\0\1\5\1\0\1\5\1\0\4\5\1\0\3\5\1\0"+ + "\7\5\46\0\44\5\u0e81\0\3\5\31\0\11\5\6\3\1\0\5\5"+ + "\2\0\3\5\6\0\124\5\4\0\2\3\2\0\2\5\2\0\136\5"+ + "\6\0\50\5\4\0\136\5\21\0\30\5\u0248\0\u19b6\5\112\0\u51a6\5"+ + "\132\0\u048d\5\u0773\0\u2ba4\5\u215c\0\u012e\5\322\0\7\5\14\0\5\5"+ + "\5\0\1\5\1\3\12\5\1\0\15\5\1\0\5\5\1\0\1\5"+ + "\1\0\2\5\1\0\2\5\1\0\154\5\41\0\u016b\5\22\0\100\5"+ + "\2\0\66\5\50\0\14\5\44\0\4\3\17\0\2\5\30\0\3\5"+ + "\31\0\1\5\6\0\3\5\1\0\1\5\1\0\207\5\2\0\1\3"+ + "\4\0\1\5\13\0\12\3\7\0\32\5\4\0\1\5\1\0\32\5"+ + "\12\0\132\5\3\0\6\5\2\0\6\5\2\0\6\5\2\0\3\5"+ + "\3\0\2\5\3\0\2\5\22\0\3\3\4\0"; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\1\1\2\2\1\3\1\2\3\0\1\4\2\0\2\5"+ + "\1\0\1\6\2\1\1\7\2\1\3\2\1\10\1\2"+ + "\1\11\2\3\1\2\1\12\1\13\1\14\1\13\2\4"+ + "\1\15\1\16\1\17\1\20\2\1\1\20\1\21\1\22"+ + "\1\23\1\5\2\24\3\5\1\25\2\5\2\1\1\26"+ + "\2\6\1\0\1\7\1\0\1\27\10\0\1\30\16\0"+ + "\1\31\1\0\1\32\1\33\4\0\1\34\4\0\1\35"+ + "\10\0\1\36\1\37\7\0\1\40"; + + private static int [] zzUnpackAction() { + int [] result = new int[118]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\42\0\104\0\146\0\210\0\252\0\314\0\356"+ + "\0\u0110\0\u0132\0\u0154\0\u0176\0\u0198\0\u01ba\0\u01dc\0\u01fe"+ + "\0\u0220\0\u0242\0\u0264\0\u0286\0\u02a8\0\u02ca\0\u01fe\0\u01fe"+ + "\0\u02ec\0\u01fe\0\u030e\0\u0330\0\u0352\0\u01fe\0\u01fe\0\u01fe"+ + "\0\u0374\0\u0396\0\u03b8\0\u01fe\0\u03da\0\u01fe\0\u03fc\0\u041e"+ + "\0\u0440\0\u0462\0\u01fe\0\u01fe\0\u01fe\0\u0484\0\u041e\0\u01fe"+ + "\0\u0264\0\u01fe\0\u04a6\0\u01fe\0\u04c8\0\u04ea\0\u050c\0\u052e"+ + "\0\u01fe\0\u0550\0\u0572\0\u0594\0\u05b6\0\u05d8\0\u01fe\0\u05fa"+ + "\0\u061c\0\u063e\0\u0660\0\u0682\0\u05b6\0\u050c\0\u052e\0\u01fe"+ + "\0\u06a4\0\u06c6\0\u06e8\0\u070a\0\u072c\0\u074e\0\u0770\0\u0792"+ + "\0\u07b4\0\u07d6\0\u07f8\0\u081a\0\u083c\0\u085e\0\u01fe\0\u0880"+ + "\0\u01fe\0\u08a2\0\u08c4\0\u08e6\0\u0908\0\u092a\0\u01fe\0\u094c"+ + "\0\u096e\0\u0990\0\u09b2\0\u01fe\0\u08a2\0\u09d4\0\u09f6\0\u0a18"+ + "\0\u0a3a\0\u0a5c\0\u0a7e\0\u0aa0\0\u01fe\0\u01fe\0\u0ac2\0\u0ae4"+ + "\0\u0b06\0\u0b28\0\u0b4a\0\u0b6c\0\u0b8e\0\u01fe"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[118]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\1\20\1\21\5\20\1\22\6\20\1\23\1\20\1\24"+ + "\17\20\1\21\1\20\4\25\1\26\7\25\1\27\21\25"+ + "\1\30\3\25\17\31\1\32\16\31\1\30\3\31\15\33"+ + "\1\34\7\33\1\32\12\33\2\27\14\35\1\32\22\35"+ + "\1\36\2\35\34\37\1\20\1\37\1\40\37\37\1\20"+ + "\2\37\1\40\17\37\1\41\7\37\1\32\6\37\1\20"+ + "\5\37\4\42\1\43\27\42\1\20\5\42\5\44\2\45"+ + "\2\44\3\45\1\46\3\44\1\45\1\44\3\45\1\44"+ + "\1\45\1\44\4\45\1\20\4\44\1\45\5\20\2\47"+ + "\1\50\1\20\3\47\1\46\1\51\1\23\1\20\1\52"+ + "\1\20\3\47\1\20\1\47\1\20\4\47\1\20\1\53"+ + "\1\54\1\55\1\20\1\47\7\56\1\57\4\56\1\60"+ + "\1\56\1\61\1\62\1\63\1\62\3\56\1\62\6\56"+ + "\1\62\1\56\1\64\3\56\7\65\1\57\4\65\1\60"+ + "\1\65\1\61\1\62\1\66\1\62\3\65\1\62\6\65"+ + "\1\62\2\65\1\64\2\65\27\67\1\70\4\67\1\71"+ + "\5\67\17\72\1\73\14\72\1\20\5\72\43\0\1\21"+ + "\36\0\1\21\11\0\1\74\4\0\1\75\10\0\1\76"+ + "\1\77\22\0\1\100\52\0\1\101\20\0\4\25\1\0"+ + "\7\25\1\0\21\25\1\0\3\25\4\0\1\102\35\0"+ + "\17\31\1\0\16\31\1\0\3\31\25\33\1\0\12\33"+ + "\2\0\25\33\1\32\12\33\2\0\14\35\1\0\22\35"+ + "\1\0\2\35\25\0\1\32\14\0\4\42\1\0\27\42"+ + "\1\0\5\42\4\0\1\103\40\0\4\45\2\0\3\45"+ + "\4\0\1\45\1\0\3\45\1\0\1\45\1\0\4\45"+ + "\5\0\1\45\3\0\4\47\2\0\3\47\4\0\1\47"+ + "\1\0\3\47\1\0\1\47\1\0\4\47\5\0\1\47"+ + "\10\0\1\104\4\0\1\105\10\0\1\76\27\0\1\46"+ + "\30\0\4\47\2\0\3\47\4\0\1\47\1\101\3\47"+ + "\1\0\1\47\1\0\4\47\5\0\1\47\7\56\1\0"+ + "\4\56\1\0\1\56\2\0\1\56\1\0\3\56\1\0"+ + "\6\56\1\0\1\56\1\0\12\56\1\0\4\56\1\0"+ + "\1\56\2\0\1\56\1\101\3\56\1\0\6\56\1\0"+ + "\1\56\1\0\3\56\7\65\1\0\4\65\1\0\1\65"+ + "\2\0\1\65\1\0\3\65\1\0\6\65\1\0\2\65"+ + "\1\0\11\65\1\0\4\65\1\0\1\65\2\0\1\65"+ + "\1\101\3\65\1\0\6\65\1\0\2\65\1\0\2\65"+ + "\27\106\1\107\4\106\1\71\21\106\1\110\12\106\1\111"+ + "\4\106\1\71\5\106\17\72\1\0\14\72\1\0\5\72"+ + "\17\0\1\112\26\0\1\113\11\0\1\114\51\0\1\115"+ + "\21\0\1\116\34\0\2\117\6\0\1\120\1\121\1\120"+ + "\1\0\1\122\16\0\1\117\3\0\1\117\2\0\2\123"+ + "\12\0\1\124\4\0\1\125\1\126\1\125\7\0\1\123"+ + "\3\0\1\123\15\0\1\32\41\0\1\127\31\0\1\130"+ + "\35\0\14\106\1\110\12\106\1\111\4\106\1\0\5\106"+ + "\14\0\1\131\31\0\1\132\65\0\1\133\17\0\1\134"+ + "\55\0\1\135\1\136\1\135\16\0\2\117\6\0\1\120"+ + "\1\121\1\120\20\0\1\117\3\0\1\117\2\0\1\137"+ + "\36\0\1\137\2\0\1\137\7\0\1\120\26\0\1\137"+ + "\2\0\2\122\6\0\1\140\1\141\21\0\1\122\3\0"+ + "\1\122\2\0\2\123\17\0\1\125\1\126\1\125\7\0"+ + "\1\123\3\0\1\123\2\0\2\124\17\0\1\142\1\143"+ + "\10\0\1\124\3\0\1\124\2\0\1\144\36\0\1\144"+ + "\2\0\1\144\20\0\1\125\15\0\1\144\5\0\1\145"+ + "\36\0\2\146\6\0\1\147\1\150\1\147\1\0\1\151"+ + "\16\0\1\146\3\0\1\146\32\0\1\152\32\0\1\153"+ + "\1\154\17\0\1\155\36\0\1\155\2\0\1\155\20\0"+ + "\1\135\15\0\1\155\2\0\2\140\14\0\1\27\14\0"+ + "\1\140\3\0\1\140\2\0\2\140\6\0\1\140\5\0"+ + "\1\27\14\0\1\140\3\0\1\140\2\0\2\142\22\0"+ + "\1\27\6\0\1\142\3\0\1\142\2\0\2\142\17\0"+ + "\1\142\2\0\1\27\6\0\1\142\3\0\1\142\2\0"+ + "\2\146\6\0\1\147\1\150\1\147\20\0\1\146\3\0"+ + "\1\146\2\0\1\156\36\0\1\156\2\0\1\156\7\0"+ + "\1\147\26\0\1\156\2\0\2\151\6\0\1\157\1\160"+ + "\21\0\1\151\3\0\1\151\33\0\1\161\10\0\1\153"+ + "\12\0\1\27\23\0\1\153\2\0\1\153\12\0\1\27"+ + "\5\0\1\153\15\0\1\153\2\0\2\157\1\0\1\162"+ + "\27\0\1\157\3\0\1\157\2\0\2\157\1\0\1\162"+ + "\4\0\1\157\22\0\1\157\3\0\1\157\34\0\1\163"+ + "\12\0\1\164\67\0\1\165\23\0\1\27\43\0\1\166"+ + "\23\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[2992]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state aState + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\5\1\3\0\1\1\2\0\2\1\1\0\1\1\1\11"+ + "\6\1\2\11\1\1\1\11\3\1\3\11\3\1\1\11"+ + "\1\1\1\11\4\1\3\11\2\1\1\11\1\1\1\11"+ + "\1\1\1\11\4\1\1\11\2\1\1\0\1\1\1\0"+ + "\1\11\10\0\1\11\16\0\1\11\1\0\1\11\1\1"+ + "\4\0\1\11\4\0\1\11\10\0\2\11\7\0\1\11"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[118]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the textposition at the last state to be included in yytext */ + private int zzPushbackPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /* user code: */ + /* styles */ + + public static final byte PLAIN_STYLE = 1; + public static final byte CHAR_DATA = 2; + public static final byte TAG_SYMBOLS = 3; + public static final byte COMMENT = 4; + public static final byte ATTRIBUTE_VALUE = 5; + public static final byte ATTRIBUTE_NAME = 6; + public static final byte PROCESSING_INSTRUCTION = 7; + public static final byte TAG_NAME = 8; + public static final byte RIFE_TAG = 9; + public static final byte RIFE_NAME = 10; + + /* Highlighter implementation */ + + public int getStyleCount() + { + return 10; + } + + public byte getStartState() + { + return YYINITIAL+1; + } + + public byte getCurrentState() + { + return (byte) (yystate()+1); + } + + public void setState(byte newState) + { + yybegin(newState-1); + } + + public byte getNextToken() + { + try + { + return (byte) yylex(); + } + catch (IOException e) + { + throw new InternalError(); + } + } + + public int getTokenLength() + { + return yylength(); + } + + public void setReader(Reader r) + { + this.zzReader = r; + } + + public XmlHighlighter() + { + } + + private int mReturningState; + private int mReturningStateTag; + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public XmlHighlighter(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public XmlHighlighter(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char [] zzUnpackCMap(String packed) { + char [] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1614) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do map[j++] = value; while (--count > 0); + } + return map; + } + + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzPushbackPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead < 0) { + return true; + } + else { + zzEndRead+= numRead; + return false; + } + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * cannot be reused (internal buffer is discarded and lost). + * Lexical state is set to ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position pos from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public int yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = zzLexicalState; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 27: + { yybegin(IN_COMMENT); return COMMENT; + } + case 33: break; + case 5: + { return ATTRIBUTE_VALUE; + } + case 34: break; + case 4: + { return COMMENT; + } + case 35: break; + case 21: + { yybegin(IN_TAG); return ATTRIBUTE_VALUE; + } + case 36: break; + case 20: + { yybegin(IN_TAG); return TAG_SYMBOLS; + } + case 37: break; + case 13: + { yybegin(IN_TAG); return PLAIN_STYLE; + } + case 38: break; + case 14: + { yybegin(IN_TAG); return TAG_NAME; + } + case 39: break; + case 3: + { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME); return RIFE_NAME; + } + case 40: break; + case 10: + { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME_QUOTED); return RIFE_NAME; + } + case 41: break; + case 31: + { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMMENT); return RIFE_TAG; + } + case 42: break; + case 24: + { yybegin(YYINITIAL); return PROCESSING_INSTRUCTION; + } + case 43: break; + case 28: + { mReturningState = yystate(); yybegin(IN_RIFE_TAG_COMPACT); return RIFE_TAG; + } + case 44: break; + case 22: + { return PROCESSING_INSTRUCTION; + } + case 45: break; + case 8: + { mReturningStateTag = yystate(); yybegin(IN_RIFE_NAME_SINGLEQUOTED); return RIFE_NAME; + } + case 46: break; + case 15: + { yybegin(YYINITIAL); return TAG_SYMBOLS; + } + case 47: break; + case 30: + { mReturningState = yystate(); yybegin(IN_RIFE_TAG_REGULAR); return RIFE_TAG; + } + case 48: break; + case 11: + { return RIFE_NAME; + } + case 49: break; + case 23: + { yybegin(IN_PROCESSING_INSTRUCTION); return PROCESSING_INSTRUCTION; + } + case 50: break; + case 17: + { return TAG_SYMBOLS; + } + case 51: break; + case 29: + { mReturningState = yystate(); yybegin(IN_RIFE_TAG_VELOCITY); return RIFE_TAG; + } + case 52: break; + case 1: + { return PLAIN_STYLE; + } + case 53: break; + case 2: + { return RIFE_TAG; + } + case 54: break; + case 18: + { yybegin(IN_SINGLE_QUOTE_STRING); return ATTRIBUTE_VALUE; + } + case 55: break; + case 26: + { yybegin(YYINITIAL); return CHAR_DATA; + } + case 56: break; + case 25: + { yybegin(YYINITIAL); return COMMENT; + } + case 57: break; + case 19: + { yybegin(IN_DOUBLE_QUOTE_STRING); return ATTRIBUTE_VALUE; + } + case 58: break; + case 32: + { yybegin(IN_CDATA_SECTION); return CHAR_DATA; + } + case 59: break; + case 12: + { yybegin(mReturningStateTag); return RIFE_NAME; + } + case 60: break; + case 16: + { return ATTRIBUTE_NAME; + } + case 61: break; + case 6: + { return CHAR_DATA; + } + case 62: break; + case 9: + { yybegin(mReturningState); return RIFE_TAG; + } + case 63: break; + case 7: + { yybegin(TAG_START); return TAG_SYMBOLS; + } + case 64: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return YYEOF; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/AbstractCharCollection.java b/src/main/java/com/uwyn/jhighlight/pcj/AbstractCharCollection.java new file mode 100644 index 0000000..a438f4c --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/AbstractCharCollection.java @@ -0,0 +1,208 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj; + +import com.uwyn.jhighlight.pcj.CharCollection; +import com.uwyn.jhighlight.pcj.CharIterator; +import com.uwyn.jhighlight.pcj.util.Display; +import com.uwyn.jhighlight.pcj.util.Exceptions; + +/** + * This class represents an abstract base for implementing + * collections of char values. All operations that can be implemented + * using iterators are implemented as such. In most cases, this is + * hardly an efficient solution, and at least some of those + * methods should be overridden by sub-classes. + * + *

In this implementation, size() is calculated by + * iterating over the collection. Make sure that size() + * is overwritten or that iterators do not depend on the + * size() method. + * + * @author Søren Bak + * @version 1.3 21-08-2003 20:16 + * @since 1.0 + */ +public abstract class AbstractCharCollection implements CharCollection +{ + + /** Default constructor to be invoked by sub-classes. */ + protected AbstractCharCollection() + { } + + /** + * Throws UnsupportedOperationException. + * + * @throws UnsupportedOperationException + * unconditionally. + */ + public boolean add(char v) + { Exceptions.unsupported("add"); return false; } + + public boolean addAll(CharCollection c) + { + CharIterator i = c.iterator(); // Throws NullPointerException + boolean result = false; + while (i.hasNext()) + result = result|add(i.next()); + return result; + } + + public void clear() + { + CharIterator i = iterator(); + while (i.hasNext()) + { + i.next(); + i.remove(); + } + } + + public boolean contains(char v) + { + CharIterator i = iterator(); + while (i.hasNext()) + if (i.next()==v) + return true; + return false; + } + + public boolean containsAll(CharCollection c) + { + CharIterator i = c.iterator(); // Throws NullPointerException + while (i.hasNext()) + if (!contains(i.next())) + return false; + return true; + } + + public boolean isEmpty() + { return size()==0; } + + public boolean remove(char v) + { + CharIterator i = iterator(); + boolean result = false; + while (i.hasNext()) + { + if (i.next()==v) + { + i.remove(); + result = true; + break; + } + } + return result; + } + + public boolean removeAll(CharCollection c) + { + if (c==null) + Exceptions.nullArgument("collection"); + CharIterator i = iterator(); + boolean result = false; + while (i.hasNext()) + { + if (c.contains(i.next())) + { + i.remove(); + result = true; + } + } + return result; + } + + public boolean retainAll(CharCollection c) + { + if (c==null) + Exceptions.nullArgument("collection"); + CharIterator i = iterator(); + boolean result = false; + while (i.hasNext()) + { + if (!c.contains(i.next())) + { + i.remove(); + result = true; + } + } + return result; + } + + public int size() + { + CharIterator i = iterator(); + int size = 0; + while (i.hasNext()) + { + i.next(); + size++; + } + return size; + } + + public char[] toArray() + { + return toArray(null); + } + + public char[] toArray(char[] a) + { + int size = size(); + if (a==null||a.length1) + s.append(','); + s.append(Display.display(i.next())); + } + s.append(']'); + return s.toString(); + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/CharCollection.java b/src/main/java/com/uwyn/jhighlight/pcj/CharCollection.java new file mode 100644 index 0000000..126ad7a --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/CharCollection.java @@ -0,0 +1,250 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj; + +/** + * This interface defines collections of char values. + * + * @see java.util.Collection + * + * @author Søren Bak + * @version 1.1 2002/30/12 + * @since 1.0 + */ +import com.uwyn.jhighlight.pcj.CharCollection; +import com.uwyn.jhighlight.pcj.CharIterator; + +public interface CharCollection +{ + + /** + * Adds an element to this collection. + * + * @param v + * the element to add to this collection. + * + * @return true if this collection was modified + * as a result of adding v; returns + * false otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + * + * @see #addAll(CharCollection) + */ + boolean add(char v); + + /** + * Adds all the elements of a specified collection to + * this collection. + * + * @param c + * the collection whose elements to add to this + * collection. + * + * @return true if this collection was modified + * as a result of adding the elements of c; + * returns false otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + * + * @throws NullPointerException + * if c is null. + * + * @see #add(char) + */ + boolean addAll(CharCollection c); + + /** + * Clears this collection. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + */ + void clear(); + + /** + * Indicates whether this collection contains a specified + * element. + * + * @param v + * the element to test for containment. + * + * @return true if v is contained in this + * collection; returns false otherwise. + * + * @see #containsAll(CharCollection) + */ + boolean contains(char v); + + /** + * Indicates whether all elements of a specified + * collection is contained in this collection. + * + * @param c + * the collection whose elements to test for + * containment. + * + * @return true if all the elements of c + * are contained in this collection; returns + * false otherwise. + * + * @throws NullPointerException + * if c is null. + * + * @see #contains(char) + */ + boolean containsAll(CharCollection c); + + /** + * Indicates whether this collection is equal to some object. + * + * @param obj + * the object with which to compare this collection. + * + * @return true if this collection is equals to + * obj; returns false otherwise. + */ + boolean equals(Object obj); + + /** + * Returns a hash code value for this collection. + * + * @return a hash code value for this collection. + */ + int hashCode(); + + /** + * Indicates whether this collection is empty. + * + * @return true if this collection is empty; returns + * false otherwise. + */ + boolean isEmpty(); + + /** + * Returns an iterator over this collection. + * + * @return an iterator over this collection. + */ + CharIterator iterator(); + + /** + * Removes a specified element from this collection. + * + * @param v + * the char value to remove from this collection. + * + * @return true if this collection was modified + * as a result of removing v; returns + * false otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + */ + boolean remove(char v); + + /** + * Removes all the elements of a specified collection from + * this collection. + * + * @param c + * the collection whose elements to remove from this + * collection. + * + * @return true if this collection was modified + * as a result of removing the elements of c; + * returns false otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + * + * @throws NullPointerException + * if c is null. + */ + boolean removeAll(CharCollection c); + + /** + * Retains only the elements of a specified collection in + * this collection. + * + * @param c + * the collection whose elements to retain in this + * collection. + * + * @return true if this collection was modified + * as a result of removing the elements not contained + * in c; + * returns false otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this + * collection. + * + * @throws NullPointerException + * if c is null. + */ + boolean retainAll(CharCollection c); + + /** + * Returns the number of elements in this collection. + * + * @return the number of elements in this collection. + */ + int size(); + + /** + * Returns the elements of this collection as an array. + * + * @return a new array containing the elements of this + * collection. + */ + char[] toArray(); + + /** + * Returns the elements of this collection as an array. + * + * @param a + * an array to fill with the elements of this + * collection; if a is null or not + * big enough to contain all the elements of this + * collection, an new array is allocated, + * and a is not changed. + * + * @return a, if a has room for all the + * elements of this collection; otherwise a new + * array is allocated, filled with the elements of + * this collection, and returned. + */ + char[] toArray(char[] a); + + /** + * Minimizes the memory used by this collection. The exact + * operation of this method depends on the class implementing it. + * Implementors may choose to ignore it completely. + */ + void trimToSize(); + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/CharIterator.java b/src/main/java/com/uwyn/jhighlight/pcj/CharIterator.java new file mode 100644 index 0000000..cc09cfc --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/CharIterator.java @@ -0,0 +1,71 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj; + +/** + * This class represents iterators over collections of char values. + * + * @see java.util.Iterator + * + * @author Søren Bak + * @version 1.0 2002/29/12 + * @since 1.0 + */ +public interface CharIterator +{ + + /** + * Indicates whether more char values can be returned by this + * iterator. + * + * @return true if more char values can be returned + * by this iterator; returns false + * otherwise. + * + * @see #next() + */ + boolean hasNext(); + + /** + * Returns the next char value of this iterator. + * + * @return the next char value of this iterator. + * + * @throws NoSuchElementException + * if no more elements are available from this + * iterator. + * + * @see #hasNext() + */ + char next(); + + /** + * Removes the last char value returned from the underlying + * collection. + * + * @throws UnsupportedOperationException + * if removal is not supported by this iterator. + * + * @throws IllegalStateException + * if no element has been returned by this iterator + * yet. + */ + void remove(); + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/hash/CharHashFunction.java b/src/main/java/com/uwyn/jhighlight/pcj/hash/CharHashFunction.java new file mode 100644 index 0000000..4e01225 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/hash/CharHashFunction.java @@ -0,0 +1,51 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.hash; + +/** + * This interface represents hash functions from char values + * to int values. The int value result is chosen to achieve + * consistence with the common + * {@link Object#hashCode() hashCode()} + * method. The interface is provided to alter the hash functions used + * by hashing data structures, like + * {@link com.uwyn.rife.pcj.map.CharKeyIntChainedHashMap CharKeyIntChainedHashMap} + * or + * {@link com.uwyn.rife.pcj.set.CharChainedHashSet CharChainedHashSet}. + * + * @see DefaultCharHashFunction + * + * @author Søren Bak + * @version 1.0 2002/29/12 + * @since 1.0 + */ +public interface CharHashFunction +{ + + /** + * Returns a hash code for a specified char value. + * + * @param v + * the value for which to return a hash code. + * + * @return a hash code for the specified value. + */ + int hash(char v); + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/hash/DefaultCharHashFunction.java b/src/main/java/com/uwyn/jhighlight/pcj/hash/DefaultCharHashFunction.java new file mode 100644 index 0000000..547e73f --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/hash/DefaultCharHashFunction.java @@ -0,0 +1,49 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.hash; + +import com.uwyn.jhighlight.pcj.hash.CharHashFunction; +import com.uwyn.jhighlight.pcj.hash.DefaultCharHashFunction; +import java.io.Serializable; + +/** + * This class provides a default hash function for + * char values. + * + * @serial exclude + * @author Søren Bak + * @version 1.2 2003/5/3 + * @since 1.0 + */ +public class DefaultCharHashFunction implements CharHashFunction, Serializable +{ + + /** Default instance of this hash function. */ + public static final CharHashFunction INSTANCE = new DefaultCharHashFunction(); + + /** Default constructor to be invoked by sub-classes. */ + protected DefaultCharHashFunction() + { } + + public int hash(char v) + { + return (int)v; + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/hash/Primes.java b/src/main/java/com/uwyn/jhighlight/pcj/hash/Primes.java new file mode 100644 index 0000000..38c7061 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/hash/Primes.java @@ -0,0 +1,144 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.hash; + +import com.uwyn.jhighlight.pcj.util.Exceptions; + +/** + * This class provides a static table of int sized prime numbers. + * For small numbers (0-511) it contains all primes. For larger + * numbers it contains 32 primes each time the number of bits is + * increased. I.e., there are 32 primes from 512 to 1023, + * 32 primes from 1024 to 2048, etc., the primes thus becoming less + * dense with size. Within the interval formed by using one more + * bit (say, v0 to v1), the 32 primes are formed by searching for + * the first prime greater than or equal to v0 + n*(v1-v0)/32, n + * belonging to {0,1,2, ..., 31}. This creates a reasonable + * distribution. + * + * @author Søren Bak + * @version 1.2 21-08-2003 20:21 + * @since 1.0 + */ +public class Primes +{ + + /** Prime numbers in ascending order. */ + private static final int[] primes = { + 1,3,5,7,11,13,17,19,23,29,31, + 37,41,43,47,53,59,61,67,71,73,79, + 83,89,97,101,103,107,109,113,127,131,137, + 139,149,151,157,163,167,173,179,181,191,193, + 197,199,211,223,227,229,233,239,241,251,257, + 263,269,271,277,281,283,293,307,311,313,317, + 331,337,347,349,353,359,367,373,379,383,389, + 397,401,409,419,421,431,433,439,443,449,457, + 461,463,467,479,487,491,499,503,509,521,541, + 547,563,577,593,613,631,641,659,673,691,709, + 727,739,757,769,787,809,821,839,853,877,881, + 907,919,929,947,967,977,997,1009,1031,1061,1091, + 1123,1153,1187,1217,1249,1283,1319,1361,1381,1409,1447, + 1481,1511,1543,1571,1601,1637,1667,1697,1733,1777,1801, + 1831,1861,1889,1931,1973,1987,2017,2053,2113,2179,2243, + 2309,2371,2437,2503,2579,2633,2689,2753,2819,2887,2953, + 3011,3079,3137,3203,3271,3329,3407,3457,3527,3593,3659, + 3719,3779,3847,3907,3989,4049,4099,4229,4357,4481,4621, + 4751,4871,4993,5147,5261,5381,5507,5639,5779,5897,6029, + 6151,6277,6421,6529,6659,6791,6917,7043,7177,7297,7433, + 7559,7681,7817,7937,8069,8209,8461,8707,8963,9221,9473, + 9733,10007,10243,10499,10753,11027,11273,11527,11777,12037,12289, + 12547,12809,13063,13313,13577,13829,14081,14341,14593,14851,15107, + 15361,15619,15877,16139,16411,16901,17417,17921,18433,18947,19457, + 19973,20483,21001,21517,22027,22531,23041,23557,24071,24593,25097, + 25601,26113,26627,27143,27653,28163,28687,29191,29717,30211,30727, + 31237,31751,32257,32771,33797,34819,35851,36871,37889,38917,39937, + 40961,41999,43013,44041,45061,46091,47111,48131,49157,50177,51203, + 52237,53267,54277,55313,56333,57347,58369,59393,60427,61441,62467, + 63493,64513,65537,67589,69653,71693,73751,75781,77839,79873,81929, + 83969,86017,88069,90121,92173,94219,96259,98317,100357,102407,104459, + 106501,108553,110597,112643,114689,116741,118787,120833,122887,124951,126989, + 129037,131101,135173,139267,143387,147457,151553,155653,159763,163841,167953, + 172049,176129,180233,184321,188417,192529,196613,200713,204803,208907,212999, + 217111,221197,225287,229393,233477,237571,241667,245771,249857,253969,258061, + 262147,270337,278543,286721,294919,303119,311299,319489,327689,335879,344083, + 352267,360457,368647,376837,385027,393241,401411,409609,417793,425987,434179, + 442397,450563,458789,466951,475141,483337,491527,499717,507907,516127,524309, + 540677,557057,573451,589829,606223,622603,638977,655373,671753,688133,704521, + 720899,737281,753677,770053,786433,802829,819229,835591,851971,868369,884743, + 901133,917513,933893,950281,966659,983063,999431,1015813,1032193,1048583,1081351, + 1114117,1146881,1179649,1212427,1245187,1277957,1310723,1343491,1376257,1409027,1441807, + 1474579,1507369,1540109,1572869,1605677,1638431,1671191,1703941,1736711,1769473,1802261, + 1835017,1867783,1900553,1933331,1966123,1998881,2031671,2064389,2097169,2162717,2228243, + 2293771,2359303,2424833,2490377,2555911,2621447,2686979,2752513,2818103,2883593,2949137, + 3014659,3080237,3145739,3211279,3276803,3342341,3407881,3473419,3538949,3604481,3670027, + 3735553,3801097,3866627,3932167,3997723,4063237,4128781,4194319,4325389,4456451,4587533, + 4718617,4849687,4980749,5111833,5242883,5373971,5505037,5636123,5767169,5898253,6029329, + 6160391,6291469,6422531,6553621,6684673,6815749,6946817,7077893,7208977,7340033,7471127, + 7602187,7733251,7864331,7995397,8126473,8257537,8388617,8650753,8912921,9175057,9437189, + 9699331,9961487,10223617,10485767,10747921,11010059,11272193,11534351,11796503,12058679,12320773, + 12582917,12845069,13107229,13369399,13631489,13893637,14155777,14417927,14680067,14942209,15204391, + 15466499,15728681,15990791,16252967,16515073,16777259,17301517,17825803,18350093,18874379,19398727, + 19922993,20447239,20971529,21495809,22020127,22544387,23068673,23592967,24117257,24641543,25165843, + 25690121,26214401,26738717,27262997,27787267,28311553,28835857,29360147,29884417,30408713,30933011, + 31457287,31981583,32505901,33030163,33554467,34603013,35651593,36700201,37748743,38797379,39845899, + 40894481,41943049,42991621,44040253,45088781,46137359,47185967,48234517,49283083,50331653,51380233, + 52428841,53477453,54525979,55574567,56623153,57671683,58720267,59768843,60817411,61865989,62914619, + 63963149,65011717,66060311,67108879,69206017,71303171,73400329,75497479,77594641,79691779,81788929, + 83886091,85983239,88080389,90177541,92274737,94371863,96469001,98566147,100663319,102760453,104857601, + 106954759,109051907,111149057,113246209,115343383,117440551,119537689,121634819,123731977,125829139,127926307, + 130023431,132120577,134217757,138412033,142606357,146800649,150994979,155189249,159383563,163577857,167772161, + 171966481,176160779,180355079,184549429,188743691,192937991,197132293,201326611,205520911,209715263,213909511, + 218103811,222298127,226492433,230686721,234881033,239075351,243269639,247463939,251658263,255852593,260046883, + 264241223,268435459,276824071,285212677,293601283,301989917,310378501,318767107,327155743,335544323,343932959, + 352321547,360710167,369098771,377487361,385876021,394264613,402653189,411041831,419430419,427819031,436207619, + 444596227,452984849,461373449,469762049,478150661,486539323,494927929,503316511,511705091,520093703,528482347, + 536870923,553648171,570425377,587202571,603979799,620757019,637534277,654311459,671088667,687865859,704643083, + 721420307,738197549,754974721,771751961,788529191,805306457,822083597,838860817,855638023,872415239,889192471, + 905969671,922746883,939524129,956301317,973078537,989855747,1006632983,1023410207,1040187403,1056964619,1073741827, + 1107296257,1140850699,1174405129,1207959559,1241514007,1275068423,1308622877,1342177283,1375731737,1409286161,1442840579, + 1476395029,1509949451,1543503881,1577058331,1610612741,1644167233,1677721631,1711276033,1744830469,1778384921,1811939329, + 1845493777,1879048201,1912602647,1946157079,1979711497,2013265921,2046820357,2080374797,2113929217,Integer.MAX_VALUE, + }; + + /** Prevents instantiation. */ + private Primes() + { } + + /** + * Returns from a static prime table the least prime that is greater + * than or equal to a specified value. + * + * On average, the returned prime will about 1/64 of 2(r+1) - 2r + * greater than n, where r is the order of n (the number of bits + * required for representing it). + * + * @return the least prime in the table that is greater + * than or equal to the specified value. + */ + public static int nextPrime(int n) + { + if (n<=0) + Exceptions.negativeArgument("lower bound", String.valueOf(n)); + int idx = java.util.Arrays.binarySearch(primes, n); + if (idx<0) + return primes[-idx-1]; + return primes[idx]; + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/map/AbstractCharKeyMap.java b/src/main/java/com/uwyn/jhighlight/pcj/map/AbstractCharKeyMap.java new file mode 100644 index 0000000..d7cc3f5 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/map/AbstractCharKeyMap.java @@ -0,0 +1,215 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.map; + +import com.uwyn.jhighlight.pcj.hash.DefaultCharHashFunction; +import com.uwyn.jhighlight.pcj.map.CharKeyMap; +import com.uwyn.jhighlight.pcj.map.CharKeyMapIterator; + +/** + * This class represents an abstract base for implementing + * maps from char values to objects. All operations that can be implemented + * using iterators + * are implemented as such. In most cases, this is + * hardly an efficient solution, and at least some of those + * methods should be overridden by sub-classes. + * + * @author Søren Bak + * @version 1.0 2003/10/1 + * @since 1.0 + */ +public abstract class AbstractCharKeyMap implements CharKeyMap +{ + + /** Default constructor to be invoked by sub-classes. */ + protected AbstractCharKeyMap() + { } + + public void clear() + { + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + i.remove(); + } + } + + public Object remove(char key) + { + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + if (i.getKey()==key) + { + Object value = i.getValue(); + i.remove(); + return value; + } + } + return null; + } + + public void putAll(CharKeyMap map) + { + CharKeyMapIterator i = map.entries(); + while (i.hasNext()) + { + i.next(); + put(i.getKey(), i.getValue()); + } + } + + public boolean containsKey(char key) + { + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + if (i.getKey()==key) + return true; + } + return false; + } + + public Object get(char key) + { + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + if (i.getKey()==key) + return i.getValue(); + } + return null; + } + + public boolean containsValue(Object value) + { + CharKeyMapIterator i = entries(); + if (value==null) + { + while (i.hasNext()) + { + i.next(); + if (value==null) + return true; + } + } + else + { + while (i.hasNext()) + { + i.next(); + if (value.equals(i.getValue())) + return true; + } + } + return false; + } + + public boolean equals(Object obj) + { + if (!(obj instanceof CharKeyMap)) + return false; + CharKeyMap map = (CharKeyMap)obj; + if (size()!=map.size()) + return false; + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + char k = i.getKey(); + Object v = i.getValue(); + if (v==null) + { + if (map.get(k)!=null) + return false; + if (!map.containsKey(k)) + return false; + } + else + { + if (!v.equals(map.get(k))) + return false; + } + } + return true; + } + + public int hashCode() + { + int h = 0; + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + h += (DefaultCharHashFunction.INSTANCE.hash(i.getKey())^i.getValue().hashCode()); + } + return h; + } + + public boolean isEmpty() + { return size()==0; } + + public int size() + { + int size = 0; + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + size++; + } + return size; + } + + /** + * Returns a string representation of this map. + * + * @return a string representation of this map. + */ + public String toString() + { + StringBuffer s = new StringBuffer(); + s.append('['); + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + if (s.length()>1) + s.append(','); + i.next(); + s.append(String.valueOf(i.getKey())); + s.append("->"); + s.append(String.valueOf(i.getValue())); + } + s.append(']'); + return s.toString(); + } + + /** + * Does nothing. Sub-classes may provide an implementation to + * minimize memory usage, but this is not required since many + * implementations will always have minimal memory usage. + */ + public void trimToSize() + { } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMap.java b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMap.java new file mode 100644 index 0000000..2877f7f --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMap.java @@ -0,0 +1,193 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.map; + +import com.uwyn.jhighlight.pcj.map.CharKeyMapIterator; +import com.uwyn.jhighlight.pcj.set.CharSet; + +/** + * This interface represents maps from char values to objects. + * + * @see java.util.Map + * + * @author Søren Bak + * @version 1.1 2003/6/1 + * @since 1.0 + */ +public interface CharKeyMap +{ + + /** + * Clears this map. + */ + void clear(); + + /** + * Indicates whether this map contains a mapping from a specified + * key. + * + * @param key + * the key to test for. + * + * @return true if this map contains a mapping from + * the specified key; returns false + * otherwise. + */ + boolean containsKey(char key); + + /** + * Indicates whether this map contains a mapping to a specified + * value. + * + * @param value + * the value to test for. + * + * @return true if this map contains at least one + * mapping to the specified value; returns + * false otherwise. + */ + boolean containsValue(Object value); + + /** + * Returns an iterator over the entries of this map. It is + * possible to remove entries from this map using the iterator + * provided that the concrete map supports removal of + * entries. + * + * @return an iterator over the entries of this map. + */ + CharKeyMapIterator entries(); + + /** + * Indicates whether this map is equal to some object. + * + * @param obj + * the object with which to compare this map. + * + * @return true if this map is equal to the + * specified object; returns false + * otherwise. + */ + boolean equals(Object obj); + + /** + * Maps a specified key to a value. + * + * @param key + * the key to map to a value. + * + * @return the value that the specified key maps to; returns + * null, if no mapping exists for the + * specified key. + */ + Object get(char key); + + /** + * Returns a hash code value for this map. + * + * @return a hash code value for this map. + */ + int hashCode(); + + /** + * Indicates whether this map is empty. + * + * @return true if this map is empty; returns + * false otherwise. + */ + public boolean isEmpty(); + + /** + * Returns a set view of the keys of this map. The set is not + * directly modifiable, but changes to the map are reflected in + * the set. + * + * @return a set view of the keys of this map. + */ + CharSet keySet(); + + /** + * Adds a mapping from a specified key to a specified value to + * this map. If a mapping already exists for the specified key + * it is overwritten by the new mapping. + * + * @param key + * the key of the mapping to add to this map. + * + * @param value + * the value of the mapping to add to this map. + * + * @return the old value (which can be null) if a + * mapping from the specified key already existed + * in this map; returns null otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this map. + */ + Object put(char key, Object value); + + /** + * Adds all mappings from a specified map to this map. Any + * existing mappings whose keys collide with a new mapping is + * overwritten by the new mapping. + * + * @param map + * the map whose mappings to add to this map. + * + * @throws NullPointerException + * if map is null. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this map. + */ + void putAll(CharKeyMap map); + + /** + * Removes the mapping from a specified key from this map. + * + * @param key + * the key whose mapping to remove from this map. + * + * @return the old value (which can be null) if a + * mapping from the specified key already existed + * in this map; returns null otherwise. + * + * @throws UnsupportedOperationException + * if the operation is not supported by this map. + */ + Object remove(char key); + + /** + * Returns the size of this map. The size is defined as the + * number of mappings from keys to values. + * + * @return the size of this map. + */ + int size(); + + /** + * Returns a collection view of the values in this map. The + * collection is not modifiable, but changes to the map are + * reflected in the collection. + * + * @return a collection view of the values in this map. + */ + java.util.Collection values(); + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMapIterator.java b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMapIterator.java new file mode 100644 index 0000000..06569ba --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyMapIterator.java @@ -0,0 +1,104 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.map; + +/** + * This interface represents iterators over maps from + * char values to objects. + * + * @see com.uwyn.rife.pcj.map.CharKeyMap + * @see com.uwyn.rife.pcj.CharIterator + * + * @author Søren Bak + * @version 1.0 2003/6/1 + * @since 1.0 + */ +public interface CharKeyMapIterator +{ + + /** + * Indicates whether more entries can be returned by this + * iterator. + * + * @return true if more char entries can be returned + * by this iterator; returns false + * otherwise. + * + * @see #next() + */ + boolean hasNext(); + + /** + * Advances to the next entry of this iterator. + * + * @throws java.util.NoSuchElementException + * if no more entries are available from this + * iterator. + * + * @see #hasNext() + */ + void next(); + + /** + * Removes the last entry value returned from the underlying + * map. + * + * @throws UnsupportedOperationException + * if removal is not supported by this iterator. + * + * @throws IllegalStateException + * if no entry has been returned by this iterator + * yet. + */ + void remove(); + + /** + * Returns the key of the current entry of this iterator. + * + * @return the key of the current entry of this iterator. + * + * @throws IllegalStateException + * if there is no current entry (i.e. if + * {@link #next() next()} + * has not been called or + * {@link #remove() remove()} + * has just been called. + * + * @see #getValue() + */ + char getKey(); + + /** + * Returns the value of the current entry of this iterator. + * + * @return the value of the current entry of this iterator + * (which may be null). + * + * @throws IllegalStateException + * if there is no current entry (i.e. if + * {@link #next() next()} + * has not been called or + * {@link #remove() remove()} + * has just been called. + * + * @see #getKey() + */ + Object getValue(); + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyOpenHashMap.java b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyOpenHashMap.java new file mode 100644 index 0000000..a3138de --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/map/CharKeyOpenHashMap.java @@ -0,0 +1,974 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.map; + +import com.uwyn.jhighlight.pcj.CharIterator; +import com.uwyn.jhighlight.pcj.hash.CharHashFunction; +import com.uwyn.jhighlight.pcj.hash.DefaultCharHashFunction; +import com.uwyn.jhighlight.pcj.hash.Primes; +import com.uwyn.jhighlight.pcj.map.AbstractCharKeyMap; +import com.uwyn.jhighlight.pcj.map.CharKeyMap; +import com.uwyn.jhighlight.pcj.map.CharKeyMapIterator; +import com.uwyn.jhighlight.pcj.set.AbstractCharSet; +import com.uwyn.jhighlight.pcj.set.CharSet; +import com.uwyn.jhighlight.pcj.util.Exceptions; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Iterator; + +/** + * This class represents open addressing hash table based maps from + * char values to objects. + * + * @see CharKeyChainedHashMap + * @see java.util.Map + * + * @author Søren Bak + * @version 1.3 21-08-2003 19:45 + * @since 1.0 + */ +public class CharKeyOpenHashMap extends AbstractCharKeyMap implements CharKeyMap, Cloneable, Serializable +{ + + /** Constant indicating relative growth policy. */ + private static final int GROWTH_POLICY_RELATIVE = 0; + + /** Constant indicating absolute growth policy. */ + private static final int GROWTH_POLICY_ABSOLUTE = 1; + + /** + * The default growth policy of this map. + * @see #GROWTH_POLICY_RELATIVE + * @see #GROWTH_POLICY_ABSOLUTE + */ + private static final int DEFAULT_GROWTH_POLICY = GROWTH_POLICY_RELATIVE; + + /** The default factor with which to increase the capacity of this map. */ + public static final double DEFAULT_GROWTH_FACTOR = 1.0; + + /** The default chunk size with which to increase the capacity of this map. */ + public static final int DEFAULT_GROWTH_CHUNK = 10; + + /** The default capacity of this map. */ + public static final int DEFAULT_CAPACITY = 11; + + /** The default load factor of this map. */ + public static final double DEFAULT_LOAD_FACTOR = 0.75; + + /** + * The hash function used to hash keys in this map. + * @serial + */ + private CharHashFunction keyhash; + + /** + * The size of this map. + * @serial + */ + private int size; + + /** + * The keys of this map. Contains key values directly. + * Due to the use of a secondary hash function, the length of this + * array must be a prime. + */ + private transient char[] keys; + + /** + * The values of this map. Contains values directly. + * Due to the use of a secondary hash function, the length of this + * array must be a prime. + */ + private transient Object[] values; + + /** The states of each cell in the keys[] and values[]. */ + private transient byte[] states; + + private static final byte EMPTY = 0; + private static final byte OCCUPIED = 1; + private static final byte REMOVED = 2; + + /** The number of entries in use (removed or occupied). */ + private transient int used; + + /** + * The growth policy of this map (0 is relative growth, 1 is absolute growth). + * @serial + */ + private int growthPolicy; + + /** + * The growth factor of this map, if the growth policy is + * relative. + * @serial + */ + private double growthFactor; + + /** + * The growth chunk size of this map, if the growth policy is + * absolute. + * @serial + */ + private int growthChunk; + + /** + * The load factor of this map. + * @serial + */ + private double loadFactor; + + /** + * The next size at which to expand the data[]. + * @serial + */ + private int expandAt; + + /** A set view of the keys of this map. */ + private transient CharSet ckeys; + + /** A collection view of the values of this map. */ + private transient Collection cvalues; + + private CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, int growthPolicy, double growthFactor, int growthChunk, double loadFactor) + { + if (keyhash==null) + Exceptions.nullArgument("hash function"); + if (capacity<0) + Exceptions.negativeArgument("capacity", String.valueOf(capacity)); + if (growthFactor<=0.0) + Exceptions.negativeOrZeroArgument("growthFactor", String.valueOf(growthFactor)); + if (growthChunk<=0) + Exceptions.negativeOrZeroArgument("growthChunk", String.valueOf(growthChunk)); + if (loadFactor<=0.0) + Exceptions.negativeOrZeroArgument("loadFactor", String.valueOf(loadFactor)); + this.keyhash = keyhash; + capacity = Primes.nextPrime(capacity); + keys = new char[capacity]; + values = (Object[])new Object[capacity]; + this.states = new byte[capacity]; + size = 0; + expandAt = (int)Math.round(loadFactor*capacity); + this.used = 0; + this.growthPolicy = growthPolicy; + this.growthFactor = growthFactor; + this.growthChunk = growthChunk; + this.loadFactor = loadFactor; + } + + private CharKeyOpenHashMap(int capacity, int growthPolicy, double growthFactor, int growthChunk, double loadFactor) + { + this(DefaultCharHashFunction.INSTANCE, capacity, growthPolicy, growthFactor, growthChunk, loadFactor); + } + + /** + * Creates a new hash map with capacity 11, a relative + * growth factor of 1.0, and a load factor of 75%. + */ + public CharKeyOpenHashMap() + { + this(DEFAULT_CAPACITY); + } + + /** + * Creates a new hash map with the same mappings as a specified map. + * + * @param map + * the map whose mappings to put into the new map. + * + * @throws NullPointerException + * if map is null. + */ + public CharKeyOpenHashMap(CharKeyMap map) + { + this(); + putAll(map); + } + + /** + * Creates a new hash map with a specified capacity, a relative + * growth factor of 1.0, and a load factor of 75%. + * + * @param capacity + * the initial capacity of the map. + * + * @throws IllegalArgumentException + * if capacity is negative. + */ + public CharKeyOpenHashMap(int capacity) + { + this(capacity, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, DEFAULT_LOAD_FACTOR); + } + + /** + * Creates a new hash map with a capacity of 11, a relative + * growth factor of 1.0, and a specified load factor. + * + * @param loadFactor + * the load factor of the map. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive. + */ + public CharKeyOpenHashMap(double loadFactor) + { + this(DEFAULT_CAPACITY, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity and + * load factor, and a relative growth factor of 1.0. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive. + */ + public CharKeyOpenHashMap(int capacity, double loadFactor) + { + this(capacity, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity, + * load factor, and relative growth factor. + * + *

The map capacity increases to capacity()*(1+growthFactor). + * This strategy is good for avoiding many capacity increases, but + * the amount of wasted memory is approximately the size of the map. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @param growthFactor + * the relative amount with which to increase the + * the capacity when a capacity increase is needed. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive; + * if growthFactor is not positive. + */ + public CharKeyOpenHashMap(int capacity, double loadFactor, double growthFactor) + { + this(capacity, GROWTH_POLICY_RELATIVE, growthFactor, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity, + * load factor, and absolute growth factor. + * + *

The map capacity increases to capacity()+growthChunk. + * This strategy is good for avoiding wasting memory. However, an + * overhead is potentially introduced by frequent capacity increases. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @param growthChunk + * the absolute amount with which to increase the + * the capacity when a capacity increase is needed. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive; + * if growthChunk is not positive. + */ + public CharKeyOpenHashMap(int capacity, double loadFactor, int growthChunk) + { + this(capacity, GROWTH_POLICY_ABSOLUTE, DEFAULT_GROWTH_FACTOR, growthChunk, loadFactor); + } + + // --------------------------------------------------------------- + // Constructors with hash function argument + // --------------------------------------------------------------- + + /** + * Creates a new hash map with capacity 11, a relative + * growth factor of 1.0, and a load factor of 75%. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash) + { + this(keyhash, DEFAULT_CAPACITY, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, DEFAULT_LOAD_FACTOR); + } + + /** + * Creates a new hash map with a specified capacity, a relative + * growth factor of 1.0, and a load factor of 75%. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @param capacity + * the initial capacity of the map. + * + * @throws IllegalArgumentException + * if capacity is negative. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity) + { + this(keyhash, capacity, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, DEFAULT_LOAD_FACTOR); + } + + /** + * Creates a new hash map with a capacity of 11, a relative + * growth factor of 1.0, and a specified load factor. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @param loadFactor + * the load factor of the map. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash, double loadFactor) + { + this(keyhash, DEFAULT_CAPACITY, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity and + * load factor, and a relative growth factor of 1.0. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor) + { + this(keyhash, capacity, DEFAULT_GROWTH_POLICY, DEFAULT_GROWTH_FACTOR, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity, + * load factor, and relative growth factor. + * + *

The map capacity increases to capacity()*(1+growthFactor). + * This strategy is good for avoiding many capacity increases, but + * the amount of wasted memory is approximately the size of the map. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @param growthFactor + * the relative amount with which to increase the + * the capacity when a capacity increase is needed. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive; + * if growthFactor is not positive. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor, double growthFactor) + { + this(keyhash, capacity, GROWTH_POLICY_RELATIVE, growthFactor, DEFAULT_GROWTH_CHUNK, loadFactor); + } + + /** + * Creates a new hash map with a specified capacity, + * load factor, and absolute growth factor. + * + *

The map capacity increases to capacity()+growthChunk. + * This strategy is good for avoiding wasting memory. However, an + * overhead is potentially introduced by frequent capacity increases. + * + * @param keyhash + * the hash function to use when hashing keys. + * + * @param capacity + * the initial capacity of the map. + * + * @param loadFactor + * the load factor of the map. + * + * @param growthChunk + * the absolute amount with which to increase the + * the capacity when a capacity increase is needed. + * + * @throws IllegalArgumentException + * if capacity is negative; + * if loadFactor is not positive; + * if growthChunk is not positive. + * + * @throws NullPointerException + * if keyhash is null. + */ + public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor, int growthChunk) + { + this(keyhash, capacity, GROWTH_POLICY_ABSOLUTE, DEFAULT_GROWTH_FACTOR, growthChunk, loadFactor); + } + + // --------------------------------------------------------------- + // Hash table management + // --------------------------------------------------------------- + + private void ensureCapacity(int elements) + { + if (elements>=expandAt) + { + int newcapacity; + if (growthPolicy==GROWTH_POLICY_RELATIVE) + newcapacity = (int)(keys.length*(1.0+growthFactor)); + else + newcapacity = keys.length+growthChunk; + if (newcapacity*loadFactorint); the maps's entries + * (char, Object). + * + * @since 1.1 + */ + private void writeObject(ObjectOutputStream s) throws IOException + { + s.defaultWriteObject(); + s.writeInt(keys.length); + CharKeyMapIterator i = entries(); + while (i.hasNext()) + { + i.next(); + s.writeChar(i.getKey()); + s.writeObject(i.getValue()); + } + } + + /** + * @since 1.1 + */ + private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + keys = new char[s.readInt()]; + states = new byte[keys.length]; + values = (Object[])new Object[keys.length]; + used = size; + + for (int n = 0; nget()-methods when a specified key does not + * map to any value. + * + *

Note: Later versions may provide the ability to configure + * the default values returned by maps. + * + * @author Søren Bak + * @version 1.0 2002/29/12 + * @since 1.0 + */ +public class MapDefaults +{ + + /** + * Returns a default boolean value (false). + * + * @return a default boolean value (false). + */ + public static boolean defaultBoolean() + { return false; } + + /** + * Returns a default char value ('\0'). + * + * @return a default char value ('\0'). + */ + public static char defaultChar() + { return '\0'; } + + /** + * Returns a default byte value (0). + * + * @return a default byte value (0). + */ + public static byte defaultByte() + { return 0; } + + /** + * Returns a default short value (0). + * + * @return a default short value (0). + */ + public static short defaultShort() + { return 0; } + + /** + * Returns a default int value (0). + * + * @return a default int value (0). + */ + public static int defaultInt() + { return 0; } + + /** + * Returns a default long value (0L). + * + * @return a default long value (0L). + */ + public static long defaultLong() + { return 0; } + + /** + * Returns a default float value (0.0f). + * + * @return a default float value (0.0f). + */ + public static float defaultFloat() + { return 0.0f; } + + /** + * Returns a default double value (0.0). + * + * @return a default double value (0.0). + */ + public static double defaultDouble() + { return 0.0; } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/map/NoSuchMappingException.java b/src/main/java/com/uwyn/jhighlight/pcj/map/NoSuchMappingException.java new file mode 100644 index 0000000..bcb7b73 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/map/NoSuchMappingException.java @@ -0,0 +1,48 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.map; + +/** + * Thrown to indicate that an attempt was made to retrieve a + * non-existing mapping in a map. + * + * @author Søren Bak + * @version 1.0 2002/30/12 + * @since 1.0 + */ +public class NoSuchMappingException extends RuntimeException +{ + + /** + * Creates a new exception with a specified detail message. + * The message indicates the key of the mapping that was + * not available. + * + * @param s + * the detail message. + * + * @throws NullPointerException + * if s is null. + */ + public NoSuchMappingException(String s) + { + super(s); + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/set/AbstractCharSet.java b/src/main/java/com/uwyn/jhighlight/pcj/set/AbstractCharSet.java new file mode 100644 index 0000000..6b0b8d6 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/set/AbstractCharSet.java @@ -0,0 +1,64 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.set; + +import com.uwyn.jhighlight.pcj.AbstractCharCollection; +import com.uwyn.jhighlight.pcj.CharIterator; +import com.uwyn.jhighlight.pcj.hash.DefaultCharHashFunction; +import com.uwyn.jhighlight.pcj.set.CharSet; + +/** + * This class represents an abstract base for implementing + * sets of char values. All operations that can be implemented + * using iterators and the get() and set() methods + * are implemented as such. In most cases, this is + * hardly an efficient solution, and at least some of those + * methods should be overridden by sub-classes. + * + * @author Søren Bak + * @version 1.1 2003/1/10 + * @since 1.0 + */ +public abstract class AbstractCharSet extends AbstractCharCollection implements CharSet +{ + + /** Default constructor to be invoked by sub-classes. */ + protected AbstractCharSet() + { } + + public boolean equals(Object obj) + { + if (!(obj instanceof CharSet)) + return false; + CharSet s = (CharSet)obj; + if (s.size()!=size()) + return false; + return containsAll(s); + } + + public int hashCode() + { + int h = 0; + CharIterator i = iterator(); + while (i.hasNext()) + h += DefaultCharHashFunction.INSTANCE.hash(i.next()); + return h; + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/set/CharSet.java b/src/main/java/com/uwyn/jhighlight/pcj/set/CharSet.java new file mode 100644 index 0000000..e663864 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/set/CharSet.java @@ -0,0 +1,34 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.set; + +import com.uwyn.jhighlight.pcj.CharCollection; + +/** + * This interface defines sets of char values. + * + * @see java.util.Set + * + * @author Søren Bak + * @version 1.0 2002/29/12 + * @since 1.0 + */ +public interface CharSet extends CharCollection +{ +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/util/Display.java b/src/main/java/com/uwyn/jhighlight/pcj/util/Display.java new file mode 100644 index 0000000..4f782e2 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/util/Display.java @@ -0,0 +1,89 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2002, 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.util; + +/** + * This class provides static methods for display of collection + * elements. It is only provided as a utility class for the collection + * implementations and is not a part of the API. + * + * @author Søren Bak + * @version 1.2 21-08-2003 20:25 + */ +public class Display +{ + + public static String display(boolean v) + { + return String.valueOf(v); + } + + public static String display(byte v) + { + return String.valueOf(v); + } + + public static String display(short v) + { + return String.valueOf(v); + } + + public static String display(int v) + { + return String.valueOf(v); + } + + public static String display(long v) + { + return String.valueOf(v); + } + + public static String display(float v) + { + return String.valueOf(v); + } + + public static String display(double v) + { + return String.valueOf(v); + } + + public static String display(char v) + { + return "'"+(displayChars.indexOf(v)!=-1? String.valueOf(v) :hexChar(v))+"'"; + } + + private static final String displayChars = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#�%&/()=?\'@�${[]}+|^~*-_.:,;<>\\"; + + static String hexChar(char v) + { + String s = Integer.toHexString(v); + switch (s.length()) + { + case 1: return "\\u000"+s; + case 2: return "\\u00"+s; + case 3: return "\\u0"+s; + case 4: return "\\u"+s; + default: + throw new RuntimeException("Internal error"); + } + } + +} diff --git a/src/main/java/com/uwyn/jhighlight/pcj/util/Exceptions.java b/src/main/java/com/uwyn/jhighlight/pcj/util/Exceptions.java new file mode 100644 index 0000000..a1e15f3 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/pcj/util/Exceptions.java @@ -0,0 +1,201 @@ +/* + * Primitive Collections for Java. + * Copyright (C) 2003 Søren Bak + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.uwyn.jhighlight.pcj.util; + +import com.uwyn.jhighlight.pcj.map.NoSuchMappingException; +import java.util.NoSuchElementException; + +/** + * This class provides static methods for throwing exceptions. + * It is only provided as a utility class for the collection + * implementations and is not a part of the API. + * + * @author Søren Bak + * @version 1.0 21-08-2003 18:44 + */ +public class Exceptions +{ + + public static void indexOutOfBounds(int index, int low, int high) throws IndexOutOfBoundsException + { + throw new IndexOutOfBoundsException("Index out of bounds: "+index+", valid range is "+low+" to "+high); + } + + public static void nullArgument(String name) throws NullPointerException + { + throw new NullPointerException("The specified "+name+" is null"); + } + + public static void negativeArgument(String name, Object value) throws IllegalArgumentException + { + throw new IllegalArgumentException(name+" cannot be negative: "+String.valueOf(value)); + } + + public static void negativeOrZeroArgument(String name, Object value) throws IllegalArgumentException + { + throw new IllegalArgumentException(name+" must be a positive value: "+String.valueOf(value)); + } + + // --------------------------------------------------------------- + // Iterator errors + // --------------------------------------------------------------- + + public static void endOfIterator() throws NoSuchElementException + { + throw new NoSuchElementException("Attempt to iterate past iterator's last element."); + } + + public static void startOfIterator() throws NoSuchElementException + { + throw new NoSuchElementException("Attempt to iterate past iterator's first element."); + } + + public static void noElementToRemove() throws IllegalStateException + { + throw new IllegalStateException("Attempt to remove element from iterator that has no current element."); + } + + public static void noElementToGet() throws IllegalStateException + { + throw new IllegalStateException("Attempt to get element from iterator that has no current element. Call next() first."); + } + + public static void noElementToSet() throws IllegalStateException + { + throw new IllegalStateException("Attempt to set element in iterator that has no current element."); + } + + // --------------------------------------------------------------- + // Map errors + // --------------------------------------------------------------- + + public static void noLastElement() throws IllegalStateException + { + throw new IllegalStateException("No value to return. Call containsKey() first."); + } + + public static void noSuchMapping(Object key) throws NoSuchMappingException + { + throw new NoSuchMappingException("No such key in map: "+String.valueOf(key)); + } + + // --------------------------------------------------------------- + // Deque errors + // --------------------------------------------------------------- + + public static void dequeNoFirst() throws IndexOutOfBoundsException + { + throw new IndexOutOfBoundsException("Attempt to get first element of empty deque"); + } + + public static void dequeNoLast() throws IndexOutOfBoundsException + { + throw new IndexOutOfBoundsException("Attempt to get last element of empty deque"); + } + + public static void dequeNoFirstToRemove() throws IndexOutOfBoundsException + { + throw new IndexOutOfBoundsException("Attempt to remove last element of empty deque"); + } + + public static void dequeNoLastToRemove() throws IndexOutOfBoundsException + { + throw new IndexOutOfBoundsException("Attempt to remove last element of empty deque"); + } + + // --------------------------------------------------------------- + // Adapter value errors + // --------------------------------------------------------------- + + public static void nullElementNotAllowed() throws IllegalArgumentException + { + throw new IllegalArgumentException("Attempt to add a null value to an adapted primitive set."); + } + + public static void cannotAdapt(String name) throws IllegalStateException + { + throw new IllegalStateException("The "+name+" contains values preventing it from being adapted to a primitive "+name); + } + + // --------------------------------------------------------------- + // + // --------------------------------------------------------------- + + public static void unsupported(String name) throws UnsupportedOperationException + { + throw new UnsupportedOperationException("Attempt to invoke unsupported operation: "+name); + } + + public static void unmodifiable(String name) throws UnsupportedOperationException + { + throw new UnsupportedOperationException("Attempt to modify unmodifiable "+name); + } + + public static void cloning() throws RuntimeException + { + throw new RuntimeException("Clone is not supported"); + } + + public static void invalidRangeBounds(Object first, Object last) throws IllegalArgumentException + { + throw new IllegalArgumentException("First ("+first+") cannot be greater than last ("+last+")"); + } + + public static void cannotMergeRanges(Object r1, Object r2) throws IllegalArgumentException + { + throw new IllegalArgumentException("Ranges cannot be merged: "+r1.toString()+" and "+r2.toString()); + } + + // --------------------------------------------------------------- + // Sorted set errors + // --------------------------------------------------------------- + + public static void setNoFirst() throws NoSuchElementException + { + throw new NoSuchElementException("Attempt to get first element of empty set"); + } + + public static void setNoLast() throws NoSuchElementException + { + throw new NoSuchElementException("Attempt to get last element of empty set"); + } + + public static void invalidSetBounds(Object low, Object high) throws IllegalArgumentException + { + throw new IllegalArgumentException("Lower bound ("+low+") cannot be greater than upper bound ("+high+")"); + } + + public static void valueNotInSubRange(Object value) throws IllegalArgumentException + { + throw new IllegalArgumentException("Attempt to add a value outside valid range: "+value); + } + + public static void invalidUpperBound(Object value) throws IllegalArgumentException + { + throw new IllegalArgumentException("Upper bound is not in valid sub-range: "+value); + } + + public static void invalidLowerBound(Object value) throws IllegalArgumentException + { + throw new IllegalArgumentException("Lower bound is not in valid sub-range: "+value); + } + + + +} diff --git a/src/main/java/com/uwyn/jhighlight/renderer/CppXhtmlRenderer.java b/src/main/java/com/uwyn/jhighlight/renderer/CppXhtmlRenderer.java new file mode 100644 index 0000000..8c23ada --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/CppXhtmlRenderer.java @@ -0,0 +1,120 @@ +/* + * Copyright 2006 Arnout Engelen + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: CppXhtmlRenderer.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import com.uwyn.jhighlight.highlighter.CppHighlighter; +import com.uwyn.jhighlight.highlighter.ExplicitStateHighlighter; +import com.uwyn.jhighlight.renderer.XhtmlRenderer; +import java.util.HashMap; +import java.util.Map; + +/** + * Generates highlighted syntax in XHTML from Cpp source. + * + * @author Arnout Engelen (arnouten[remove] at bzzt dot net) + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 0$ + */ +public class CppXhtmlRenderer extends XhtmlRenderer +{ + public final static HashMap DEFAULT_CSS = new HashMap() {{ + put("h1", + "font-family: sans-serif; " + + "font-size: 16pt; " + + "font-weight: bold; " + + "color: rgb(0,0,0); " + + "background: rgb(210,210,210); " + + "border: solid 1px black; " + + "padding: 5px; " + + "text-align: center;"); + + put("code", + "color: rgb(0,0,0); " + + "font-family: monospace; " + + "font-size: 12px; " + + "white-space: nowrap;"); + + put(".cpp_plain", + "color: rgb(0,0,0);"); + + put(".cpp_keyword", + "color: rgb(0,0,0); " + + "font-weight: bold;"); + + put(".cpp_type", + "color: rgb(0,44,221);"); + + put(".cpp_operator", + "color: rgb(0,124,31);"); + + put(".cpp_separator", + "color: rgb(0,33,255);"); + + put(".cpp_literal", + "color: rgb(188,0,0);"); + + put(".cpp_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247);"); + + put(".cpp_doxygen_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic;"); + + put(".cpp_doxygen_tag", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic; " + + "font-weight: bold;"); + + put(".cpp_preproc", + "color: purple;"); + }}; + + protected Map getDefaultCssStyles() + { + return DEFAULT_CSS; + } + + protected String getCssClass(int style) + { + switch (style) + { + case CppHighlighter.PLAIN_STYLE: + return "cpp_plain"; + case CppHighlighter.KEYWORD_STYLE: + return "cpp_keyword"; + case CppHighlighter.TYPE_STYLE: + return "cpp_type"; + case CppHighlighter.OPERATOR_STYLE: + return "cpp_operator"; + case CppHighlighter.SEPARATOR_STYLE: + return "cpp_separator"; + case CppHighlighter.LITERAL_STYLE: + return "cpp_literal"; + case CppHighlighter.CPP_COMMENT_STYLE: + return "cpp_comment"; + case CppHighlighter.DOXYGEN_COMMENT_STYLE: + return "cpp_doxygen_comment"; + case CppHighlighter.DOXYGEN_TAG_STYLE: + return "cpp_doxygen_tag"; + case CppHighlighter.PREPROC_STYLE: + return "cpp_preproc"; + } + + return null; + } + + protected ExplicitStateHighlighter getHighlighter() + { + return new CppHighlighter(); + } +} + diff --git a/src/main/java/com/uwyn/jhighlight/renderer/GroovyXhtmlRenderer.java b/src/main/java/com/uwyn/jhighlight/renderer/GroovyXhtmlRenderer.java new file mode 100644 index 0000000..272c54e --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/GroovyXhtmlRenderer.java @@ -0,0 +1,114 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: GroovyXhtmlRenderer.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import com.uwyn.jhighlight.highlighter.ExplicitStateHighlighter; +import com.uwyn.jhighlight.highlighter.GroovyHighlighter; +import com.uwyn.jhighlight.renderer.XhtmlRenderer; +import java.util.HashMap; +import java.util.Map; + +/** + * Generates highlighted syntax in XHTML from Groovy source. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class GroovyXhtmlRenderer extends XhtmlRenderer +{ + public final static HashMap DEFAULT_CSS = new HashMap() {{ + put("h1", + "font-family: sans-serif; " + + "font-size: 16pt; " + + "font-weight: bold; " + + "color: rgb(0,0,0); " + + "background: rgb(210,210,210); " + + "border: solid 1px black; " + + "padding: 5px; " + + "text-align: center;"); + + put("code", + "color: rgb(0,0,0); " + + "font-family: monospace; " + + "font-size: 12px; " + + "white-space: nowrap;"); + + put(".java_plain", + "color: rgb(0,0,0);"); + + put(".java_keyword", + "color: rgb(0,0,0); " + + "font-weight: bold;"); + + put(".java_type", + "color: rgb(0,44,221);"); + + put(".java_operator", + "color: rgb(0,124,31);"); + + put(".java_separator", + "color: rgb(0,33,255);"); + + put(".java_literal", + "color: rgb(188,0,0);"); + + put(".java_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247);"); + + put(".java_javadoc_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic;"); + + put(".java_javadoc_tag", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic; " + + "font-weight: bold;"); + }}; + + protected Map getDefaultCssStyles() + { + return DEFAULT_CSS; + } + + protected String getCssClass(int style) + { + switch (style) + { + case GroovyHighlighter.PLAIN_STYLE: + return "java_plain"; + case GroovyHighlighter.KEYWORD_STYLE: + return "java_keyword"; + case GroovyHighlighter.TYPE_STYLE: + return "java_type"; + case GroovyHighlighter.OPERATOR_STYLE: + return "java_operator"; + case GroovyHighlighter.SEPARATOR_STYLE: + return "java_separator"; + case GroovyHighlighter.LITERAL_STYLE: + return "java_literal"; + case GroovyHighlighter.JAVA_COMMENT_STYLE: + return "java_comment"; + case GroovyHighlighter.JAVADOC_COMMENT_STYLE: + return "java_javadoc_comment"; + case GroovyHighlighter.JAVADOC_TAG_STYLE: + return "java_javadoc_tag"; + } + + return null; + } + + protected ExplicitStateHighlighter getHighlighter() + { + return new GroovyHighlighter(); + } +} + diff --git a/src/main/java/com/uwyn/jhighlight/renderer/JavaXhtmlRenderer.java b/src/main/java/com/uwyn/jhighlight/renderer/JavaXhtmlRenderer.java new file mode 100644 index 0000000..3e2ff25 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/JavaXhtmlRenderer.java @@ -0,0 +1,117 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: JavaXhtmlRenderer.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import com.uwyn.jhighlight.highlighter.ExplicitStateHighlighter; +import com.uwyn.jhighlight.highlighter.JavaHighlighter; +import com.uwyn.jhighlight.renderer.XhtmlRenderer; +import java.util.HashMap; +import java.util.Map; + +/** + * Generates highlighted syntax in XHTML from Java source. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class JavaXhtmlRenderer extends XhtmlRenderer +{ + public final static HashMap DEFAULT_CSS = new HashMap() {{ + put("h1", + "font-family: sans-serif; " + + "font-size: 16pt; " + + "font-weight: bold; " + + "color: rgb(0,0,0); " + + "background: rgb(210,210,210); " + + "border: solid 1px black; " + + "padding: 5px; " + + "text-align: center;"); + + put("code", + "color: rgb(0,0,0); " + + "font-family: monospace; " + + "font-size: 12px; " + + "white-space: nowrap;"); + + put(".java_plain", + "color: rgb(0,0,0);"); + + put(".java_keyword", + "color: rgb(0,0,0); " + + "font-weight: bold;"); + + put(".java_type", + "color: rgb(0,44,221);"); + + put(".java_operator", + "color: rgb(0,124,31);"); + + put(".java_separator", + "color: rgb(0,33,255);"); + + put(".java_literal", + "color: rgb(188,0,0);"); + + put(".java_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247);"); + + put(".java_javadoc_comment", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic;"); + + put(".java_javadoc_tag", + "color: rgb(147,147,147); " + + "background-color: rgb(247,247,247); " + + "font-style: italic; " + + "font-weight: bold;"); + }}; + + protected Map getDefaultCssStyles() + { + return DEFAULT_CSS; + } + + protected String getCssClass(int style) + { + switch (style) + { + case JavaHighlighter.PLAIN_STYLE: + return "java_plain"; + case JavaHighlighter.KEYWORD_STYLE: + return "java_keyword"; + case JavaHighlighter.TYPE_STYLE: + return "java_type"; + case JavaHighlighter.OPERATOR_STYLE: + return "java_operator"; + case JavaHighlighter.SEPARATOR_STYLE: + return "java_separator"; + case JavaHighlighter.LITERAL_STYLE: + return "java_literal"; + case JavaHighlighter.JAVA_COMMENT_STYLE: + return "java_comment"; + case JavaHighlighter.JAVADOC_COMMENT_STYLE: + return "java_javadoc_comment"; + case JavaHighlighter.JAVADOC_TAG_STYLE: + return "java_javadoc_tag"; + } + + return null; + } + + protected ExplicitStateHighlighter getHighlighter() + { + JavaHighlighter highlighter = new JavaHighlighter(); + highlighter.ASSERT_IS_KEYWORD = true; + + return highlighter; + } +} + diff --git a/src/main/java/com/uwyn/jhighlight/renderer/Renderer.java b/src/main/java/com/uwyn/jhighlight/renderer/Renderer.java new file mode 100644 index 0000000..65ebb1b --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/Renderer.java @@ -0,0 +1,58 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: Renderer.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Provides interface to render the source code highlighting. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public interface Renderer +{ + /** + * Transforms source code that's provided through an + * InputStream to highlighted syntax and writes it back to + * an OutputStream. + * + * @param name The name of the source file. + * @param in The input stream that provides the source code that needs to + * be transformed. + * @param out The output stream to which to result should be written. + * @param encoding The encoding that will be used to read and write the + * text. + * @param fragment true if the result should be a fragment; + * or false if it should be a complete document + * @see #highlight(String, String, String, boolean) + * @since 1.0 + */ + public void highlight(String name, InputStream in, OutputStream out, String encoding, boolean fragment) throws IOException; + + /** + * Transforms source code that's provided through a + * String to highlighted syntax and returns it as a + * String. + * + * @param name The name of the source file. + * @param in The input string that provides the source code that needs to + * be transformed. + * @param encoding The encoding that will be used to read and write the + * text. + * @param fragment true if the result should be a fragment; + * or false if it should be a complete document + * @return the highlighted source code as a string + * @see #highlight(String, InputStream, OutputStream, String, boolean) + * @since 1.0 + */ + public String highlight(String name, String in, String encoding, boolean fragment) throws IOException; +} diff --git a/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRenderer.java b/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRenderer.java new file mode 100644 index 0000000..b3dfd9a --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRenderer.java @@ -0,0 +1,325 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: XhtmlRenderer.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import java.io.*; + +import com.uwyn.jhighlight.JHighlightVersion; +import com.uwyn.jhighlight.highlighter.ExplicitStateHighlighter; +import com.uwyn.jhighlight.tools.ExceptionUtils; +import com.uwyn.jhighlight.tools.StringUtils; +import java.net.URL; +import java.net.URLConnection; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Logger; + +/** + * Provides an abstract base class to perform source code to XHTML syntax + * highlighting. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public abstract class XhtmlRenderer implements Renderer +{ + /** + * Transforms source code that's provided through an + * InputStream to highlighted syntax in XHTML and writes it + * back to an OutputStream. + *

If the highlighting has to become a fragment, no CSS styles will be + * generated. + *

For complete documents, there's a collection of default styles that + * will be included. It's possible to override these by changing the + * provided jhighlight.properties file. It's best to look at + * this file in the JHighlight archive and modify the styles that are + * there already. + * + * @param name The name of the source file. + * @param in The input stream that provides the source code that needs to + * be transformed. + * @param out The output stream to which to resulting XHTML should be + * written. + * @param encoding The encoding that will be used to read and write the + * text. + * @param fragment true if the generated XHTML should be a + * fragment; or false if it should be a complete page + * @see #highlight(String, String, String, boolean) + * @since 1.0 + */ + public void highlight(String name, InputStream in, OutputStream out, String encoding, boolean fragment) + throws IOException + { + ExplicitStateHighlighter highlighter = getHighlighter(); + + Reader isr; + Writer osw; + if (null == encoding) + { + isr = new InputStreamReader(in); + osw = new OutputStreamWriter(out); + } + else + { + isr = new InputStreamReader(in, encoding); + osw = new OutputStreamWriter(out, encoding); + } + + BufferedReader r = new BufferedReader(isr); + BufferedWriter w = new BufferedWriter(osw); + + if (fragment) + { + w.write(getXhtmlHeaderFragment(name)); + } + else + { + w.write(getXhtmlHeader(name)); + } + + String line; + String token; + int length; + int style; + String css_class; + int previous_style = 0; + boolean newline = false; + while ((line = r.readLine()) != null) + { + line += "\n"; + line = StringUtils.convertTabsToSpaces(line, 4); + + // should be optimized by reusing a custom LineReader class + Reader lineReader = new StringReader(line); + highlighter.setReader(lineReader); + int index = 0; + while (index < line.length()) + { + style = highlighter.getNextToken(); + length = highlighter.getTokenLength(); + token = line.substring(index, index + length); + + if (style != previous_style || + newline) + { + css_class = getCssClass(style); + + if (css_class != null) + { + if (previous_style != 0 && !newline) + { + w.write(""); + } + w.write(""); + + previous_style = style; + } + } + newline = false; + w.write(StringUtils.replace(StringUtils.encodeHtml(StringUtils.replace(token, "\n", "")), " ", " ")); + + index += length; + } + + w.write("
\n"); + newline = true; + } + + if (!fragment) w.write(getXhtmlFooter()); + + w.flush(); + w.close(); + } + + /** + * Transforms source code that's provided through a + * String to highlighted syntax in XHTML and returns it + * as a String. + *

If the highlighting has to become a fragment, no CSS styles will be + * generated. + * + * @param name The name of the source file. + * @param in The input string that provides the source code that needs to + * be transformed. + * @param encoding The encoding that will be used to read and write the + * text. + * @param fragment true if the generated XHTML should be a + * fragment; or false if it should be a complete page + * or false if it should be a complete document + * @return the highlighted source code as XHTML in a string + * @see #highlight(String, InputStream, OutputStream, String, boolean) + * @since 1.0 + */ + public String highlight(String name, String in, String encoding, boolean fragment) + throws IOException + { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + highlight(name, new StringBufferInputStream(in), out, encoding, fragment); + return out.toString(encoding); + } + + /** + * Returns a map of all the CSS styles that the renderer requires, + * together with default definitions for them. + * + * @return The map of CSS styles. + * @since 1.0 + */ + protected abstract Map getDefaultCssStyles(); + + /** + * Looks up the CSS class identifier that corresponds to the syntax style. + * + * @param style The syntax style. + * @return The requested CSS class identifier; or + *

null if the syntax style isn't supported. + * @since 1.0 + */ + protected abstract String getCssClass(int style); + + /** + * Returns the language-specific highlighting lexer that should be used + * + * @return The requested highlighting lexer. + * @since 1.0 + */ + protected abstract ExplicitStateHighlighter getHighlighter(); + + /** + * Returns all the CSS class definitions that should appear within the + * style XHTML tag. + *

This should support all the classes that the + * getCssClass(int) method returns. + * + * @return The CSS class definitions + * @see #getCssClass(int) + * @since 1.0 + */ + protected String getCssClassDefinitions() + { + StringBuffer css = new StringBuffer(); + + Properties properties = new Properties(); + + URL jhighlighter_props = getClass().getClassLoader().getResource("jhighlight.properties"); + if (jhighlighter_props != null) + { + try + { + URLConnection connection = jhighlighter_props.openConnection(); + connection.setUseCaches(false); + InputStream is = connection.getInputStream(); + + try + { + properties.load(is); + } + finally + { + is.close(); + } + } + catch (IOException e) + { + Logger.getLogger("com.uwyn.jhighlight").warning("Error while reading the '" + jhighlighter_props.toExternalForm() + "' resource, using default CSS styles.\n" + ExceptionUtils.getExceptionStackTrace(e)); + } + } + + Iterator it = getDefaultCssStyles().entrySet().iterator(); + Map.Entry entry; + while (it.hasNext()) + { + entry = (Map.Entry)it.next(); + + String key = (String)entry.getKey(); + + css.append(key); + css.append(" {\n"); + + if (properties.containsKey(key)) + { + css.append(properties.get(key)); + } + else + { + css.append(entry.getValue()); + } + + css.append("\n}\n"); + } + + return css.toString(); + } + + /** + * Returns the XHTML header that preceedes the highlighted source code. + *

It will integrate the CSS class definitions and use the source's + * name to indicate in XHTML which file has been highlighted. + * + * @param name The name of the source file. + * @return The constructed XHTML header. + * @since 1.0 + */ + protected String getXhtmlHeader(String name) + { + if (null == name) + { + name = ""; + } + + return + "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " " + StringUtils.encodeHtml(name) + "\n" + + " \n" + + " \n" + + "\n" + + "\n" + + "

" + StringUtils.encodeHtml(name) + "

" + + ""; + } + + /** + * Returns the XHTML header that preceedes the highlighted source code for + * a fragment. + * + * @param name The name of the source file. + * @return The constructed XHTML header. + * @since 1.0 + */ + protected String getXhtmlHeaderFragment(String name) + { + if (null == name) + { + name = ""; + } + + return "\n"; + } + + /** + * Returns the XHTML footer that nicely finishes the file after the + * highlighted source code. + * + * @return The requested XHTML footer. + * @since 1.0 + */ + protected String getXhtmlFooter() + { + return "\n\n\n"; + + } +} diff --git a/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRendererFactory.java b/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRendererFactory.java new file mode 100644 index 0000000..71e1a92 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/XhtmlRendererFactory.java @@ -0,0 +1,89 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: XhtmlRendererFactory.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.renderer; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Provides a single point of entry to instantiate Xhtml renderers. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public abstract class XhtmlRendererFactory +{ + public final static String GROOVY = "groovy"; + public final static String JAVA = "java"; + public final static String BEANSHELL = "beanshell"; + public final static String BSH = "bsh"; + public final static String XML = "xml"; + public final static String XHTML = "xhtml"; + public final static String LZX = "lzx"; + public final static String HTML = "html"; + public final static String CPP = "cpp"; + public final static String CXX = "cxx"; + public final static String CPLUSPLUS = "c++"; + + private final static Map RENDERERS_CLASSNAMES = new HashMap() {{ + put(GROOVY, GroovyXhtmlRenderer.class.getName()); + put(JAVA, JavaXhtmlRenderer.class.getName()); + put(BEANSHELL, JavaXhtmlRenderer.class.getName()); + put(BSH, JavaXhtmlRenderer.class.getName()); + put(XML, XmlXhtmlRenderer.class.getName()); + put(XHTML, XmlXhtmlRenderer.class.getName()); + put(LZX, XmlXhtmlRenderer.class.getName()); + put(HTML, XmlXhtmlRenderer.class.getName()); + put(CPP, CppXhtmlRenderer.class.getName()); + put(CXX, CppXhtmlRenderer.class.getName()); + put(CPLUSPLUS, CppXhtmlRenderer.class.getName()); + }}; + + /** + * Instantiates an instance of a known XhtmlRenderer according to + * the type that's provided. + * + * @param type The type of renderer, look at the static variables of this + * class to see which ones are supported. + * @return an instance of the XhtmlRenderer that corresponds to the type; or + *

null if the type wasn't known + * @since 1.0 + */ + public static Renderer getRenderer(String type) + { + String classname = (String)RENDERERS_CLASSNAMES.get(type.toLowerCase()); + if (null == classname) + { + return null; + } + + try + { + Class klass = Class.forName(classname); + return (Renderer)klass.newInstance(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + /** + * Returned a set with all the supported XHTML renderer types. + * + * @return a Set with the supported XHTML renderer types as strings. + * @since 1.0 + */ + public static Set getSupportedTypes() + { + return Collections.unmodifiableSet(RENDERERS_CLASSNAMES.keySet()); + } +} diff --git a/src/main/java/com/uwyn/jhighlight/renderer/XmlXhtmlRenderer.java b/src/main/java/com/uwyn/jhighlight/renderer/XmlXhtmlRenderer.java new file mode 100644 index 0000000..b8d8fa6 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/renderer/XmlXhtmlRenderer.java @@ -0,0 +1,120 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: XmlXhtmlRenderer.java 3108 2006-03-13 18:03:00Z gbevin $ +*/ +package com.uwyn.jhighlight.renderer; + +import com.uwyn.jhighlight.highlighter.ExplicitStateHighlighter; +import com.uwyn.jhighlight.highlighter.XmlHighlighter; +import com.uwyn.jhighlight.renderer.XhtmlRenderer; +import java.util.HashMap; +import java.util.Map; + +/** + * Generates highlighted syntax in XHTML from XML source. + *

RIFE template tags are also + * supported and will be clearly highlighted. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class XmlXhtmlRenderer extends XhtmlRenderer +{ + public final static HashMap DEFAULT_CSS = new HashMap() {{ + put("h1", + "font-family: sans-serif; "+ + "font-size: 16pt; "+ + "font-weight: bold; "+ + "color: rgb(0,0,0); "+ + "background: rgb(210,210,210); "+ + "border: solid 1px black; "+ + "padding: 5px; "+ + "text-align: center;"); + + put("code", + "color: rgb(0,0,0); "+ + "font-family: monospace; "+ + "font-size: 12px; " + + "white-space: nowrap;"); + + put(".xml_plain", + "color: rgb(0,0,0);"); + + put(".xml_char_data", + "color: rgb(0,0,0);"); + + put(".xml_tag_symbols", + "color: rgb(0,59,255);"); + + put(".xml_comment", + "color: rgb(147,147,147); "+ + "background-color: rgb(247,247,247);"); + + put(".xml_attribute_value", + "color: rgb(193,0,0);"); + + put(".xml_attribute_name", + "color: rgb(0,0,0); "+ + "font-weight: bold;"); + + put(".xml_processing_instruction", + "color: rgb(0,0,0); "+ + "font-weight: bold; "+ + "font-style: italic;"); + + put(".xml_tag_name", + "color: rgb(0,55,255);"); + + put(".xml_rife_tag", + "color: rgb(0,0,0); "+ + "background-color: rgb(228,230,160);"); + + put(".xml_rife_name", + "color: rgb(0,0,196); "+ + "background-color: rgb(228,230,160);"); + }}; + + protected Map getDefaultCssStyles() + { + return DEFAULT_CSS; + } + + protected String getCssClass(int style) + { + switch (style) + { + case XmlHighlighter.PLAIN_STYLE: + return "xml_plain"; + case XmlHighlighter.CHAR_DATA: + return "xml_char_data"; + case XmlHighlighter.TAG_SYMBOLS: + return "xml_tag_symbols"; + case XmlHighlighter.COMMENT: + return "xml_comment"; + case XmlHighlighter.ATTRIBUTE_VALUE: + return "xml_attribute_value"; + case XmlHighlighter.ATTRIBUTE_NAME: + return "xml_attribute_name"; + case XmlHighlighter.PROCESSING_INSTRUCTION: + return "xml_processing_instruction"; + case XmlHighlighter.TAG_NAME: + return "xml_tag_name"; + case XmlHighlighter.RIFE_TAG: + return "xml_rife_tag"; + case XmlHighlighter.RIFE_NAME: + return "xml_rife_name"; + } + + return null; + } + + protected ExplicitStateHighlighter getHighlighter() + { + return new XmlHighlighter(); + } +} + diff --git a/src/main/java/com/uwyn/jhighlight/servlet/HighlightFilter.java b/src/main/java/com/uwyn/jhighlight/servlet/HighlightFilter.java new file mode 100644 index 0000000..3f8d352 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/servlet/HighlightFilter.java @@ -0,0 +1,236 @@ +/* + * Copyright 2004-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: HighlightFilter.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.servlet; + +import javax.servlet.*; + +import com.uwyn.jhighlight.renderer.Renderer; +import com.uwyn.jhighlight.renderer.XhtmlRendererFactory; +import com.uwyn.jhighlight.tools.FileUtils; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +/** + * A servlet filter that offers on-the-fly syntax highlighting for Java, HTML, + * XHTML, XML and LZX files. + *

The filter should be declared in a similar fashion as this: + *

<filter>
+ *    <filter-name>jhighlight</filter-name>
+ *    <filter-class>com.uwyn.jhighlight.servlet.HighlightFilter</filter-class>
+ *</filter>
+ *
+ *<filter-mapping>
+ *    <filter-name>jhighlight</filter-name>
+ *    <url-pattern>/*</url-pattern>
+ *</filter-mapping>
+ *

It will respond to files with the following extensions: + * .javas, .htmls, .htms, + * .xhtmls, .xmls and .lzxs. These will + * be automatically mapped to files without the last s in the + * filenames. Thus, for example, a request like this: + *

http://myhost.com/folder/MySource.javas
+ *

will retrieve this file: + *

http://myhost.com/folder/MySource.java
+ *

The contents of this file will be automatically highlighted and the + * resulting HTML will be served. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public final class HighlightFilter implements Filter +{ + public void init(FilterConfig filterConfig) + { + } + + public void destroy() + { + } + + public void doFilter(ServletRequest request, + ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + if (request instanceof HttpServletRequest && + response instanceof HttpServletResponse) + { + HttpServletRequest http_request = (HttpServletRequest)request; + HttpServletResponse http_response = (HttpServletResponse)response; + + Renderer renderer = null; + String uri = http_request.getRequestURI(); + String extension = FileUtils.getExtension(uri); + if (extension != null && + extension.endsWith("s")) + { + renderer = XhtmlRendererFactory.getRenderer(extension.substring(0, extension.length()-1)); + } + + if (renderer != null) + { + SourceRequestWrapper request_wrapper = new SourceRequestWrapper(http_request); + CharResponseWrapper response_wrapper = new CharResponseWrapper(http_response); + + chain.doFilter(request_wrapper, response_wrapper); + + OutputStream out = response.getOutputStream(); + try + { + if (HttpServletResponse.SC_OK == response_wrapper.getStatus()) + { + InputStream is = new ByteArrayInputStream(response_wrapper.getWrappedOutputStream().toByteArray()); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + String encoding = request.getCharacterEncoding(); + if (null == encoding) + { + encoding = "UTF-8"; + } + + renderer.highlight(http_request.getServletPath().substring(1), is, os, encoding, false); + + String highlighted = os.toString("ISO-8859-1"); + + response.setContentType("text/html"); + response.setContentLength(highlighted.length()); + out.write(highlighted.getBytes("ISO-8859-1")); + } + else + { + out.write(response_wrapper.getWrappedOutputStream().toByteArray()); + } + } + finally + { + out.close(); + } + } + else + { + chain.doFilter(request, response); + } + } + else + { + chain.doFilter(request, response); + } + } + + private static class SourceRequestWrapper extends HttpServletRequestWrapper + { + public SourceRequestWrapper(HttpServletRequest request) + { + super(request); + } + + public String getServletPath() + { + String path = super.getServletPath(); + return path.substring(0, path.length() - 1); + } + + public String getPathTranslated() + { + String path = super.getPathTranslated(); + return path.substring(0, path.length() - 1); + } + + public String getRequestURI() + { + String uri = super.getRequestURI(); + return uri.substring(0, uri.length() - 1); + } + + public StringBuffer getRequestURL() + { + StringBuffer url = super.getRequestURL(); + url.setLength(url.length() - 1); + return url; + } + } + + private static class CharResponseWrapper extends HttpServletResponseWrapper + { + private ServletOutputStreamWrapper mOutput; + private int mStatus = HttpServletResponse.SC_OK; + + public ServletOutputStreamWrapper getWrappedOutputStream() + { + return mOutput; + } + + public CharResponseWrapper(HttpServletResponse response) + { + super(response); + + mOutput = new ServletOutputStreamWrapper(); + } + + public ServletOutputStream getOutputStream() + throws IOException + { + return mOutput; + } + + public void setStatus(int status) + { + mStatus = status; + + super.setStatus(status); + } + + public void sendError(int status, String msg) + throws IOException + { + mStatus = status; + + super.sendError(status, msg); + } + + public void sendError(int status) + throws IOException + { + mStatus = status; + + super.sendError(status); + } + + public int getStatus() + { + return mStatus; + } + } + + private static class ServletOutputStreamWrapper extends ServletOutputStream + { + protected ByteArrayOutputStream mOutput; + + public ServletOutputStreamWrapper() + { + mOutput = new ByteArrayOutputStream(); + } + + public void write(int b) throws IOException + { + mOutput.write(b); + } + + public byte[] toByteArray() + { + return mOutput.toByteArray(); + } + } +} diff --git a/src/main/java/com/uwyn/jhighlight/tools/ExceptionUtils.java b/src/main/java/com/uwyn/jhighlight/tools/ExceptionUtils.java new file mode 100644 index 0000000..df4aefd --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/tools/ExceptionUtils.java @@ -0,0 +1,61 @@ +/* + * Copyright 2001-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: ExceptionUtils.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.tools; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Collection of utility methods to work with exceptions. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public abstract class ExceptionUtils +{ + private ExceptionUtils() + { + } + + /** + * Obtains the entire stracktrace of an exception and converts it into a + * string. + * + * @param exception the exception whose stacktrace has to be converted + * @return the stracktrace, converted into a string + * @since 1.0 + */ + public static String getExceptionStackTrace(Throwable exception) + { + if (null == exception) throw new IllegalArgumentException("exception can't be null;"); + + String stack_trace = null; + + StringWriter string_writer = new StringWriter(); + PrintWriter print_writer = new PrintWriter(string_writer); + + exception.printStackTrace(print_writer); + + stack_trace = string_writer.getBuffer().toString(); + + print_writer.close(); + + try + { + string_writer.close(); + } + // JDK 1.2.2 compatibility + catch (Throwable e2) + { + } + + return stack_trace; + } +} + diff --git a/src/main/java/com/uwyn/jhighlight/tools/FileUtils.java b/src/main/java/com/uwyn/jhighlight/tools/FileUtils.java new file mode 100644 index 0000000..7dd9883 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/tools/FileUtils.java @@ -0,0 +1,141 @@ +/* + * Copyright 2001-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: FileUtils.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.tools; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.regex.Pattern; + +/** + * Collection of utility methods to work with files. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public abstract class FileUtils +{ + private FileUtils() + { + } + + /** + * Recursively traverse a directory hierachy and obtain a list of all + * absolute file names. + *

Regular expression patterns can be provided to explicitly include + * and exclude certain file names. + * + * @param file the directory whose file hierarchy will be traversed + * @param included an array of regular expression patterns that will be + * used to determine which files should be included; or + *

null if all files should be included + * @param excluded an array of regular expression patterns that will be + * used to determine which files should be excluded; or + *

null if no files should be excluded + * @return the list of absolute file names + * @since 1.0 + */ + public static ArrayList getFileList(File file, Pattern[] included, Pattern[] excluded) + { + return getFileList(file, included, excluded, true); + } + + private static ArrayList getFileList(File file, Pattern[] included, Pattern[] excluded, boolean root) + { + if (null == file) + { + return new ArrayList(); + } + + ArrayList filelist = new ArrayList(); + if (file.isDirectory()) + { + String[] list = file.list(); + if (null != list) + { + String list_entry; + for (int i = 0; i < list.length; i++) + { + list_entry = list[i]; + + File next_file = new File(file.getAbsolutePath() + File.separator + list_entry); + ArrayList dir = getFileList(next_file, included, excluded, false); + + Iterator dir_it = dir.iterator(); + String file_name; + while (dir_it.hasNext()) + { + file_name = (String)dir_it.next(); + + if (root) + { + // if the file is not accepted, don't process it further + if (!StringUtils.filter(file_name, included, excluded)) + { + continue; + } + + } + else + { + file_name = file.getName() + File.separator + file_name; + } + + int filelist_size = filelist.size(); + for (int j = 0; j < filelist_size; j++) + { + if (((String)filelist.get(j)).compareTo(file_name) > 0) + { + filelist.add(j, file_name); + break; + } + } + if (filelist.size() == filelist_size) + { + filelist.add(file_name); + } + } + } + } + } + else if (file.isFile()) + { + String file_name = file.getName(); + + if (root) + { + if (StringUtils.filter(file_name, included, excluded)) + { + filelist.add(file_name); + } + } + else + { + filelist.add(file_name); + } + } + + return filelist; + } + + public static String getExtension(String fileName) + { + if (null == fileName) throw new IllegalArgumentException("fileName can't be null."); + + String ext = null; + + int index = fileName.lastIndexOf('.'); + if (index > 0 && index < fileName.length() - 1) + { + ext = fileName.substring(index+1).toLowerCase(); + } + + return ext; + } +} diff --git a/src/main/java/com/uwyn/jhighlight/tools/StringUtils.java b/src/main/java/com/uwyn/jhighlight/tools/StringUtils.java new file mode 100644 index 0000000..ee197f5 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/tools/StringUtils.java @@ -0,0 +1,706 @@ +/* + * Copyright 2001-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: StringUtils.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.tools; + +import com.uwyn.jhighlight.pcj.map.CharKeyOpenHashMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.regex.Pattern; + +/** + * General purpose class containing common String manipulation + * methods. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public abstract class StringUtils +{ + private static final CharKeyOpenHashMap mHtmlEncodeMap = new CharKeyOpenHashMap(); + + static + { + // Html encoding mapping according to the HTML 4.0 spec + // http://www.w3.org/TR/REC-html40/sgml/entities.html + + // Special characters for HTML + mHtmlEncodeMap.put('\u0026', "&"); + mHtmlEncodeMap.put('\u003C', "<"); + mHtmlEncodeMap.put('\u003E', ">"); + mHtmlEncodeMap.put('\u0022', """); + + mHtmlEncodeMap.put('\u0152', "Œ"); + mHtmlEncodeMap.put('\u0153', "œ"); + mHtmlEncodeMap.put('\u0160', "Š"); + mHtmlEncodeMap.put('\u0161', "š"); + mHtmlEncodeMap.put('\u0178', "Ÿ"); + mHtmlEncodeMap.put('\u02C6', "ˆ"); + mHtmlEncodeMap.put('\u02DC', "˜"); + mHtmlEncodeMap.put('\u2002', " "); + mHtmlEncodeMap.put('\u2003', " "); + mHtmlEncodeMap.put('\u2009', " "); + mHtmlEncodeMap.put('\u200C', "‌"); + mHtmlEncodeMap.put('\u200D', "‍"); + mHtmlEncodeMap.put('\u200E', "‎"); + mHtmlEncodeMap.put('\u200F', "‏"); + mHtmlEncodeMap.put('\u2013', "–"); + mHtmlEncodeMap.put('\u2014', "—"); + mHtmlEncodeMap.put('\u2018', "‘"); + mHtmlEncodeMap.put('\u2019', "’"); + mHtmlEncodeMap.put('\u201A', "‚"); + mHtmlEncodeMap.put('\u201C', "“"); + mHtmlEncodeMap.put('\u201D', "”"); + mHtmlEncodeMap.put('\u201E', "„"); + mHtmlEncodeMap.put('\u2020', "†"); + mHtmlEncodeMap.put('\u2021', "‡"); + mHtmlEncodeMap.put('\u2030', "‰"); + mHtmlEncodeMap.put('\u2039', "‹"); + mHtmlEncodeMap.put('\u203A', "›"); + mHtmlEncodeMap.put('\u20AC', "€"); + + // Character entity references for ISO 8859-1 characters + mHtmlEncodeMap.put('\u00A0', " "); + mHtmlEncodeMap.put('\u00A1', "¡"); + mHtmlEncodeMap.put('\u00A2', "¢"); + mHtmlEncodeMap.put('\u00A3', "£"); + mHtmlEncodeMap.put('\u00A4', "¤"); + mHtmlEncodeMap.put('\u00A5', "¥"); + mHtmlEncodeMap.put('\u00A6', "¦"); + mHtmlEncodeMap.put('\u00A7', "§"); + mHtmlEncodeMap.put('\u00A8', "¨"); + mHtmlEncodeMap.put('\u00A9', "©"); + mHtmlEncodeMap.put('\u00AA', "ª"); + mHtmlEncodeMap.put('\u00AB', "«"); + mHtmlEncodeMap.put('\u00AC', "¬"); + mHtmlEncodeMap.put('\u00AD', "­"); + mHtmlEncodeMap.put('\u00AE', "®"); + mHtmlEncodeMap.put('\u00AF', "¯"); + mHtmlEncodeMap.put('\u00B0', "°"); + mHtmlEncodeMap.put('\u00B1', "±"); + mHtmlEncodeMap.put('\u00B2', "²"); + mHtmlEncodeMap.put('\u00B3', "³"); + mHtmlEncodeMap.put('\u00B4', "´"); + mHtmlEncodeMap.put('\u00B5', "µ"); + mHtmlEncodeMap.put('\u00B6', "¶"); + mHtmlEncodeMap.put('\u00B7', "·"); + mHtmlEncodeMap.put('\u00B8', "¸"); + mHtmlEncodeMap.put('\u00B9', "¹"); + mHtmlEncodeMap.put('\u00BA', "º"); + mHtmlEncodeMap.put('\u00BB', "»"); + mHtmlEncodeMap.put('\u00BC', "¼"); + mHtmlEncodeMap.put('\u00BD', "½"); + mHtmlEncodeMap.put('\u00BE', "¾"); + mHtmlEncodeMap.put('\u00BF', "¿"); + mHtmlEncodeMap.put('\u00C0', "À"); + mHtmlEncodeMap.put('\u00C1', "Á"); + mHtmlEncodeMap.put('\u00C2', "Â"); + mHtmlEncodeMap.put('\u00C3', "Ã"); + mHtmlEncodeMap.put('\u00C4', "Ä"); + mHtmlEncodeMap.put('\u00C5', "Å"); + mHtmlEncodeMap.put('\u00C6', "Æ"); + mHtmlEncodeMap.put('\u00C7', "Ç"); + mHtmlEncodeMap.put('\u00C8', "È"); + mHtmlEncodeMap.put('\u00C9', "É"); + mHtmlEncodeMap.put('\u00CA', "Ê"); + mHtmlEncodeMap.put('\u00CB', "Ë"); + mHtmlEncodeMap.put('\u00CC', "Ì"); + mHtmlEncodeMap.put('\u00CD', "Í"); + mHtmlEncodeMap.put('\u00CE', "Î"); + mHtmlEncodeMap.put('\u00CF', "Ï"); + mHtmlEncodeMap.put('\u00D0', "Ð"); + mHtmlEncodeMap.put('\u00D1', "Ñ"); + mHtmlEncodeMap.put('\u00D2', "Ò"); + mHtmlEncodeMap.put('\u00D3', "Ó"); + mHtmlEncodeMap.put('\u00D4', "Ô"); + mHtmlEncodeMap.put('\u00D5', "Õ"); + mHtmlEncodeMap.put('\u00D6', "Ö"); + mHtmlEncodeMap.put('\u00D7', "×"); + mHtmlEncodeMap.put('\u00D8', "Ø"); + mHtmlEncodeMap.put('\u00D9', "Ù"); + mHtmlEncodeMap.put('\u00DA', "Ú"); + mHtmlEncodeMap.put('\u00DB', "Û"); + mHtmlEncodeMap.put('\u00DC', "Ü"); + mHtmlEncodeMap.put('\u00DD', "Ý"); + mHtmlEncodeMap.put('\u00DE', "Þ"); + mHtmlEncodeMap.put('\u00DF', "ß"); + mHtmlEncodeMap.put('\u00E0', "à"); + mHtmlEncodeMap.put('\u00E1', "á"); + mHtmlEncodeMap.put('\u00E2', "â"); + mHtmlEncodeMap.put('\u00E3', "ã"); + mHtmlEncodeMap.put('\u00E4', "ä"); + mHtmlEncodeMap.put('\u00E5', "å"); + mHtmlEncodeMap.put('\u00E6', "æ"); + mHtmlEncodeMap.put('\u00E7', "ç"); + mHtmlEncodeMap.put('\u00E8', "è"); + mHtmlEncodeMap.put('\u00E9', "é"); + mHtmlEncodeMap.put('\u00EA', "ê"); + mHtmlEncodeMap.put('\u00EB', "ë"); + mHtmlEncodeMap.put('\u00EC', "ì"); + mHtmlEncodeMap.put('\u00ED', "í"); + mHtmlEncodeMap.put('\u00EE', "î"); + mHtmlEncodeMap.put('\u00EF', "ï"); + mHtmlEncodeMap.put('\u00F0', "ð"); + mHtmlEncodeMap.put('\u00F1', "ñ"); + mHtmlEncodeMap.put('\u00F2', "ò"); + mHtmlEncodeMap.put('\u00F3', "ó"); + mHtmlEncodeMap.put('\u00F4', "ô"); + mHtmlEncodeMap.put('\u00F5', "õ"); + mHtmlEncodeMap.put('\u00F6', "ö"); + mHtmlEncodeMap.put('\u00F7', "÷"); + mHtmlEncodeMap.put('\u00F8', "ø"); + mHtmlEncodeMap.put('\u00F9', "ù"); + mHtmlEncodeMap.put('\u00FA', "ú"); + mHtmlEncodeMap.put('\u00FB', "û"); + mHtmlEncodeMap.put('\u00FC', "ü"); + mHtmlEncodeMap.put('\u00FD', "ý"); + mHtmlEncodeMap.put('\u00FE', "þ"); + mHtmlEncodeMap.put('\u00FF', "ÿ"); + + // Mathematical, Greek and Symbolic characters for HTML + mHtmlEncodeMap.put('\u0192', "ƒ"); + mHtmlEncodeMap.put('\u0391', "Α"); + mHtmlEncodeMap.put('\u0392', "Β"); + mHtmlEncodeMap.put('\u0393', "Γ"); + mHtmlEncodeMap.put('\u0394', "Δ"); + mHtmlEncodeMap.put('\u0395', "Ε"); + mHtmlEncodeMap.put('\u0396', "Ζ"); + mHtmlEncodeMap.put('\u0397', "Η"); + mHtmlEncodeMap.put('\u0398', "Θ"); + mHtmlEncodeMap.put('\u0399', "Ι"); + mHtmlEncodeMap.put('\u039A', "Κ"); + mHtmlEncodeMap.put('\u039B', "Λ"); + mHtmlEncodeMap.put('\u039C', "Μ"); + mHtmlEncodeMap.put('\u039D', "Ν"); + mHtmlEncodeMap.put('\u039E', "Ξ"); + mHtmlEncodeMap.put('\u039F', "Ο"); + mHtmlEncodeMap.put('\u03A0', "Π"); + mHtmlEncodeMap.put('\u03A1', "Ρ"); + mHtmlEncodeMap.put('\u03A3', "Σ"); + mHtmlEncodeMap.put('\u03A4', "Τ"); + mHtmlEncodeMap.put('\u03A5', "Υ"); + mHtmlEncodeMap.put('\u03A6', "Φ"); + mHtmlEncodeMap.put('\u03A7', "Χ"); + mHtmlEncodeMap.put('\u03A8', "Ψ"); + mHtmlEncodeMap.put('\u03A9', "Ω"); + mHtmlEncodeMap.put('\u03B1', "α"); + mHtmlEncodeMap.put('\u03B2', "β"); + mHtmlEncodeMap.put('\u03B3', "γ"); + mHtmlEncodeMap.put('\u03B4', "δ"); + mHtmlEncodeMap.put('\u03B5', "ε"); + mHtmlEncodeMap.put('\u03B6', "ζ"); + mHtmlEncodeMap.put('\u03B7', "η"); + mHtmlEncodeMap.put('\u03B8', "θ"); + mHtmlEncodeMap.put('\u03B9', "ι"); + mHtmlEncodeMap.put('\u03BA', "κ"); + mHtmlEncodeMap.put('\u03BB', "λ"); + mHtmlEncodeMap.put('\u03BC', "μ"); + mHtmlEncodeMap.put('\u03BD', "ν"); + mHtmlEncodeMap.put('\u03BE', "ξ"); + mHtmlEncodeMap.put('\u03BF', "ο"); + mHtmlEncodeMap.put('\u03C0', "π"); + mHtmlEncodeMap.put('\u03C1', "ρ"); + mHtmlEncodeMap.put('\u03C2', "ς"); + mHtmlEncodeMap.put('\u03C3', "σ"); + mHtmlEncodeMap.put('\u03C4', "τ"); + mHtmlEncodeMap.put('\u03C5', "υ"); + mHtmlEncodeMap.put('\u03C6', "φ"); + mHtmlEncodeMap.put('\u03C7', "χ"); + mHtmlEncodeMap.put('\u03C8', "ψ"); + mHtmlEncodeMap.put('\u03C9', "ω"); + mHtmlEncodeMap.put('\u03D1', "ϑ"); + mHtmlEncodeMap.put('\u03D2', "ϒ"); + mHtmlEncodeMap.put('\u03D6', "ϖ"); + mHtmlEncodeMap.put('\u2022', "•"); + mHtmlEncodeMap.put('\u2026', "…"); + mHtmlEncodeMap.put('\u2032', "′"); + mHtmlEncodeMap.put('\u2033', "″"); + mHtmlEncodeMap.put('\u203E', "‾"); + mHtmlEncodeMap.put('\u2044', "⁄"); + mHtmlEncodeMap.put('\u2118', "℘"); + mHtmlEncodeMap.put('\u2111', "ℑ"); + mHtmlEncodeMap.put('\u211C', "ℜ"); + mHtmlEncodeMap.put('\u2122', "™"); + mHtmlEncodeMap.put('\u2135', "ℵ"); + mHtmlEncodeMap.put('\u2190', "←"); + mHtmlEncodeMap.put('\u2191', "↑"); + mHtmlEncodeMap.put('\u2192', "→"); + mHtmlEncodeMap.put('\u2193', "↓"); + mHtmlEncodeMap.put('\u2194', "↔"); + mHtmlEncodeMap.put('\u21B5', "↵"); + mHtmlEncodeMap.put('\u21D0', "⇐"); + mHtmlEncodeMap.put('\u21D1', "⇑"); + mHtmlEncodeMap.put('\u21D2', "⇒"); + mHtmlEncodeMap.put('\u21D3', "⇓"); + mHtmlEncodeMap.put('\u21D4', "⇔"); + mHtmlEncodeMap.put('\u2200', "∀"); + mHtmlEncodeMap.put('\u2202', "∂"); + mHtmlEncodeMap.put('\u2203', "∃"); + mHtmlEncodeMap.put('\u2205', "∅"); + mHtmlEncodeMap.put('\u2207', "∇"); + mHtmlEncodeMap.put('\u2208', "∈"); + mHtmlEncodeMap.put('\u2209', "∉"); + mHtmlEncodeMap.put('\u220B', "∋"); + mHtmlEncodeMap.put('\u220F', "∏"); + mHtmlEncodeMap.put('\u2211', "∑"); + mHtmlEncodeMap.put('\u2212', "−"); + mHtmlEncodeMap.put('\u2217', "∗"); + mHtmlEncodeMap.put('\u221A', "√"); + mHtmlEncodeMap.put('\u221D', "∝"); + mHtmlEncodeMap.put('\u221E', "∞"); + mHtmlEncodeMap.put('\u2220', "∠"); + mHtmlEncodeMap.put('\u2227', "∧"); + mHtmlEncodeMap.put('\u2228', "∨"); + mHtmlEncodeMap.put('\u2229', "∩"); + mHtmlEncodeMap.put('\u222A', "∪"); + mHtmlEncodeMap.put('\u222B', "∫"); + mHtmlEncodeMap.put('\u2234', "∴"); + mHtmlEncodeMap.put('\u223C', "∼"); + mHtmlEncodeMap.put('\u2245', "≅"); + mHtmlEncodeMap.put('\u2248', "≈"); + mHtmlEncodeMap.put('\u2260', "≠"); + mHtmlEncodeMap.put('\u2261', "≡"); + mHtmlEncodeMap.put('\u2264', "≤"); + mHtmlEncodeMap.put('\u2265', "≥"); + mHtmlEncodeMap.put('\u2282', "⊂"); + mHtmlEncodeMap.put('\u2283', "⊃"); + mHtmlEncodeMap.put('\u2284', "⊄"); + mHtmlEncodeMap.put('\u2286', "⊆"); + mHtmlEncodeMap.put('\u2287', "⊇"); + mHtmlEncodeMap.put('\u2295', "⊕"); + mHtmlEncodeMap.put('\u2297', "⊗"); + mHtmlEncodeMap.put('\u22A5', "⊥"); + mHtmlEncodeMap.put('\u22C5', "⋅"); + mHtmlEncodeMap.put('\u2308', "⌈"); + mHtmlEncodeMap.put('\u2309', "⌉"); + mHtmlEncodeMap.put('\u230A', "⌊"); + mHtmlEncodeMap.put('\u230B', "⌋"); + mHtmlEncodeMap.put('\u2329', "⟨"); + mHtmlEncodeMap.put('\u232A', "⟩"); + mHtmlEncodeMap.put('\u25CA', "◊"); + mHtmlEncodeMap.put('\u2660', "♠"); + mHtmlEncodeMap.put('\u2663', "♣"); + mHtmlEncodeMap.put('\u2665', "♥"); + mHtmlEncodeMap.put('\u2666', "♦"); + } + + private StringUtils() + { + } + + /** + * Transforms a provided String object into a new string, + * containing only valid Html characters. + * + * @param source The string that has to be transformed into a valid Html + * string. + * + * @return The encoded String object. + * + * @since 1.0 + */ + public static String encodeHtml(String source) + { + return encode(source, mHtmlEncodeMap); + } + + /** + * Transforms a provided String object into a new string, + * using the mapping that are provided through the supplied encoding table. + * + * @param source The string that has to be transformed into a valid string, + * using the mappings that are provided through the supplied encoding table. + * @param encodingTables A Map object containing the mappings to + * transform characters into valid entities. The keys of this map should be + * Character objects and the values String + * objects. + * + * @return The encoded String object. + * + * @since 1.0 + */ + private static String encode(String source, CharKeyOpenHashMap encodingTable) + { + if (null == source) + { + return null; + } + + if (null == encodingTable) + { + return source; + } + + StringBuffer encoded_string = null; + char[] string_to_encode_array = source.toCharArray(); + int last_match = -1; + int difference = 0; + + for (int i = 0; i < string_to_encode_array.length; i++) + { + char char_to_encode = string_to_encode_array[i]; + + if (encodingTable.containsKey(char_to_encode)) + { + if (null == encoded_string) + { + encoded_string = new StringBuffer(source.length()); + } + difference = i - (last_match + 1); + if (difference > 0) + { + encoded_string.append(string_to_encode_array, last_match + 1, difference); + } + encoded_string.append(encodingTable.get(char_to_encode)); + last_match = i; + } + } + + if (null == encoded_string) + { + return source; + } + else + { + difference = string_to_encode_array.length - (last_match + 1); + if (difference > 0) + { + encoded_string.append(string_to_encode_array, last_match + 1, difference); + } + return encoded_string.toString(); + } + } + + /** + * Checks if the name filters through an including and an excluding + * regular expression. + * + * @param name The String that will be filtered. + * @param included The regular expressions that needs to succeed + * @param excluded The regular expressions that needs to fail + * + * @return true if the name filtered through correctly; or + *

+ * false otherwise. + * + * @since 1.0 + */ + public static boolean filter(String name, Pattern included, Pattern excluded) + { + Pattern[] included_array = null; + if (included != null) + { + included_array = new Pattern[] {included}; + } + + Pattern[] excluded_array = null; + if (excluded != null) + { + excluded_array = new Pattern[] {excluded}; + } + + return filter(name, included_array, excluded_array); + } + + /** + * Checks if the name filters through a series of including and excluding + * regular expressions. + * + * @param name The String that will be filtered. + * @param included An array of regular expressions that need to succeed + * @param excluded An array of regular expressions that need to fail + * + * @return true if the name filtered through correctly; or + *

+ * false otherwise. + * + * @since 1.0 + */ + public static boolean filter(String name, Pattern[] included, Pattern[] excluded) + { + if (null == name) + { + return false; + } + + boolean accepted = false; + + // retain only the includes + if (null == included) + { + accepted = true; + } + else + { + Pattern pattern; + for (int i = 0; i < included.length; i++) + { + pattern = included[i]; + + if (pattern != null && + pattern.matcher(name).matches()) + { + accepted = true; + break; + } + } + } + + // remove the excludes + if (accepted && + excluded != null) + { + Pattern pattern; + for (int i = 0; i < excluded.length; i++) + { + pattern = excluded[i]; + + if (pattern != null && + pattern.matcher(name).matches()) + { + accepted = false; + break; + } + } + } + + return accepted; + } + + /** + * Splits a string into different parts, using a seperator string to detect + * the seperation boundaries in a case-sensitive manner. The seperator will + * not be included in the list of parts. + * + * @param source The string that will be split into parts. + * @param seperator The seperator string that will be used to determine the + * parts. + * + * @return An ArrayList containing the parts as + * String objects. + * + * @since 1.0 + */ + public static ArrayList split(String source, String seperator) + { + return split(source, seperator, true); + } + + /** + * Splits a string into different parts, using a seperator string to detect + * the seperation boundaries. The seperator will not be included in the list + * of parts. + * + * @param source The string that will be split into parts. + * @param seperator The seperator string that will be used to determine the + * parts. + * @param matchCase A boolean indicating if the match is going + * to be performed in a case-sensitive manner or not. + * + * @return An ArrayList containing the parts as + * String objects. + * + * @since 1.0 + */ + public static ArrayList split(String source, String seperator, boolean matchCase) + { + ArrayList substrings = new ArrayList(); + + if (null == source) + { + return substrings; + } + + if (null == seperator) + { + substrings.add(source); + return substrings; + } + + int current_index = 0; + int delimiter_index = 0; + String element = null; + + String source_lookup_reference = null; + if (!matchCase) + { + source_lookup_reference = source.toLowerCase(); + seperator = seperator.toLowerCase(); + } + else + { + source_lookup_reference = source; + } + + while (current_index <= source_lookup_reference.length()) + { + delimiter_index = source_lookup_reference.indexOf(seperator, current_index); + + if (-1 == delimiter_index) + { + element = new String(source.substring(current_index, source.length())); + substrings.add(element); + current_index = source.length() + 1; + } + else + { + element = new String(source.substring(current_index, delimiter_index)); + substrings.add(element); + current_index = delimiter_index + seperator.length(); + } + } + + return substrings; + } + + /** + * Searches for a string within a specified string in a case-sensitive + * manner and replaces every match with another string. + * + * @param source The string in which the matching parts will be replaced. + * @param stringToReplace The string that will be searched for. + * @param replacementString The string that will replace each matching part. + * + * @return A new String object containing the replacement + * result. + * + * @since 1.0 + */ + public static String replace(String source, String stringToReplace, String replacementString) + { + return replace(source, stringToReplace, replacementString, true); + } + + /** + * Searches for a string within a specified string and replaces every match + * with another string. + * + * @param source The string in which the matching parts will be replaced. + * @param stringToReplace The string that will be searched for. + * @param replacementString The string that will replace each matching part. + * @param matchCase A boolean indicating if the match is going + * to be performed in a case-sensitive manner or not. + * + * @return A new String object containing the replacement + * result. + * + * @since 1.0 + */ + public static String replace(String source, String stringToReplace, String replacementString, boolean matchCase) + { + if (null == source) + { + return null; + } + + if (null == stringToReplace) + { + return source; + } + + if (null == replacementString) + { + return source; + } + + Iterator string_parts = split(source, stringToReplace, matchCase).iterator(); + StringBuffer new_string = new StringBuffer(); + + synchronized (new_string) // speed increase by thread lock pre-allocation + { + while (string_parts.hasNext()) + { + String string_part = (String)string_parts.next(); + new_string.append(string_part); + if (string_parts.hasNext()) + { + new_string.append(replacementString); + } + } + + return new_string.toString(); + } + } + + /** + * Creates a new string that contains the provided string a number of times. + * + * @param source The string that will be repeated. + * @param count The number of times that the string will be repeated. + * @return A new String object containing the repeated + * concatenation result. + * + * @since 1.0 + */ + public static String repeat(String source, int count) + { + if (null == source) + { + return null; + } + + StringBuffer new_string = new StringBuffer(); + synchronized (new_string) // speed increase by thread lock pre-allocation + { + while (count > 0) + { + new_string.append(source); + count --; + } + + return new_string.toString(); + } + } + + /** + * Converts all tabs on a line to spaces according to the provided tab + * width. + * + * @param line The line whose tabs have to be converted. + * @param tabWidth The tab width. + * @return A new String object containing the line with the + * replaced tabs. + * @since 1.0 + */ + public static String convertTabsToSpaces(String line, int tabWidth) + { + StringBuffer result = new StringBuffer(); + + synchronized (result) // speed increase by thread lock pre-allocation + { + int tab_index = -1; + int last_tab_index = 0; + int added_chars = 0; + int tab_size; + while ((tab_index = line.indexOf("\t", last_tab_index)) != -1) + { + tab_size = tabWidth - ((tab_index + added_chars) % tabWidth); + if (0 == tab_size) + { + tab_size = tabWidth; + } + added_chars += tab_size - 1; + result.append(line.substring(last_tab_index, tab_index)); + result.append(StringUtils.repeat(" ", tab_size)); + last_tab_index = tab_index + 1; + } + if (0 == last_tab_index) + { + return line; + } + else + { + result.append(line.substring(last_tab_index)); + } + } + + return result.toString(); + } +} + + diff --git a/src/main/java/com/uwyn/jhighlight/tools/exceptions/FileUtilsErrorException.java b/src/main/java/com/uwyn/jhighlight/tools/exceptions/FileUtilsErrorException.java new file mode 100644 index 0000000..f555f90 --- /dev/null +++ b/src/main/java/com/uwyn/jhighlight/tools/exceptions/FileUtilsErrorException.java @@ -0,0 +1,29 @@ +/* + * Copyright 2001-2006 Geert Bevin + * Distributed under the terms of either: + * - the common development and distribution license (CDDL), v1.0; or + * - the GNU Lesser General Public License, v2.1 or later + * $Id: FileUtilsErrorException.java 3108 2006-03-13 18:03:00Z gbevin $ + */ +package com.uwyn.jhighlight.tools.exceptions; + +/** + * Exception that will be trigger when unexpected errors occur during the + * functionalities of the {@link com.uwyn.jhighlight.tools.FileUtils} class. + * + * @author Geert Bevin (gbevin[remove] at uwyn dot com) + * @version $Revision: 3108 $ + * @since 1.0 + */ +public class FileUtilsErrorException extends Exception +{ + public FileUtilsErrorException(String message) + { + super(message); + } + + public FileUtilsErrorException(String message, Throwable cause) + { + super(message, cause); + } +} diff --git a/src/main/resources/JHIGHLIGHT_VERSION b/src/main/resources/JHIGHLIGHT_VERSION new file mode 100644 index 0000000..d3827e7 --- /dev/null +++ b/src/main/resources/JHIGHLIGHT_VERSION @@ -0,0 +1 @@ +1.0 diff --git a/src/main/resources/jhighlight.properties b/src/main/resources/jhighlight.properties new file mode 100644 index 0000000..11f8384 --- /dev/null +++ b/src/main/resources/jhighlight.properties @@ -0,0 +1,154 @@ +h1 = \ +\ + font-family: sans-serif; \ + font-size: 16pt; \ + font-weight: bold; \ + color: rgb(0,0,0); \ + background: rgb(210,210,210); \ + border: solid 1px black; \ + padding: 5px; \ + text-align: center; + +code = \ +\ + color: rgb(0,0,0); \ + font-family: monospace; \ + font-size: 12px; \ + white-space: nowrap; + +.java_plain = \ +\ + color: rgb(0,0,0); + +.java_keyword = \ +\ + color: rgb(0,0,0); \ + font-weight: bold; + +.java_type = \ +\ + color: rgb(0,44,221); + +.java_operator = \ +\ + color: rgb(0,124,31); + +.java_separator = \ +\ + color: rgb(0,33,255); + +.java_literal = \ +\ + color: rgb(188,0,0); + +.java_comment = \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); + +.java_javadoc_comment = \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); \ + font-style: italic; + +.java_javadoc_tag = \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); \ + font-style: italic; \ + font-weight: bold; + +.xml_plain = \ +\ + color: rgb(0,0,0); + +.xml_char_data = \ +\ + color: rgb(0,0,0); + +.xml_tag_symbols = \ +\ + color: rgb(0,59,255); + +.xml_comment = \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); + +.xml_attribute_value = \ +\ + color: rgb(193,0,0); + +.xml_attribute_name = \ +\ + color: rgb(0,0,0); \ + font-weight: bold; + +.xml_processing_instruction = \ +\ + color: rgb(0,0,0); \ + font-weight: bold; \ + font-style: italic; + +.xml_tag_name = \ +\ + color: rgb(0,55,255); + +.xml_rife_tag = \ +\ + color: rgb(0,0,0); \ + background-color: rgb(228,230,160); + +.xml_rife_name = \ +\ + color: rgb(0,0,196); \ + background-color: rgb(228,230,160); + +.cpp_plain \ +\ + color: rgb(0,0,0); + +.cpp_keyword \ +\ + color: rgb(0,0,0); \ + font-weight: bold; + +.cpp_type \ +\ + color: rgb(0,44,221); + +.cpp_operator \ +\ + color: rgb(0,124,31); + +.cpp_separator \ +\ + color: rgb(0,33,255); + +.cpp_literal \ +\ + color: rgb(188,0,0); + +.cpp_comment \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); + +.cpp_doxygen_comment \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); \ + font-style: italic; + +.cpp_doxygen_tag \ +\ + color: rgb(147,147,147); \ + background-color: rgb(247,247,247); \ + font-style: italic; \ + font-weight: bold; + +.cpp_preproc \ +\ + color: purple; +