/* * 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 * * tweaked by jason davis - mohadib@openactive.org * * $Id$ */ package swingutils.text.lexers; import java.util.HashMap; import java.util.Map; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import swingutils.text.lexers.Lexer; import java.awt.Color; %% %class XMLLexer %implements Lexer %unicode %pack %char %buffer 128 %public %int %{ /* styles */ public static final int TAG_STYLE = 2; public static final int SGML_STYLE = 3; public static final int OPERATOR_STYLE = 4; public static final int SEPARATOR_STYLE = 5; public static final int LITERAL_STYLE = 6; public static final int COMMENT_STYLE = 7; public int yychar() { return yychar; } public JavaLexer() { } %} StringLiteral=(([\"][^\"]*[\"])|([\'][^\']*[\'])) SGMLProcessingStart=("") SGMLProcessingText=(([^\?]|[\?]+[^\>\?])*) SGMLProcessing=({SGMLProcessingStart}{SGMLProcessingText}{SGMLProcessingEnd}) Digit=([0-9]) Letter=([a-zA-Z]) BLANK=([ ]) TAB=([\t]) FF=([\f]) CR=([\r]) LF=([\n]) EOL=({CR}|{LF}|{CR}{LF}) WhiteSpace=({BLANK}|{TAB}|{FF}|{EOL}|" ") TagStart=("<") EndTagStart=("") Doctype=([Dd][Oo][Cc][Tt][Yy][Pp][Ee]) DoctypeText=(([^\>\"\']|{StringLiteral})*) Word=(([^\ \r\n\f\t\<])*)|(({Word}|{WhiteSpace})+) Comment=("--"([^\-]|([\-][^\-]))*"--") CommentDeclaration=({DocTagStart}((({WhiteSpace}*){Comment}({WhiteSpace}*))*){TagEnd}) %% { /* separators */ "(" | ")" | "[" | "]" | "." { return SEPARATOR_STYLE; } } {CommentDeclaration}{ return COMMENT_STYLE; } {Comment}{ return COMMENT_STYLE; } {TagStart|TagEnd}{ return TAG_STYLE; } {StringLiteral} { return PLAIN_STYLE; } {SGMLProcessingStart|SGMLProcessingEnd|SGMLProcessingText}{ return SGML_STYLE; }