libjsyntaxpane-java-0.9.6~r156/ 0000755 0001750 0001750 00000000000 12127321547 017202 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/nbactions.xml 0000644 0001750 0001750 00000003302 12127321547 021702 0 ustar sylvestre sylvestre
run
process-classes
org.codehaus.mojo:exec-maven-plugin:1.1:exec
-classpath %classpath jsyntaxpane.SyntaxTester
java
debug
process-classes
org.codehaus.mojo:exec-maven-plugin:1.1:exec
-Xdebug -Djava.compiler=none -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath jsyntaxpane.SyntaxTester
true
java
profile
jar
process-classes
org.codehaus.mojo:exec-maven-plugin:1.1:exec
${profiler.args} -classpath %classpath jsyntaxpane.SyntaxTester
profile
${profiler.java}
libjsyntaxpane-java-0.9.6~r156/CHANGELOG.txt 0000644 0001750 0001750 00000011440 12127321547 021232 0 ustar sylvestre sylvestre Version 0.9.5 - Java Reflection Completions additions
* Configuration class overhaul. Each kit now has its own COnfiguration file
which merges the superclass(es) Configurations.
* Usable Reflect Completions Dialog (Java with F1 or Menu)
* Java ENTER key responds properly to multi line comments
* Font can be changed for each Kit
* Kits for XHTML and Xpath added. XHTML has a simple Preview Action.
* Added Execute Script to JacaScript (can also be used for Groovy if Groovy
Scripting support is installed properly).
* Hotkeys for actions are displayed in Popup Menus
* Word Completion action can also do CamelCase matches
* Smart Home Action (and Smart Home Extend Selection)
* Enhanced JavaScript support. Issue 115
* Better Undo grouping
* Replace DIalog ENhancement. Only for updatedable editors and added single replace.
* Added append method to SyntaxDocument
* Fixed Issue 130 - Compound Undo on multiple lines.
Version 0.9.4 - IntelliSense additions
* Adding IntelliSense to Java with simple List of selectable keywords
* Added Toggle Comment Actions using Control SLASH
* Fixed Issue 47.
* Added Clojure, Scala, DOS Batch and 'nix bash support
* Added Configurable Popup menus with default Tango Desktop icons
* Added configurable format for the CaretMonitor class
* Toggle Comments Action selects the lines affected after being performed
* Added multi-line support in ActionUtils.insertMagicSTring method.
* GotoLine dialog responds to ESC key
Version 0.9.3 - Start of scripts for the document:
* Added new methods getLine() to SyntaxDocument
* SyntaxDocument getIndexOf methods deprecated, use getMatchers instead
* Added Line Numbering to Java
* Added CaretMonitor Class
* Merged Find And Replace dialogs into one.
* Created SyntaxComponent interface and have all UI components implement
that interface. DefaultSyntaxKit will use config.properties class to
dynamically install these components.
* Added Right Margin option and Single Color Selection Options
* Added Python, C and C++ Support
* Added Ruby Syntax Support
* Fixed Issue 37 (NPE for LineNumbersRuler)
* Fixed Issue 39 (Highlighting Tokens overrides selection highlights)
* Fixed some JavaDoc comments.
* Fixed Line Numbers being displayed for the height of the editor and now
just for the actual available lines.
* Fixed Margin typo in all project. Issue 43
* Changing Actions to be more configurable:
* SyntaxActions renamed to ActionUtils
* Removed all inner classes from SyntaxActions
* Will create new SyntaxAction interface that will allow dynamic addition
actions (in the addKeyActions of DefaultSyntaxKit
* Added Text AA property to SyntaxView
Version 0.9.2:
* Fixing Java Indentation and Un-Indentattion Actions
* Added and used (in the Tester) clearUndoes on the SyntaxDocument
* Added Basic JFlex Syntax
* Added getContentTypes to DefaultSyntaxKit to get all registered
ContentTypes. This is now also used in the SyntaxTester instead of
hardcoding the types.
* Cleanup and optimization of Lexers by removing duplicate Java Code
(replaced with Regex OR)
* Removed calls to deprecated calls in SyntaxView
* Modified the SyntaxDOcument to override the fireXXX methods and parse
the document at that time instead of overriding the inserUpdate method.
This fixes issue 24.
* Added Groovy GString expression highlights
* Removed getLanguages method from Lexer interface and implementations.
* Added WARNING and ERROR TokenTypes and added their default styles.
* Moved Keymaps and install methods to SyntaxKits instead of the Lexers
* Removed deprecated methods from SyntaxActions class
* Split SyntaxActions into new package and moved inner classes to the new
package
* Added Token HighLighter to Java
* Added Pairs Highlighter to Java
* Token class made immutable (all final fields)
* Added Find and Replace Dialogs and Action to Java (mapped to C-F and
C-H )
* Added pair matching to XML tags
* Added CDATA matching and pair highlights for XML
* Added Comment Pair Highlighting in XML
* Fixed highlighting with selections so the selection always appears
* Merged Find and Replace Dialogs into one
* Fixed issue 33 (undable to add new line after final closing brace for
Java)
* Added Groovy Multi-Line strings and fixed Comments as Regex issue.
* Fixes to empty find text field causing NPE
Version 0.9.1
* Fixed empty strings in XML syntax Issue 29
* Fixed TAL lexer using incorrect package name
Version 0.9.0
* Initial version after major overhaul libjsyntaxpane-java-0.9.6~r156/pom.xml 0000644 0001750 0001750 00000005172 12127321547 020524 0 ustar sylvestre sylvestre
4.0.0
jsyntaxpane
jsyntaxpane
jar
0.9.6
jsyntaxpane
A very simple to use and extend JEditorKit that supports few languages. The main goal is to make it easy to have nice looking Java Swing Editors with support for Syntax Highlighting.
http://jsyntaxpane.googlecode.com/
The Apache Software License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0
repo
http://jsyntaxpane.googlecode.com/svn/
jflex
JFlex repository
http://jflex.sourceforge.net/repo/
maven-compiler-plugin
2.3
1.6
1.6
org.apache.maven.plugins
maven-jar-plugin
**/Thumbs.db
jsyntaxpane.SyntaxTester
jsyntaxpane
true
development
${pom.url}
de.jflex
maven-jflex-plugin
generate
UTF-8
libjsyntaxpane-java-0.9.6~r156/src/ 0000755 0001750 0001750 00000000000 12127321546 017770 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/ 0000755 0001750 0001750 00000000000 12127321547 020715 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/jflex/ 0000755 0001750 0001750 00000000000 12127321546 022024 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/ 0000755 0001750 0001750 00000000000 12127321546 024370 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/ 0000755 0001750 0001750 00000000000 12127321547 025673 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/lua.flex 0000644 0001750 0001750 00000022530 12127321547 027336 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class LuaLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public LuaLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
private static final byte ENDBLOCK = 4;
private static final byte REPEATBLOCK = 5;
TokenType longType;
int longLen;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
WhiteSpace = {LineTerminator} | [ \t\f]+
LongStart = \[=*\[
LongEnd = \]=*\]
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = [0-9]+
HexDigit = [0-9a-fA-F]
HexIntegerLiteral = 0x{HexDigit}+
/* floating point literals */
DoubleLiteral = ({FLit1}|{FLit2}) {Exponent}?
FLit1 = [0-9]+(\.[0-9]*)?
FLit2 = \.[0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter1 = [^\r\n\"\\]
StringCharacter2 = [^\r\n\'\\]
%state STRING1
%state STRING2
%state LONGSTRING
%state COMMENT
%state LINECOMMENT
%%
{
/* keywords */
"and" |
"break" |
"for" |
"if" |
"in" |
"local" |
"not" |
"or" |
"return" |
"while" |
/* boolean literals */
"true" |
"false" |
/* nil literal */
"nil" { return token(TokenType.KEYWORD); }
"repeat" { return token(TokenType.KEYWORD, REPEATBLOCK); }
"until" { return token(TokenType.KEYWORD, -REPEATBLOCK); }
"function" { return token(TokenType.KEYWORD, ENDBLOCK); }
"then" { return token(TokenType.KEYWORD, ENDBLOCK); }
"do" { return token(TokenType.KEYWORD, ENDBLOCK); }
"else" { return token(TokenType.KEYWORD); }
"elseif" { return token(TokenType.KEYWORD); }
"end" { return token(TokenType.KEYWORD, -ENDBLOCK); }
/* operators */
"+" |
"-" |
"*" |
"/" |
"%" |
"^" |
"#" |
"==" |
"~=" |
"<=" |
">=" |
"<" |
">" |
"=" |
";" |
":" |
"," |
"." |
".." |
"..." { return token(TokenType.OPERATOR); }
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
{LongStart} {
longType = TokenType.STRING;
yybegin(LONGSTRING);
tokenStart = yychar;
tokenLength = yylength();
longLen = tokenLength;
}
"--" {
yybegin(COMMENT);
tokenStart = yychar;
tokenLength = yylength();
}
/* string literal */
\" {
yybegin(STRING1);
tokenStart = yychar;
tokenLength = 1;
}
\' {
yybegin(STRING2);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{HexIntegerLiteral} |
{DoubleLiteral} { return token(TokenType.NUMBER); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
{LongEnd} {
if (longLen == yylength()) {
tokenLength += yylength();
yybegin(YYINITIAL);
return token(longType, tokenStart, tokenLength);
} else {
tokenLength++;
yypushback(yylength() - 1);
}
}
{LineTerminator} { tokenLength += yylength(); }
. { tokenLength++; }
<> {
yybegin(YYINITIAL);
return token(longType, tokenStart, tokenLength);
}
}
{
{LongStart} {
longType = TokenType.COMMENT;
yybegin(LONGSTRING);
tokenLength += yylength();
longLen = yylength();
}
{LineTerminator} {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength);
}
. {
yybegin(LINECOMMENT);
tokenLength += yylength();
}
<> {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength);
}
}
{
{LineTerminator} {
yybegin(YYINITIAL);
tokenLength += yylength();
return token(TokenType.COMMENT, tokenStart, tokenLength);
}
{LineTerminator} { tokenLength += yylength(); }
. { tokenLength++; }
<> {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength);
}
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter1}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
<> {
yybegin(YYINITIAL);
return token(TokenType.STRING, tokenStart, tokenLength);
}
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter2}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
<> {
yybegin(YYINITIAL);
return token(TokenType.STRING, tokenStart, tokenLength);
}
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/cpp.flex 0000644 0001750 0001750 00000012434 12127321547 027341 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* 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
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class CppLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
public CppLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
ConstantIdentifier = {SimpleConstantIdentifier}
SimpleConstantIdentifier = [#A-Z0-9_]+
Identifier = [:jletter:][: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]+
%%
{
/* keywords */
"break" |
"case" |
"catch" |
"continue" |
"default" |
"do" |
"else" |
"for" |
"goto" |
"enum" |
"if" |
"inline" |
"mutable" |
"noinline" |
"return" |
"safecast" |
"sealed" |
"selectany" |
"sizeof" |
"static_cast" |
"switch" |
"template" |
"this" |
"thread" |
"throw" |
"try" |
"typedef" |
"typeid" |
"typename" |
"using" |
"uuid" |
"value" |
"virtual" |
"while" |
/* C++ Keywords */
"new" |
"delete" |
"this" |
"friend" |
"using" |
"throw" |
"try" |
"catch" |
"class" |
"typename" |
"template" |
"namespace"
{ return token(TokenType.KEYWORD); }
"static" |
"struct" |
"union" |
"volatile" |
"register" |
"extern" |
"const" |
"signed" |
"unsigned" |
"bool" |
"char" |
"double" |
"int" |
"long" |
"float" |
"short" |
"void" |
"public" |
"protected" |
"private" |
"virtual" |
"inline" |
"virtual" |
"explicit" |
"export" |
"bool" |
"wchar_t"
{ return token(TokenType.TYPE); }
/* literals */
(\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) |
(\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \'))
{ return token(TokenType.STRING); }
"true" |
"false" |
{DecLiteral} |
{OctLiteral} |
{HexLiteral} |
{FloatLiteral}
{ return token(TokenType.NUMBER); }
/* preprocessor symbols */
"#define" |
"#elif" |
"#else" |
"#endif" |
"#error" |
"#ifdef" |
"#ifndef" |
"#if" |
"#import" |
"#include" |
"#line" |
"#pragma" |
"#undef" |
"#using"
{ return token(TokenType.KEYWORD2); }
/* separators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
/* operators */
"=" |
";" |
"," |
"." |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
">>" |
"<<" |
"operator" |
"typeid" |
"and" |
"bitor" |
"or" |
"xor" |
"compl" |
"bitand" |
"and_eq" |
"or_eq" |
"xor_eq" |
"not" |
"not_eq"
{ return token(TokenType.OPERATOR); }
/** C++ standard and built-in objects */
"cin" |
"cout"
{ return token(TokenType.TYPE2); }
{ConstantIdentifier} { return token(TokenType.TYPE); }
{Identifier} { return token(TokenType.IDENTIFIER); }
{Comment} { return token(TokenType.COMMENT); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/ruby.flex 0000644 0001750 0001750 00000020733 12127321547 027541 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class RubyLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public RubyLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
private static final byte WORD = 4;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = "#" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [a-zA-Z][a-zA-Z0-9_]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
%state STRING, ML_STRING
%%
{
/* keywords */
"BEGIN" |
"ensure" |
"assert" |
"nil" |
"self" |
"when" |
"END" |
"false" |
"not" |
"super" |
"alias" |
"defined" |
"or" |
"then" |
"yield" |
"and" |
"redo" |
"true" |
"else" |
"in" |
"rescue" |
"undef" |
"break" |
"elsif" |
"module" |
"retry" |
"unless" |
"next" |
"return" { return token(TokenType.KEYWORD); }
"begin" |
"case" |
"class" |
"def" |
"for" |
"while" |
"until" |
"do" |
"if" { return token(TokenType.KEYWORD, WORD); }
"end" { return token(TokenType.KEYWORD, -WORD); }
/* Built-in Types*/
"self" |
"nil" |
"true" |
"false" |
"__FILE__" |
"__LINE__" { return token(TokenType.TYPE); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
"+" |
"-" |
"*" |
"**" |
"/" |
"//" |
"%" |
"<<" |
">>" |
"&" |
"|" |
"^" |
"~" |
"<" |
">" |
"<=" |
">=" |
"==" |
"!=" |
"<>" |
"@" |
"," |
":" |
"." |
".." |
"`" |
"=" |
";" |
"+=" |
"-=" |
"*=" |
"/=" |
"//=" |
"%=" |
"&=" |
"|=" |
"^=" |
">>=" |
"<<=" |
"**=" { return token(TokenType.OPERATOR); }
/* string literal */
\"{3} {
yybegin(ML_STRING);
tokenStart = yychar;
tokenLength = 3;
}
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{FloatLiteral}[jJ] { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier}"?" { return token(TokenType.TYPE2); }
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\"{3} {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 3);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { tokenLength ++; }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/groovy.flex 0000644 0001750 0001750 00000041642 12127321547 030107 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class GroovyLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Default constructor is needed as we will always call the yyreset
*/
public GroovyLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* Groovy and generally Java types have first UpperCase Letter */
// Type = [:uppercase:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\\$]
SingleCharacter = [^\r\n\'\\]
RegexCharacter = [^\r\n\/]
%state STRING, CHARLITERAL, REGEX, GSTRING_EXPR, CHARLITERAL, JDOC, JDOC_TAG
%state ML_STRING, ML_STRING_EXPR
%%
{
/* keywords */
"abstract" |
"boolean" |
"break" |
"byte" |
"case" |
"catch" |
"char" |
"class" |
"const" |
"continue" |
"do" |
"double" |
"enum" |
"else" |
"extends" |
"final" |
"finally" |
"float" |
"for" |
"default" |
"implements" |
"import" |
"instanceof" |
"int" |
"interface" |
"long" |
"native" |
"new" |
"goto" |
"if" |
"public" |
"short" |
"super" |
"switch" |
"synchronized" |
"package" |
"private" |
"protected" |
"transient" |
"return" |
"void" |
"static" |
"while" |
"this" |
"throw" |
"throws" |
"try" |
"volatile" |
"strictfp" |
/* Groovy reserved words not in Java */
"as" |
"asssert" |
"def" |
"in" |
"threadsafe" |
/* Booleans and null */
"true" |
"false" |
"null" { return token(TokenType.KEYWORD); }
/* Builtin Types and Object Wrappers */
"Boolean" |
"Byte" |
"Character" |
"Double" |
"Float" |
"Integer" |
"Object" |
"Short" |
"String" |
"Void" |
"Class" |
"Number" |
"Package" |
"StringBuffer" |
"StringBuilder" |
"CharSequence" |
"Thread" |
"Regex" { return token(TokenType.TYPE); }
/* Some Java standard Library Types */
"Throwable" |
"Cloneable" |
"Comparable" |
"Serializable" |
"Runnable" { return token(TokenType.TYPE); }
/* Groovy commonly used methods */
"print" |
"println" { return token(TokenType.KEYWORD); }
/* Frequently used Standard Exceptions */
"ArithmeticException" |
"ArrayIndexOutOfBoundsException" |
"ClassCastException" |
"ClassNotFoundException" |
"CloneNotSupportedException" |
"Exception" |
"IllegalAccessException" |
"IllegalArgumentException" |
"IllegalStateException" |
"IllegalThreadStateException" |
"IndexOutOfBoundsException" |
"InstantiationException" |
"InterruptedException" |
"NegativeArraySizeException" |
"NoSuchFieldException" |
"NoSuchMethodException" |
"NullPointerException" |
"NumberFormatException" |
"RuntimeException" |
"SecurityException" |
"StringIndexOutOfBoundsException" |
"UnsupportedOperationException" { return token(TokenType.TYPE2); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
";" |
"," |
"." |
"@" |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"==" |
"<=" |
">=" |
"!=" |
"&&" |
"||" |
"++" |
"--" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
"<<" |
">>" |
">>>" |
"+=" |
"-=" |
"*=" |
"/=" |
"&=" |
"|=" |
"^=" |
"%=" |
"<<=" |
">>=" |
">>>=" { return token(TokenType.OPERATOR); }
"~=" |
"?." { return token(TokenType.OPERATOR); }
/* string literal */
\"{3} {
yybegin(ML_STRING);
tokenStart = yychar;
tokenLength = 3;
}
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* character literal */
\' {
yybegin(CHARLITERAL);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
// JavaDoc comments need a state so that we can highlight the @ controls
"/**" {
yybegin(JDOC);
tokenStart = yychar;
tokenLength = 3;
}
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace}+ { /* skip */ }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
/*
Groovy Regex -- state cannot be easily used here due to / by itself being
a valid operator. So if we flip into the REGEX state, we cannot distinguish
a regular /
*/
"/" [^*] {RegexCharacter}+ "/" { return token(TokenType.REGEX); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
"${" {
yybegin(GSTRING_EXPR);
// length also includes the trailing quote
int s = tokenStart;
int l = tokenLength;
tokenStart = yychar;
tokenLength = 2;
return token(TokenType.STRING, s, l);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
"}" {
yybegin(STRING);
// length also includes the trailing quote
int s = tokenStart;
int l = tokenLength + 1;
tokenStart = yychar + 1;
tokenLength = 0;
return token(TokenType.STRING2, s, l);
}
{StringCharacter} { tokenLength ++; }
}
{
\"{3} {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 3);
}
"${" {
yybegin(ML_STRING_EXPR);
// length also includes the trailing quote
int s = tokenStart;
int l = tokenLength;
tokenStart = yychar;
tokenLength = 2;
return token(TokenType.STRING, s, l);
}
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
.|{LineTerminator} { tokenLength += yylength(); }
}
{
"}" {
yybegin(ML_STRING);
// length also includes the trailing quote
int s = tokenStart;
int l = tokenLength + 1;
tokenStart = yychar + 1;
tokenLength = 0;
return token(TokenType.STRING2, s, l);
}
.|\n|\r { tokenLength ++; }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SingleCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
"@" {
yybegin(JDOC_TAG);
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT, start, len);
}
.|\n { tokenLength ++; }
}
{
([:letter:])+ ":"? { tokenLength += yylength(); }
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
.|\n {
yybegin(JDOC);
// length also includes the trailing quote
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT2, start, len);
}
}
{
"/" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.REGEX, tokenStart, tokenLength + 1);
}
{RegexCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/java.flex 0000644 0001750 0001750 00000031040 12127321547 027472 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class JavaLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public JavaLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
%state STRING, CHARLITERAL, JDOC, JDOC_TAG
%%
{
/* keywords */
"abstract" |
"boolean" |
"break" |
"byte" |
"case" |
"catch" |
"char" |
"class" |
"const" |
"continue" |
"do" |
"double" |
"enum" |
"else" |
"extends" |
"final" |
"finally" |
"float" |
"for" |
"default" |
"implements" |
"import" |
"instanceof" |
"int" |
"interface" |
"long" |
"native" |
"new" |
"goto" |
"if" |
"public" |
"short" |
"super" |
"switch" |
"synchronized" |
"package" |
"private" |
"protected" |
"transient" |
"return" |
"void" |
"static" |
"while" |
"this" |
"throw" |
"throws" |
"try" |
"volatile" |
"strictfp" |
"true" |
"false" |
"null" { return token(TokenType.KEYWORD); }
/* Java Built in types and wrappers */
"Boolean" |
"Byte" |
"Character" |
"Double" |
"Float" |
"Integer" |
"Object" |
"Short" |
"Void" |
"Class" |
"Number" |
"Package" |
"StringBuffer" |
"StringBuilder" |
"CharSequence" |
"Thread" |
"String" { return token(TokenType.TYPE); }
/* Some Java standard Library Types */
"Throwable" |
"Cloneable" |
"Comparable" |
"Serializable" |
"Runnable" { return token(TokenType.TYPE); }
"WARNING" { return token(TokenType.WARNING); }
"ERROR" { return token(TokenType.ERROR); }
/* Frequently used Standard Exceptions */
"ArithmeticException" |
"ArrayIndexOutOfBoundsException" |
"ClassCastException" |
"ClassNotFoundException" |
"CloneNotSupportedException" |
"Exception" |
"IllegalAccessException" |
"IllegalArgumentException" |
"IllegalStateException" |
"IllegalThreadStateException" |
"IndexOutOfBoundsException" |
"InstantiationException" |
"InterruptedException" |
"NegativeArraySizeException" |
"NoSuchFieldException" |
"NoSuchMethodException" |
"NullPointerException" |
"NumberFormatException" |
"RuntimeException" |
"SecurityException" |
"StringIndexOutOfBoundsException" |
"UnsupportedOperationException" { return token(TokenType.TYPE2); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
";" |
"," |
"." |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"==" |
"<=" |
">=" |
"!=" |
"&&" |
"||" |
"++" |
"--" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
"<<" |
">>" |
">>>" |
"+=" |
"-=" |
"*=" |
"/=" |
"&=" |
"|=" |
"^=" |
"%=" |
"<<=" |
">>=" |
">>>=" { return token(TokenType.OPERATOR); }
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* character literal */
\' {
yybegin(CHARLITERAL);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
// JavaDoc comments need a state so that we can highlight the @ controls
"/**" {
yybegin(JDOC);
tokenStart = yychar;
tokenLength = 3;
}
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SingleCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
"@" {
yybegin(JDOC_TAG);
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT, start, len);
}
.|\n { tokenLength ++; }
}
{
([:letter:])+ ":"? { tokenLength += yylength(); }
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
.|\n {
yybegin(JDOC);
// length also includes the trailing quote
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT2, start, len);
}
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/scala.flex 0000644 0001750 0001750 00000025465 12127321547 027652 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class ScalaLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public ScalaLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
%state STRING, CHARLITERAL, JDOC, JDOC_TAG
%%
{
/* keywords */
"def" |
"import" |
"package" |
"if" |
"then" |
"else" |
"while" |
"for" |
"do" |
"boolean" |
"int" |
"double" |
"byte" |
"short" |
"char" |
"long" |
"float" |
"unit" |
"val" |
"with" |
"type" |
"var" |
"yield" |
"return" |
"true" |
"false" |
"null" |
"this" |
"super" |
"String" |
"Array" |
"private" |
"protected" |
"override" |
"abstract" |
"final" |
"sealed" |
"throw" |
"try" |
"catch" |
"finally" |
"extends" { return token(TokenType.KEYWORD); }
/* Java Built in types and wrappers */
"object" |
"Boolean" |
"Byte" |
"Character" |
"Double" |
"Float" |
"Integer" |
"Object" |
"Short" |
"Void" |
"Class" |
"Number" |
"Package" |
"StringBuffer" |
"StringBuilder" |
"CharSequence" |
"Thread" |
"String" { return token(TokenType.TYPE); }
/* Some Scala predefines */
"println" { return token(TokenType.KEYWORD2); }
/* Some Java standard Library Types */
"Throwable" |
"Cloneable" |
"Comparable" |
"Serializable" |
"Runnable" { return token(TokenType.TYPE); }
"WARNING" { return token(TokenType.WARNING); }
"ERROR" { return token(TokenType.ERROR); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
";" |
"," |
"." |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"==" |
"<=" |
">=" |
"!=" |
"&&" |
"||" |
"++" |
"--" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
"<<" |
">>" |
">>>" |
"+=" |
"-=" |
"*=" |
"/=" |
"&=" |
"|=" |
"^=" |
"%=" |
"<<=" |
">>=" |
">>>=" { return token(TokenType.OPERATOR); }
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* character literal */
\' {
yybegin(CHARLITERAL);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
// JavaDoc comments need a state so that we can highlight the @ controls
"/**" {
yybegin(JDOC);
tokenStart = yychar;
tokenLength = 3;
}
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SingleCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
"@" {
yybegin(JDOC_TAG);
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT, start, len);
}
.|\n { tokenLength ++; }
}
{
([:letter:])+ ":"? { tokenLength += yylength(); }
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
.|\n {
yybegin(JDOC);
// length also includes the trailing quote
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT2, start, len);
}
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/jflex.flex 0000644 0001750 0001750 00000032010 12127321547 027657 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class JFlexLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public JFlexLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
%state STRING, CHARLITERAL, JDOC, JDOC_TAG
%%
{
/* keywords */
"abstract" |
"boolean" |
"break" |
"byte" |
"case" |
"catch" |
"char" |
"class" |
"const" |
"continue" |
"do" |
"double" |
"enum" |
"else" |
"extends" |
"final" |
"finally" |
"float" |
"for" |
"default" |
"implements" |
"import" |
"instanceof" |
"int" |
"interface" |
"long" |
"native" |
"new" |
"goto" |
"if" |
"public" |
"short" |
"super" |
"switch" |
"synchronized" |
"package" |
"private" |
"protected" |
"transient" |
"return" |
"void" |
"static" |
"while" |
"this" |
"throw" |
"throws" |
"try" |
"volatile" |
"strictfp" |
"true" |
"false" |
"null" { return token(TokenType.KEYWORD); }
/* JFlex special types */
"<>" |
"[:jletter:]" |
"[:jletterdigit:]" |
"[:letter:]" |
"[:digit:]" |
"[:uppercase:]" |
"[:lowercase:]" |
"<" [a-zA-Z][a-zA-Z0-9_]* ">" { return token(TokenType.TYPE2); }
/* JFlex Specials */
"%%" |
"%{" |
"%}" |
"%class" |
"%implements" |
"%extends" |
"%public" |
"%final" |
"%abstract" |
"%apiprivate" |
"%init{" |
"%init}" |
"%initthrow{" |
"%initthrow}" |
"%initthrow" |
"%ctorarg" |
"%scanerror" |
"%buffer" |
"%include" |
"%function" |
"%integer" |
"%int" |
"%intwrap" |
"%yylexthrow{" |
"%yylexthrow}" |
"%yylexthrow" |
"%eofval{" |
"%eofval}" |
"%eof{" |
"%eof}" |
"%eofthrow{" |
"%eofthrow}" |
"%eofthrow" |
"%eofclose" |
"%debug" |
"%standalone" |
"%cup" |
"%cupsym" |
"%cupdebug" |
"%byacc" |
"%switch" |
"%table" |
"%pack" |
"%7bit" |
"%8bit" |
"%full" |
"%unicode" |
"%16bit" |
"%caseless" |
"%ignorecase" |
"%char" |
"%line" |
"%column" |
"%notunix" |
"%yyeof" |
"%s" |
"%state" |
"%x" |
"%xstate" |
"%type" { return token(TokenType.KEYWORD2); }
/* Java Built in types and wrappers */
"Boolean" |
"Byte" |
"Double" |
"Float" |
"Integer" |
"Object" |
"Short" |
"String" { return token(TokenType.TYPE); }
/* operators */
"(" |
")" |
"{" |
"}" |
"[" |
"]" |
";" |
"," |
"." |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"==" |
"<=" |
">=" |
"!=" |
"&&" |
"||" |
"++" |
"--" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
"<<" |
">>" |
">>>" |
"+=" |
"-=" |
"*=" |
"/=" |
"&=" |
"|=" |
"^=" |
"%=" |
"<<=" |
">>=" |
">>>=" { return token(TokenType.OPERATOR); }
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* character literal */
\' {
yybegin(CHARLITERAL);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
// JavaDoc comments need a state so that we can highlight the @ controls
"/**" {
yybegin(JDOC);
tokenStart = yychar;
tokenLength = 3;
}
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SingleCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
"@" {
yybegin(JDOC_TAG);
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT, start, len);
}
.|\n { tokenLength ++; }
}
{
([:letter:])+ ":"? { tokenLength += yylength(); }
"*/" {
yybegin(YYINITIAL);
return token(TokenType.COMMENT, tokenStart, tokenLength + 2);
}
.|\n {
yybegin(JDOC);
// length also includes the trailing quote
int start = tokenStart;
tokenStart = yychar;
int len = tokenLength;
tokenLength = 1;
return token(TokenType.COMMENT2, start, len);
}
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xhtml.flex 0000644 0001750 0001750 00000024606 12127321547 027717 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class XHTMLLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%ignorecase
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public XHTMLLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte TAG_OPEN = 1;
private static final byte TAG_CLOSE = -1;
private static final byte INSTR_OPEN = 2;
private static final byte INSTR_CLOSE = -2;
private static final byte CDATA_OPEN = 3;
private static final byte CDATA_CLOSE = -3;
private static final byte COMMENT_OPEN = 4;
private static final byte COMMENT_CLOSE = -4;
%}
%xstate COMMENT, CDATA, TAG, INSTR, DOCTYPE
/* main character classes */
/* white space */
S = (\u0020 | \u0009 | \u000D | \u000A)+
/* characters */
// Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF]
/* comments */
CommentStart = ""
NameStartChar = ":" | [A-Z] | "_" | [a-z]
NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7
Name = {NameStartChar} {NameChar}*
/* XML Processing Instructions */
InstrStart = "" {Name}
InstrEnd = "?>"
DocTypeStart = ""
/* Tags */
OpenTagStart = "<" {Name}
OpenTagClose = "/>"
OpenTagEnd = ">"
CloseTag = "" {Name} {S}* ">"
/* attribute */
Attribute = {Name} "="
/* HTML specifics */
HTMLTagName =
"address" |
"applet" |
"area" |
"a" |
"b" |
"base" |
"basefont" |
"big" |
"blockquote" |
"body" |
"br" |
"caption" |
"center" |
"cite" |
"code" |
"dd" |
"dfn" |
"dir" |
"div" |
"dl" |
"dt" |
"font" |
"form" |
"h"[1-6] |
"head" |
"hr" |
"html" |
"img" |
"input" |
"isindex" |
"kbd" |
"li" |
"link" |
"LINK" |
"map" |
"META" |
"menu" |
"meta" |
"ol" |
"option" |
"param" |
"pre" |
"p" |
"samp" |
"span" |
"select" |
"small" |
"strike" |
"sub" |
"sup" |
"table" |
"td" |
"textarea" |
"th" |
"title" |
"tr" |
"tt" |
"ul" |
"var" |
"xmp" |
"script" |
"noscript" |
"style"
HTMLAttrName =
"action" |
"align" |
"alink" |
"alt" |
"archive" |
"background" |
"bgcolor" |
"border" |
"bordercolor" |
"cellpadding" |
"cellspacing" |
"checked" |
"class" |
"clear" |
"code" |
"codebase" |
"color" |
"cols" |
"colspan" |
"content" |
"coords" |
"enctype" |
"face" |
"gutter" |
"height" |
"hspace" |
"href" |
"id" |
"link" |
"lowsrc" |
"marginheight" |
"marginwidth" |
"maxlength" |
"method" |
"name" |
"prompt" |
"rel" |
"rev" |
"rows" |
"rowspan" |
"scrolling" |
"selected" |
"shape" |
"size" |
"src" |
"start" |
"target" |
"text" |
"type" |
"url" |
"usemap" |
"ismap" |
"valign" |
"value" |
"vlink" |
"vspace" |
"width" |
"wrap" |
"abbr" |
"accept" |
"accesskey" |
"axis" |
"char" |
"charoff" |
"charset" |
"cite" |
"classid" |
"codetype" |
"compact" |
"data" |
"datetime" |
"declare" |
"defer" |
"dir" |
"disabled" |
"for" |
"frame" |
"headers" |
"hreflang" |
"lang" |
"language" |
"longdesc" |
"multiple" |
"nohref" |
"nowrap" |
"object" |
"profile" |
"readonly" |
"rules" |
"scheme" |
"scope" |
"span" |
"standby" |
"style" |
"summary" |
"tabindex" |
"valuetype" |
"version"
HTMLOpenTagStart = "<" {HTMLTagName}
HTMLCloseTag = "" {HTMLTagName} {S}* ">"
HTMLAttribute = {HTMLAttrName} "="
/* string and character literals */
DQuoteStringChar = [^\r\n\"]
SQuoteStringChar = [^\r\n\']
%%
{
"&" [a-z]+ ";" |
"" [:digit:]+ ";" { return token(TokenType.KEYWORD2); }
{InstrStart} {
yybegin(INSTR);
return token(TokenType.TYPE2, INSTR_OPEN);
}
{DocTypeStart} {
yybegin(DOCTYPE);
return token(TokenType.TYPE2, INSTR_OPEN);
}
{HTMLOpenTagStart} {
yybegin(TAG);
return token(TokenType.KEYWORD2, TAG_OPEN);
}
{HTMLCloseTag} { return token(TokenType.KEYWORD2, TAG_CLOSE); }
{OpenTagStart} {
yybegin(TAG);
return token(TokenType.KEYWORD, TAG_OPEN);
}
{CloseTag} { return token(TokenType.KEYWORD, TAG_CLOSE); }
{CommentStart} {
yybegin(COMMENT);
return token(TokenType.COMMENT2, COMMENT_OPEN);
}
{CDataStart} {
yybegin(CDATA);
return token(TokenType.COMMENT2, CDATA_OPEN);
}
}
{
{Attribute} { return token(TokenType.IDENTIFIER); }
\"{DQuoteStringChar}*\" |
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
{InstrEnd} {
yybegin(YYINITIAL);
return token(TokenType.TYPE2, INSTR_CLOSE);
}
}
{
[^>]* { }
{OpenTagEnd} {
yybegin(YYINITIAL);
return token(TokenType.TYPE2, INSTR_CLOSE);
}
}
{
{HTMLAttribute} { return token(TokenType.KEYWORD2); }
{Attribute} { return token(TokenType.IDENTIFIER); }
\"{DQuoteStringChar}*\" |
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
{OpenTagClose} {
yybegin(YYINITIAL);
return token(TokenType.KEYWORD, TAG_CLOSE);
}
{OpenTagEnd} {
yybegin(YYINITIAL);
return token(TokenType.KEYWORD);
}
}
{
{CommentEnd} {
yybegin(YYINITIAL);
return token(TokenType.COMMENT2, COMMENT_CLOSE);
}
~{CommentEnd} {
yypushback(3);
return token(TokenType.COMMENT);
}
}
{
{CDataEnd} {
yybegin(YYINITIAL);
return token(TokenType.COMMENT2, CDATA_CLOSE);
}
~{CDataEnd} {
yypushback(3);
return token(TokenType.COMMENT);
}
}
{
/* error fallback */
.|\n { }
<> { return null; }
}
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/tal.flex 0000644 0001750 0001750 00000011050 12127321547 027330 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class TALLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%caseless
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public TALLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "!" [^\r\n!]* ( "!" | {LineTerminator} )
EndOfLineComment = "--" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [A-Za-z_][A-Za-z0-9\^_]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = "%" [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
FixedLiteral = DecIntegerLiteral [fF]
DoubleLiteral = DecIntegerLiteral [dD]
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
%%
{
/* keywords */
"begin" |
"end" |
"struct" |
"fieldalign" |
"shared" |
"shared2" |
"literal" |
"for" |
"do" |
"while" |
"?page" |
"?section" { return token(TokenType.KEYWORD); }
"int" |
"string" |
"int(32)" |
"fixed" |
"byte" |
"float" |
"filler" { return token(TokenType.TYPE); }
"(" |
")" |
"{" |
"}" |
"[" |
"]" |
";" |
"," |
"." |
"=" |
">" |
"<" |
"!" |
"?" |
":" |
":=" |
"':='" |
"'=:'" |
"<>" |
"+" |
"-" |
"*" |
"/" |
"<<" |
">>" { return token(TokenType.OPERATOR); }
/* string literal */
\"{StringCharacter}+\" { return token(TokenType.STRING); }
/* character literal */
\'{SingleCharacter}\' { return token(TokenType.STRING); }
/* numeric literals */
{DecIntegerLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FixedLiteral} |
{DoubleLiteral} { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/clojure.flex 0000644 0001750 0001750 00000036063 12127321547 030226 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class ClojureLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public ClojureLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {EndOfLineComment}
EndOfLineComment = ";" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
%state STRING, CHARLITERAL
%%
{
/* keywords */
"fn" |
"fn*" |
"if" |
"def" |
"let" |
"let*" |
"loop*" |
"new" |
"nil" |
"recur" |
"loop" |
"do" |
"quote" |
"the-var" |
"identical?" |
"throw" |
"set!" |
"monitor-enter" |
"monitor-exit" |
"try" |
"catch" |
"finally" |
"in-ns" { return token(TokenType.KEYWORD); }
/* Built-ins */
"*agent*" |
"*command-line-args*" |
"*in*" |
"*macro-meta*" |
"*ns*" |
"*out*" |
"*print-meta*" |
"*print-readably*" |
"*proxy-classes*" |
"*warn-on-reflection*" |
"+" |
"-" |
"->" |
".." |
"/" |
"<" |
"<=" |
"=" |
"==" |
">" |
">=" |
"accessor" |
"agent" |
"agent-errors" |
"aget" |
"alength" |
"all-ns" |
"alter" |
"and" |
"apply" |
"array-map" |
"aset" |
"aset-boolean" |
"aset-byte" |
"aset-char" |
"aset-double" |
"aset-float" |
"aset-int" |
"aset-long" |
"aset-short" |
"assert" |
"assoc" |
"await" |
"await-for" |
"bean" |
"binding" |
"bit-and" |
"bit-not" |
"bit-or" |
"bit-shift-left" |
"bit-shift-right" |
"bit-xor" |
"boolean" |
"butlast" |
"byte" |
"cast" |
"char" |
"class" |
"clear-agent-errors" |
"comment" |
"commute" |
"comp" |
"comparator" |
"complement" |
"concat" |
"cond" |
"conj" |
"cons" |
"constantly" |
"construct-proxy" |
"contains?" |
"count" |
"create-ns" |
"create-struct" |
"cycle" |
"dec" |
"defmacro" |
"defmethod" |
"defmulti" |
"defn" |
"defn-" |
"defstruct" |
"deref" |
"destructure" |
"disj" |
"dissoc" |
"distinct" |
"doall" |
"doc" |
"dorun" |
"doseq" |
"dosync" |
"dotimes" |
"doto" |
"double" |
"drop" |
"drop-while" |
"ensure" |
"eval" |
"every?" |
"false?" |
"ffirst" |
"file-seq" |
"filter" |
"find" |
"find-doc" |
"find-ns" |
"find-var" |
"first" |
"float" |
"flush" |
"fnseq" |
"for" |
"frest" |
"gensym" |
"gen-class" |
"gen-interface" |
"get" |
"get-proxy-class" |
"hash-map" |
"hash-set" |
"identity" |
"if-let" |
"import" |
"inc" |
"instance?" |
"int" |
"interleave" |
"into" |
"into-array" |
"iterate" |
"key" |
"keys" |
"keyword" |
"keyword?" |
"last" |
"lazy-cat" |
"lazy-cons" |
"line-seq" |
"list" |
"list*" |
"load" |
"load-file" |
"locking" |
"long" |
"macroexpand" |
"macroexpand-1" |
"make-array" |
"map" |
"map?" |
"mapcat" |
"max" |
"max-key" |
"memfn" |
"merge" |
"merge-with" |
"meta" |
"min" |
"min-key" |
"name" |
"namespace" |
"neg?" |
"newline" |
"nil?" |
"not" |
"not-any?" |
"not-every?" |
"not=" |
"ns-imports" |
"ns-interns" |
"ns-map" |
"ns-name" |
"ns-publics" |
"ns-refers" |
"ns-resolve" |
"ns-unmap" |
"nth" |
"nthrest" |
"or" |
"partial" |
"peek" |
"pmap" |
"pop" |
"pos?" |
"pr" |
"pr-str" |
"print" |
"print-doc" |
"print-str" |
"println" |
"println-str" |
"prn" |
"prn-str" |
"proxy" |
"proxy-mappings" |
"quot" |
"rand" |
"rand-int" |
"range" |
"re-find" |
"re-groups" |
"re-matcher" |
"re-matches" |
"re-pattern" |
"re-seq" |
"read" |
"read-line" |
"reduce" |
"ref" |
"ref-set" |
"refer" |
"rem" |
"remove-method" |
"remove-ns" |
"repeat" |
"replace" |
"replicate" |
"require" |
"resolve" |
"rest" |
"resultset-seq" |
"reverse" |
"rfirst" |
"rrest" |
"rseq" |
"scan" |
"second" |
"select-keys" |
"send" |
"send-off" |
"seq" |
"seq?" |
"set" |
"short" |
"slurp" |
"some" |
"sort" |
"sort-by" |
"sorted-map" |
"sorted-map-by" |
"sorted-set" |
"special-symbol?" |
"split-at" |
"split-with" |
"str" |
"string?" |
"struct" |
"struct-map" |
"subs" |
"subvec" |
"symbol" |
"symbol?" |
"sync" |
"take" |
"take-nth" |
"take-while" |
"test" |
"time" |
"to-array" |
"to-array-2d" |
"touch" |
"tree-seq" |
"true?" |
"update-proxy" |
"val" |
"vals" |
"var-get" |
"var-set" |
"var?" |
"vector" |
"vector?" |
"when" |
"when-first" |
"when-let" |
"when-not" |
"while" |
"with-local-vars" |
"with-meta" |
"with-open" |
"with-out-str" |
"xml-seq" |
"zero?" |
"zipmap" |
"repeatedly" |
"add-classpath" |
"vec" |
"hash" { return token(TokenType.KEYWORD2); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* character literal */
\' {
yybegin(CHARLITERAL);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SingleCharacter}+ { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/javascript.flex 0000644 0001750 0001750 00000020561 12127321547 030725 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class JavaScriptLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public JavaScriptLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SStringCharacter = [^\r\n\'\\]
%state STRING SSTRING
%%
{
/* keywords */
"break" |
"case" |
"catch" |
"continue" |
"do" |
"else" |
"finally" |
"for" |
"default" |
"delete" |
"new" |
"goto" |
"if" |
"switch" |
"return" |
"while" |
"this" |
"try" |
"var" |
"function" |
"with" |
"in" |
/* boolean literals */
"true" |
"false" |
/* null literal */
"null" { return token(TokenType.KEYWORD); }
/* standard / builtin functions */
"Infinity" |
"NaN" |
"undefined" |
"decodeURI" |
"encodeURIComponent" |
"escape" |
"eval" |
"isFinite" |
"isNaN" |
"parseFloat" |
"parseInt" |
"unescape" { return token(TokenType.KEYWORD2); }
/* Built-in Types*/
"Array" |
"Boolean" |
"Date" |
"Math" |
"Number" |
"Object" |
"RegExp" |
"String" |
{Identifier} ":" { return token(TokenType.TYPE); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
";" |
"," |
"." |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"==" |
"<=" |
">=" |
"!=" |
"&&" |
"||" |
"++" |
"--" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
"%" |
"<<" |
">>" |
">>>" |
"+=" |
"-=" |
"*=" |
"/=" |
"&=" |
"|=" |
"^=" |
"%=" |
"<<=" |
">>=" |
">>>=" { return token(TokenType.OPERATOR); }
/* string literal */
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
\' {
yybegin(SSTRING);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{DoubleLiteral}[dD] { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SStringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/c.flex 0000644 0001750 0001750 00000011532 12127321547 026777 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* 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
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class CLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
public CLexer() {
super();
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
@Override
public int yychar() {
return yychar;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
EndOfLineComment = "//" {InputCharacter}* {LineTerminator}?
/* 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]+
%%
{
/* keywords */
"break" |
"case" |
"catch" |
"continue" |
"default" |
"do" |
"else" |
"for" |
"goto" |
"enum" |
"if" |
"inline" |
"mutable" |
"noinline" |
"return" |
"safecast" |
"sealed" |
"selectany" |
"sizeof" |
"static_cast" |
"switch" |
"template" |
"this" |
"thread" |
"throw" |
"try" |
"typedef" |
"typeid" |
"typename" |
"using" |
"uuid" |
"value" |
"virtual" |
"while"
{ return token(TokenType.KEYWORD); }
"static" |
"struct" |
"union" |
"volatile" |
"register" |
"extern" |
"const" |
"signed" |
"unsigned" |
"bool" |
"char" |
"double" |
"int" |
"long" |
"float" |
"short" |
"void" { return token(TokenType.TYPE); }
/* literals */
(\" ( [^\"\n\\] | \\[^\n] )* (\n | \\\n | \")) |
(\' ( [^\'\n\\] | \\[^\n] )* (\n | \\\n | \'))
{ return token(TokenType.STRING); }
"true" |
"false" |
{DecLiteral} |
{OctLiteral} |
{HexLiteral} |
{FloatLiteral}
{ return token(TokenType.NUMBER); }
/* preprocessor symbols */
"#define" |
"#elif" |
"#else" |
"#endif" |
"#error" |
"#ifdef" |
"#ifndef" |
"#if" |
"#import" |
"#include" |
"#line" |
"#pragma" |
"#undef" |
"#using"
{ return token(TokenType.KEYWORD2); }
/* separators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
/* operators */
"=" |
";" |
"," |
"." |
">" |
"<" |
"!" |
"~" |
"?" |
":" |
"+" |
"-" |
"*" |
"/" |
"&" |
"|" |
"^" |
">>" |
"<<" |
"%" { return token(TokenType.OPERATOR); }
{ConstantIdentifier} { return token(TokenType.IDENTIFIER); }
{TypeIdentifier} { return token(TokenType.IDENTIFIER); }
\n |
{Identifier} |
{WhiteSpace} { return token(TokenType.IDENTIFIER); }
{Comment} { return token(TokenType.COMMENT); }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xpath.flex 0000644 0001750 0001750 00000024373 12127321547 027710 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This flex file originally donated to the project by HeyChinaski
*
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class XPathLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public XPathLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
Digits = [0-9]+
Letter = {BaseChar} | {Ideographic}
BaseChar = [\u0041-\u005A] | [\u0061-\u007A] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] | [\u0100-\u0131] | [\u0134-\u013E] | [\u0141-\u0148] | [\u014A-\u017E] | [\u0180-\u01C3] | [\u01CD-\u01F0] | [\u01F4-\u01F5] | [\u01FA-\u0217] | [\u0250-\u02A8] | [\u02BB-\u02C1] | \u0386 | [\u0388-\u038A] | \u038C | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D6] | \u03DA | \u03DC | \u03DE | \u03E0 | [\u03E2-\u03F3] | [\u0401-\u040C] | [\u040E-\u044F] | [\u0451-\u045C] | [\u045E-\u0481] | [\u0490-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04EB] | [\u04EE-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | \u0559 | [\u0561-\u0586] | [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0641-\u064A] | [\u0671-\u06B7] | [\u06BA-\u06BE] | [\u06C0-\u06CE] | [\u06D0-\u06D3] | \u06D5 | [\u06E5-\u06E6] | [\u0905-\u0939] | \u093D | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | \u09B2 | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | \u0A5E | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | \u0A8D | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | \u0ABD | \u0AE0 | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | \u0B3D | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | \u0B9C | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | \u0CDE | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0E01-\u0E2E] | \u0E30 | [\u0E32-\u0E33] | [\u0E40-\u0E45] | [\u0E81-\u0E82] | \u0E84 | [\u0E87-\u0E88] | \u0E8A | \u0E8D | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | \u0EA5 | \u0EA7 | [\u0EAA-\u0EAB] | [\u0EAD-\u0EAE] | \u0EB0 | [\u0EB2-\u0EB3] | \u0EBD | [\u0EC0-\u0EC4] | [\u0F40-\u0F47] | [\u0F49-\u0F69] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | \u1100 | [\u1102-\u1103] | [\u1105-\u1107] | \u1109 | [\u110B-\u110C] | [\u110E-\u1112] | \u113C | \u113E | \u1140 | \u114C | \u114E | \u1150 | [\u1154-\u1155] | \u1159 | [\u115F-\u1161] | \u1163 | \u1165 | \u1167 | \u1169 | [\u116D-\u116E] | [\u1172-\u1173] | \u1175 | \u119E | \u11A8 | \u11AB | [\u11AE-\u11AF] | [\u11B7-\u11B8] | \u11BA | [\u11BC-\u11C2] | \u11EB | \u11F0 | \u11F9 | [\u1E00-\u1E9B] | [\u1EA0-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | \u1F59 | \u1F5B | \u1F5D | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | \u1FBE | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | \u2126 | [\u212A-\u212B] | \u212E | [\u2180-\u2182] | [\u3041-\u3094] | [\u30A1-\u30FA] | [\u3105-\u312C] | [\uAC00-\uD7A3]
Ideographic = [\u4E00-\u9FA5] | \u3007 | [\u3021-\u3029]
NCNameStartChar = {Letter} | "_"
NameStartCharMinusColon = [A-Z] | "_" | [a-z] | [\uC0-\uD6] | [\uD8-\uF6] | [\uF8-\u2FF] | [\u370-\u37D] | [\u37F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD]
NCNameChar = {NameStartCharMinusColon} | "-" | "." | [0-9] | \uB7 | [\u0300-\u036F] | [\u203F-\u2040]
NCName = {NCNameStartChar} {NCNameChar}*
LocalPart = {NCName}
UnprefixedName = {LocalPart}
Prefix = {NCName}
PrefixedName = {Prefix} ":" {LocalPart}
QName = {PrefixedName} | {UnprefixedName}
NameTest = "*" | {NCName} ":" "*" | {QName}
VariableReference = "$" {QName}
LineTerminator = \r|\n|\r\n
NodeType = "comment"
| "text"
| "processing-instruction"
| "node"
OperatorName = "and" | "or" | "mod" | "div"
Operator = {OperatorName} | "*" | "/" | "//" | "|" | "+" | "-" | "=" | "!=" | "<" | "<=" | ">" | ">="
FunctionName = {QName}
XPathFunction = "default"
| "node-name"
| "nilled"
| "data"
| "base-uri"
| "document-uri"
| "error"
| "trace"
| "number"
| "abs"
| "ceiling"
| "floor"
| "round"
| "round-half-to-even"
| "string"
| "codepoints-to-string"
| "string-to-codepoints"
| "codepoint-equal"
| "compare"
| "concat"
| "string-join"
| "substring"
| "string-length"
| "normalize-space"
| "normalize-unicode"
| "upper-case"
| "lower-case"
| "translate"
| "escape-uri"
| "contains"
| "starts-with"
| "ends-with"
| "substring-before"
| "substring-after"
| "matches"
| "replace"
| "tokenize"
| "resolve-uri"
| "boolean"
| "not"
| "true"
| "false"
| "dateTime"
| "years-from-duration"
| "months-from-duration"
| "days-from-duration"
| "hours-from-duration"
| "minutes-from-duration"
| "seconds-from-duration"
| "year-from-dateTime"
| "month-from-dateTime"
| "day-from-dateTime"
| "hours-from-dateTime"
| "minutes-from-dateTime"
| "seconds-from-dateTime"
| "timezone-from-dateTime"
| "year-from-date"
| "month-from-date"
| "day-from-date"
| "timezone-from-date"
| "hours-from-time"
| "minutes-from-time"
| "seconds-from-time"
| "timezone-from-time"
| "adjust-dateTime-to-timezone"
| "adjust-date-to-timezone"
| "adjust-time-to-timezone"
| "QName"
| "local-name-from-QName"
| "namespace-uri-from-QName"
| "namespace-uri-for-prefix"
| "in-scope-prefixes"
| "resolve-QName"
| "name"
| "local-name"
| "namespace-uri"
| "lang"
| "root"
| "index-of"
| "remove"
| "empty"
| "exists"
| "distinct-values"
| "insert-before"
| "reverse"
| "subsequence"
| "unordered"
| "zero-or-one"
| "one-or-more"
| "exactly-one"
| "deep-equal"
| "count"
| "avg"
| "max"
| "min"
| "sum"
| "id"
| "idref"
| "doc"
| "doc-available"
| "collection"
| "position"
| "last"
| "current-dateTime"
| "current-date"
| "current-time"
| "implicit-timezone"
| "default-collation"
| "static-base-uri"
AxisName = "ancestor"
| "ancestor-or-self"
| "attribute"
| "child"
| "descendant"
| "descendant-or-self"
| "following"
| "following-sibling"
| "namespace"
| "parent"
| "preceding"
| "preceding-sibling"
| "self"
Number = {Digits} | {Digits} "." {Digits}
S = [\u20] | [\u9] | [\uD] | [\uA]
%state STRING_DOUBLE, STRING_SINGLE
%%
{
{VariableReference} { return token(TokenType.IDENTIFIER); }
{Number} { return token(TokenType.NUMBER); }
{AxisName} { return token(TokenType.TYPE); }
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
"." | ".." | "@" | "," | "::" { return token(TokenType.OPERATOR); }
{Operator} { return token(TokenType.OPERATOR); }
{NodeType} { return token(TokenType.KEYWORD); }
{XPathFunction} { return token(TokenType.KEYWORD2); }
{FunctionName} { return token(TokenType.IDENTIFIER); }
{NameTest} { return token(TokenType.IDENTIFIER); }
/* string literal */
\" {
yybegin(STRING_DOUBLE);
tokenStart = yychar;
tokenLength = 1;
}
/* string literal */
\' {
yybegin(STRING_SINGLE);
tokenStart = yychar;
tokenLength = 1;
}
":" | {S} | "\"" {}
. | {LineTerminator} { /* skip */ }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
[^\"] { tokenLength += yylength(); }
}
{
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
[^\'] { tokenLength += yylength(); }
}
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/sql.flex 0000644 0001750 0001750 00000024720 12127321547 027357 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class SqlLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%caseless
%{
/**
* Default constructor is needed as we will always call the yyreset
*/
public SqlLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]
/* comments */
Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment}
TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
DocumentationComment = "/**" {CommentContent} "*"+ "/"
CommentContent = ( [^*] | \*+ [^/*] )*
EndOfLineComment = "--" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
// Create states for Double Quoted and Single Quoted Strings
%state DQ_STRING, SQ_STRING
Reserved =
"ADD" |
"ALL" |
"ALLOW REVERSE SCANS" |
"ALTER" |
"ANALYZE" |
"AND" |
"AS" |
"ASC" |
"AUTOMATIC" |
"BEGIN" |
"BEFORE" |
"BETWEEN" |
"BIGINT" |
"BINARY" |
"BLOB" |
"BOTH" |
"BUFFERPOOL" |
"BY" |
"CACHE" |
"CALL" |
"CASCADE" |
"CASE" |
"CHANGE" |
"CHAR" |
"CHARACTER" |
"CHECK" |
"COLLATE" |
"COLUMN" |
"COMMIT" |
"CONDITION" |
"CONSTANT" |
"CONSTRAINT" |
"CONTINUE" |
"CONVERT" |
"CREATE" |
"CROSS" |
"CURSOR" |
"DATE" |
"DATABASE" |
"DATABASES" |
"DEC" |
"DECIMAL" |
"DECODE" |
"DECLARE" |
"DEFAULT" |
"DELAYED" |
"DELETE" |
"DESC" |
"DESCRIBE" |
"DETERMINISTIC" |
"DISTINCT" |
"DISTINCTROW" |
"DIV" |
"DOUBLE" |
"DROP" |
"DUAL" |
"EACH" |
"ELSE" |
"ELSEIF" |
"ENCLOSED" |
"END" |
"ESCAPED" |
"EXCEPTION" |
"EXISTS" |
"EXIT" |
"EXPLAIN" |
"FALSE" |
"FETCH" |
"FLOAT" |
"FLOAT4" |
"FLOAT8" |
"FOR" |
"FORCE" |
"FOREIGN" |
"FROM" |
"FUNCTION" |
"FULLTEXT" |
"GLOBAL TEMPORARY" |
"GRANT" |
"GROUP" |
"HAVING" |
"IF" |
"IGNORE" |
"IN" |
"INDEX" |
"INFILE" |
"INNER" |
"INOUT" |
"INSENSITIVE" |
"INSERT" |
"INT" |
"INTEGER" |
"INTERVAL" |
"INTO" |
"IS" |
"IS REF CURSOR" |
"ITERATE" |
"JOIN" |
"KEY" |
"KEYS" |
"KILL" |
"LEADING" |
"LEAVE" |
"LEFT" |
"LIKE" |
"LIMIT" |
"LINES" |
"LOAD" |
"LOCK" |
"LONG" |
"LOOP" |
"MATCH" |
"MERGE" |
"MINVALUE" |
"MAXVALUE" |
"MOD" |
"MODIFIES" |
"NATURAL" |
"NOCYCLE" |
"NOORDER" |
"NOT" |
"NULL" |
"NUMERIC" |
"NUMBER" |
"ON" |
"OPEN" |
"OPTIMIZE" |
"OPTION" |
"OPTIONALLY" |
"OR" |
"ORDER" |
"OTHERS" |
"OUT" |
"OUTER" |
"OUTFILE" |
"PACKAGE" |
"PACKAGE BODY" |
"PAGESIZE" |
"PLS_INTEGER" |
"PRAGMA" |
"PRECISION" |
"PRIMARY" |
"PROCEDURE" |
"PURGE" |
"RAISE" |
"READ" |
"READS" |
"REAL" |
"REFERENCES" |
"REGEXP" |
"RELEASE" |
"RENAME" |
"REPEAT" |
"REPLACE" |
"REQUIRE" |
"RESTRICT" |
"RETURN" |
"REVOKE" |
"RIGHT" |
"RLIKE" |
"ROLLBACK" |
"ROWCOUNT" |
"ROWTYPE" |
"SIZE" |
"SCHEMA" |
"SCHEMAS" |
"SELECT" |
"SENSITIVE" |
"SEPARATOR" |
"SEQUENCE" |
"SET" |
"SHOW" |
"SMALLINT" |
"SONAME" |
"SPATIAL" |
"SPECIFIC" |
"SQL" |
"SQLEXCEPTION" |
"SQLSTATE" |
"SQLWARNING" |
"STARTING" |
"SYSDATE" |
"TABLE" |
"TABLESPACE" |
"TERMINATED" |
"THEN" |
"TO" |
"TO_CHAR" |
"TO_DATE" |
"TRAILING" |
"TRIGGER" |
"TRUE" |
"TRUNCATE" |
"TYPE" |
"UNDO" |
"UNION" |
"UNIQUE" |
"UNLOCK" |
"UNSIGNED" |
"UPDATE" |
"USAGE" |
"USE" |
"USER" |
"USING" |
"VALUES" |
"VARBINARY" |
"VARCHAR" |
"VARCHAR2" |
"VARCHARACTER" |
"VARYING" |
"WHEN" |
"WHERE" |
"WHILE" |
"WITH" |
"WRITE" |
"XOR" |
"ZEROFILL"
%%
{
/* keywords */
{Reserved} { return token(TokenType.KEYWORD); }
/* operators */
"(" |
")" |
"{" |
"}" |
"[" |
"]" |
";" |
"," |
"." |
"@" |
"=" |
">" |
"<" |
"!" |
"~" |
"?" |
":" { return token(TokenType.OPERATOR); }
/* string literal */
\" {
yybegin(DQ_STRING);
tokenStart = yychar;
tokenLength = 1;
}
\' {
yybegin(SQ_STRING);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{FloatLiteral} { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace}+ { /* skip */ }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
}
{
{StringCharacter}+ { tokenLength += yylength(); }
\"\" { tokenLength += 2; }
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
}
{
{SingleCharacter}+ { tokenLength += yylength(); }
\'\' { tokenLength += 2; }
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
\' {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/xml.flex 0000644 0001750 0001750 00000013435 12127321547 027361 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class XmlLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public XmlLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte TAG_OPEN = 1;
private static final byte TAG_CLOSE = -1;
private static final byte INSTR_OPEN = 2;
private static final byte INSTR_CLOSE = -2;
private static final byte CDATA_OPEN = 3;
private static final byte CDATA_CLOSE = -3;
private static final byte COMMENT_OPEN = 4;
private static final byte COMMENT_CLOSE = -4;
%}
%xstate COMMENT, CDATA, TAG, INSTR
/* main character classes */
/* white space */
S = (\u0020 | \u0009 | \u000D | \u000A)+
/* characters */
Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF]
/* comments */
CommentStart = ""
NameStartChar = ":" | [A-Z] | "_" | [a-z]
NameStartCharUnicode = [\u00C0-\u00D6] |
[\u00D8-\u00F6] |
[\u00F8-\u02FF] |
[\u0370-\u037D] |
[\u037F-\u1FFF] |
[\u200C-\u200D] |
[\u2070-\u218F] |
[\u2C00-\u2FEF] |
[\u3001-\uD7FF] |
[\uF900-\uFDCF] |
[\uFDF0-\uFFFD] |
[\u10000-\uEFFFF]
NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7
NameCharUnicode = [\u0300-\u036F] | [\u0203F-\u2040]
Name = {NameStartChar} {NameChar}*
NameUnicode = ({NameStartChar}|{NameStartCharUnicode}) ({NameChar}|{NameCharUnicode})*
/* XML Processing Instructions */
InstrStart = "" {Name}
InstrEnd = "?>"
/* CDATA */
CDataStart = ""
/* Tags */
OpenTagStart = "<" {Name}
OpenTagClose = "/>"
OpenTagEnd = ">"
CloseTag = "" {Name} {S}* ">"
/* attribute */
Attribute = {Name} "="
/* string and character literals */
DQuoteStringChar = [^\r\n\"]
SQuoteStringChar = [^\r\n\']
%%
{
"&" [a-z]+ ";" |
"" [:digit:]+ ";" { return token(TokenType.KEYWORD2); }
{InstrStart} {
yybegin(INSTR);
return token(TokenType.TYPE2, INSTR_OPEN);
}
{OpenTagStart} {
yybegin(TAG);
return token(TokenType.TYPE, TAG_OPEN);
}
{CloseTag} { return token(TokenType.TYPE, TAG_CLOSE); }
{CommentStart} {
yybegin(COMMENT);
return token(TokenType.COMMENT2, COMMENT_OPEN);
}
{CDataStart} {
yybegin(CDATA);
return token(TokenType.COMMENT2, CDATA_OPEN);
}
}
{
{Attribute} { return token(TokenType.IDENTIFIER); }
\"{DQuoteStringChar}*\" |
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
{InstrEnd} {
yybegin(YYINITIAL);
return token(TokenType.TYPE2, INSTR_CLOSE);
}
}
{
{Attribute} { return token(TokenType.IDENTIFIER); }
\"{DQuoteStringChar}*\" |
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
{OpenTagClose} {
yybegin(YYINITIAL);
return token(TokenType.TYPE, TAG_CLOSE);
}
{OpenTagEnd} {
yybegin(YYINITIAL);
return token(TokenType.TYPE);
}
}
{
{CommentEnd} {
yybegin(YYINITIAL);
return token(TokenType.COMMENT2, COMMENT_CLOSE);
}
~{CommentEnd} {
yypushback(3);
return token(TokenType.COMMENT);
}
}
{
{CDataEnd} {
yybegin(YYINITIAL);
return token(TokenType.COMMENT2, CDATA_CLOSE);
}
~{CDataEnd} {
yypushback(3);
return token(TokenType.COMMENT);
}
}
{
/* error fallback */
.|\n { }
<> { return null; }
}
libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex 0000644 0001750 0001750 00000007677 12127321547 030363 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class DOSBatchLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%ignorecase
%state ECHO_TEXT
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public DOSBatchLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
%}
StartComment = "rem"
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
Comment = {StartComment} {InputCharacter}* {LineTerminator}?
%%
{
/* DOS keywords */
"@" |
"goto" |
"call" |
"exit" |
"if" |
"else" |
"for" |
"copy" |
"set" |
"dir" |
"cd" |
"set" |
"errorlevel" { return token(TokenType.KEYWORD); }
"%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); }
"%" [:digit:]+ { return token(TokenType.KEYWORD2); }
"echo" {
yybegin(ECHO_TEXT);
return token(TokenType.KEYWORD);
}
/* DOS commands */
"append" |
"assoc" |
"at" |
"attrib" |
"break" |
"cacls" |
"cd" |
"chcp" |
"chdir" |
"chkdsk" |
"chkntfs" |
"cls" |
"cmd" |
"color" |
"comp" |
"compact" |
"convert" |
"copy" |
"date" |
"del" |
"dir" |
"diskcomp" |
"diskcopy" |
"doskey" |
"exist" |
"endlocal" |
"erase" |
"fc" |
"find" |
"findstr" |
"format" |
"ftype" |
"graftabl" |
"help" |
"keyb" |
"label" |
"md" |
"mkdir" |
"mode" |
"more" |
"move" |
"path" |
"pause" |
"popd" |
"print" |
"prompt" |
"pushd" |
"rd" |
"recover" |
"rem" |
"ren" |
"rename" |
"replace" |
"restore" |
"rmdir" |
"set" |
"setlocal" |
"shift" |
"sort" |
"start" |
"subst" |
"time" |
"title" |
"tree" |
"type" |
"ver" |
"verify" |
"vol" |
"xcopy" { return token(TokenType.KEYWORD); }
[:jletterdigit:]+ { return token(TokenType.IDENTIFIER); }
/* labels */
":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE3); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
. | {LineTerminator} { /* skip */ }
}
{
"%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); }
"%" [:digit:]+ { return token(TokenType.KEYWORD2); }
. * { return token(TokenType.STRING); }
{LineTerminator} { yybegin(YYINITIAL) ; }
}
<> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/properties.flex 0000644 0001750 0001750 00000003042 12127321547 030746 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class PropertiesLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public PropertiesLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
%}
StartComment = #
WhiteSpace = [ \t]
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
KeyCharacter = [a-zA-Z0-9._ ]
%%
{
{KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); }
{StartComment} {InputCharacter}* {LineTerminator}?
{ return token(TokenType.COMMENT); }
. | {LineTerminator} { /* skip */ }
}
<> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/bash.flex 0000644 0001750 0001750 00000026734 12127321547 027504 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class BashLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public BashLexer() {
super();
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
private static final byte DO = 4;
private static final byte CASE = 5;
private static final byte IF = 5;
private static final byte INT_EXPR = 6;
@Override
public int yychar() {
return yychar;
}
%}
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
Identifier = [a-zA-Z][a-zA-Z0-9_]*
Comment = "#" {InputCharacter}* {LineTerminator}?
Shebang = "#!" {InputCharacter}* {LineTerminator}?
StringCharacter = [^\r\n\"\\]
SingleCharacter = [^\r\n\'\\]
BackQuoteChars = [^\r\n\`\\]
%%
{
/* Bash keywords */
"if" { return token(TokenType.KEYWORD, IF); }
"fi" { return token(TokenType.KEYWORD, -IF); }
"do" { return token(TokenType.KEYWORD, DO); }
"done" { return token(TokenType.KEYWORD, -DO); }
"case" { return token(TokenType.KEYWORD, CASE); }
"esac" { return token(TokenType.KEYWORD, -CASE); }
"$((" { return token(TokenType.KEYWORD, INT_EXPR); }
"))" { return token(TokenType.KEYWORD, -INT_EXPR); }
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
"-eq" |
"-ne" |
"-lt" |
"-gt" |
"-ge" |
"-le" |
">=" |
"<=" |
"==" |
"!=" |
"-z" |
"-n" |
"=~" |
"$" |
"#" |
"&" |
"." |
";" |
"+" |
"-" |
"=" |
"/" |
"++" |
"@" { return token(TokenType.OPERATOR); }
"then" |
"else" |
"elif" |
"for" |
"in" |
"until" |
"while" |
"break" |
"local" |
"continue" { return token(TokenType.KEYWORD); }
/* string literal */
\"{StringCharacter}+\" |
\'{SingleCharacter}+\ { return token(TokenType.STRING); }
\`{BackQuoteChars}+\` { return token(TokenType.STRING2); }
/* Other commands */
"alias" |
"apropos" |
"apt" |
"aspell" |
"awk" |
"bash" |
"basename" |
"bc" |
"bg" |
"builtin" |
"bzip2" |
"cal" |
"cat" |
"cd" |
"cfdisk" |
"chgrp" |
"chmod" |
"chown" |
"chroot" |
"chkconfig" |
"cksum" |
"clear" |
"cmp" |
"comm" |
"command" |
"continue" |
"cp" |
"cron" |
"crontab" |
"csplit" |
"cut" |
"date" |
"dc" |
"dd" |
"ddrescue" |
"declare" |
"df" |
"diff" |
"diff3" |
"dig" |
"dir" |
"dircolors" |
"dirname" |
"dirs" |
"dmesg" |
"du" |
"echo" |
"egrep" |
"eject" |
"enable" |
"env" |
"ethtool" |
"eval" |
"exec" |
"exit" |
"expect" |
"expand" |
"export" |
"expr" |
"false" |
"fdformat" |
"fdisk" |
"fg" |
"fgrep" |
"file" |
"find" |
"fmt" |
"fold" |
"format" |
"free" |
"fsck" |
"ftp" |
"function" |
"gawk" |
"getopts" |
"grep" |
"groups" |
"gzip" |
"hash" |
"head" |
"history" |
"hostname" |
"id" |
"ifconfig" |
"ifdown" |
"ifup" |
"import" |
"install" |
"join" |
"kill" |
"killall" |
"less" |
"let" |
"ln" |
"locate" |
"logname" |
"logout" |
"look" |
"lpc" |
"lpr" |
"lprint" |
"lprintd" |
"lprintq" |
"lprm" |
"ls" |
"lsof" |
"man" |
"mkdir" |
"mkfifo" |
"mkisofs" |
"mknod" |
"more" |
"mount" |
"mtools" |
"mv" |
"mmv" |
"netstat" |
"nice" |
"nl" |
"nohup" |
"nslookup" |
"open" |
"op" |
"passwd" |
"paste" |
"pathchk" |
"ping" |
"popd" |
"pr" |
"printcap" |
"printenv" |
"printf" |
"ps" |
"pushd" |
"pwd" |
"quota" |
"quotacheck" |
"quotactl" |
"ram" |
"rcp" |
"read" |
"readonly" |
"reboot" |
"renice" |
"remsync" |
"return" |
"rev" |
"rm" |
"rmdir" |
"rsync" |
"screen" |
"scp" |
"sdiff" |
"sed" |
"select" |
"seq" |
"set" |
"sftp" |
"shift" |
"shopt" |
"shutdown" |
"sleep" |
"slocate" |
"sort" |
"source" |
"split" |
"ssh" |
"strace" |
"su" |
"sudo" |
"sum" |
"symlink" |
"sync" |
"tail" |
"tar" |
"tee" |
"test" |
"time" |
"times" |
"touch" |
"top" |
"traceroute" |
"trap" |
"tr" |
"true" |
"tsort" |
"tty" |
"type" |
"ulimit" |
"umask" |
"umount" |
"unalias" |
"uname" |
"unexpand" |
"uniq" |
"units" |
"unset" |
"unshar" |
"useradd" |
"usermod" |
"users" |
"uuencode" |
"uudecode" |
"v" |
"vdir" |
"vi" |
"vmstat" |
"watch" |
"wc" |
"whereis" |
"which" |
"who" |
"whoami" |
"Wget" |
"write" |
"xargs" |
"yes" { return token(TokenType.KEYWORD); }
{Identifier} { return token(TokenType.IDENTIFIER); }
/* labels */
":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE); }
/* comments */
{Shebang} { return token(TokenType.COMMENT2); }
{Comment} { return token(TokenType.COMMENT); }
. | {LineTerminator} { /* skip */ }
}
<> { return null; } libjsyntaxpane-java-0.9.6~r156/src/main/jflex/jsyntaxpane/lexers/python.flex 0000644 0001750 0001750 00000030713 12127321547 030100 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.lexers;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
%%
%public
%class PythonLexer
%extends DefaultJFlexLexer
%final
%unicode
%char
%type Token
%{
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public PythonLexer() {
super();
}
@Override
public int yychar() {
return yychar;
}
private static final byte PARAN = 1;
private static final byte BRACKET = 2;
private static final byte CURLY = 3;
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
WhiteSpace = {LineTerminator} | [ \t\f]+
/* comments */
Comment = "#" {InputCharacter}* {LineTerminator}?
/* identifiers */
Identifier = [a-zA-Z][a-zA-Z0-9_]*
/* integer literals */
DecIntegerLiteral = 0 | [1-9][0-9]*
DecLongLiteral = {DecIntegerLiteral} [lL]
HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8}
HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL]
HexDigit = [0-9a-fA-F]
OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15}
OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL]
OctDigit = [0-7]
/* floating point literals */
FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF]
DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}?
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
/* string and character literals */
StringCharacter = [^\r\n\"\\]
SQStringCharacter = [^\r\n\'\\]
%state STRING, ML_STRING, SQSTRING, SQML_STRING
%%
{
/* keywords */
"and" |
"as" |
"assert" |
"break" |
"class" |
"continue" |
"def" |
"del" |
"elif" |
"else" |
"except" |
"exec" |
"finally" |
"for" |
"from" |
"global" |
"if" |
"import" |
"in" |
"is" |
"lambda" |
"not" |
"or" |
"pass" |
"print" |
"self" | /* not exactly keyword, but almost */
"raise" |
"return" |
"try" |
"while" |
"with" |
"yield" { return token(TokenType.KEYWORD); }
/* Built-in Types*/
"yield" |
"Ellipsis" |
"False" |
"None" |
"NotImplemented" |
"True" |
"__import__" |
"__name__" |
"abs" |
"apply" |
"bool" |
"buffer" |
"callable" |
"chr" |
"classmethod" |
"cmp" |
"coerce" |
"compile" |
"complex" |
"delattr" |
"dict" |
"dir" |
"divmod" |
"enumerate" |
"eval" |
"execfile" |
"file" |
"filter" |
"float" |
"frozenset" |
"getattr" |
"globals" |
"hasattr" |
"hash" |
"help" |
"hex" |
"id" |
"input" |
"int" |
"intern" |
"isinstance" |
"issubclass" |
"iter" |
"len" |
"list" |
"locals" |
"long" |
"map" |
"max" |
"min" |
"object" |
"oct" |
"open" |
"ord" |
"pow" |
"property" |
"range" |
"raw_input" |
"reduce" |
"reload" |
"repr" |
"reversed" |
"round" |
"set" |
"setattr" |
"slice" |
"sorted" |
"staticmethod" |
"str" |
"sum" |
"super" |
"tuple" |
"type" |
"unichr" |
"unicode" |
"vars" |
"xrange" |
"zip" { return token(TokenType.TYPE); }
/* operators */
"(" { return token(TokenType.OPERATOR, PARAN); }
")" { return token(TokenType.OPERATOR, -PARAN); }
"{" { return token(TokenType.OPERATOR, CURLY); }
"}" { return token(TokenType.OPERATOR, -CURLY); }
"[" { return token(TokenType.OPERATOR, BRACKET); }
"]" { return token(TokenType.OPERATOR, -BRACKET); }
"+" |
"-" |
"*" |
"**" |
"/" |
"//" |
"%" |
"<<" |
">>" |
"&" |
"|" |
"^" |
"~" |
"<" |
">" |
"<=" |
">=" |
"==" |
"!=" |
"<>" |
"@" |
"," |
":" |
"." |
"`" |
"=" |
";" |
"+=" |
"-=" |
"*=" |
"/=" |
"//=" |
"%=" |
"&=" |
"|=" |
"^=" |
">>=" |
"<<=" |
"**=" { return token(TokenType.OPERATOR); }
/* string literal */
\"{3} {
yybegin(ML_STRING);
tokenStart = yychar;
tokenLength = 3;
}
\" {
yybegin(STRING);
tokenStart = yychar;
tokenLength = 1;
}
\'{3} {
yybegin(SQML_STRING);
tokenStart = yychar;
tokenLength = 3;
}
\' {
yybegin(SQSTRING);
tokenStart = yychar;
tokenLength = 1;
}
/* numeric literals */
{DecIntegerLiteral} |
{DecLongLiteral} |
{HexIntegerLiteral} |
{HexLongLiteral} |
{OctIntegerLiteral} |
{OctLongLiteral} |
{FloatLiteral} |
{DoubleLiteral} |
{FloatLiteral}[jJ] { return token(TokenType.NUMBER); }
/* comments */
{Comment} { return token(TokenType.COMMENT); }
/* whitespace */
{WhiteSpace} { }
/* identifiers */
{Identifier} { return token(TokenType.IDENTIFIER); }
"$" | "?" { return token(TokenType.ERROR); }
}
{
\" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\"{3} {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 3);
}
{StringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
\" { tokenLength ++; }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { tokenLength ++; }
}
{
"'" {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 1);
}
{SQStringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { yybegin(YYINITIAL); }
}
{
\'{3} {
yybegin(YYINITIAL);
// length also includes the trailing quote
return token(TokenType.STRING, tokenStart, tokenLength + 3);
}
{SQStringCharacter}+ { tokenLength += yylength(); }
\\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); }
\' { tokenLength ++; }
/* escape sequences */
\\. { tokenLength += 2; }
{LineTerminator} { tokenLength ++; }
}
/* error fallback */
.|\n { }
<> { return null; }
libjsyntaxpane-java-0.9.6~r156/src/main/java/ 0000755 0001750 0001750 00000000000 12127321546 021635 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/ 0000755 0001750 0001750 00000000000 12127321546 024201 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/ 0000755 0001750 0001750 00000000000 12127321546 026366 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/LineNumbersRuler.java 0000644 0001750 0001750 00000023467 12127321546 032502 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.components;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BorderFactory;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import jsyntaxpane.SyntaxDocument;
import jsyntaxpane.SyntaxView;
import jsyntaxpane.actions.ActionUtils;
import jsyntaxpane.actions.gui.GotoLineDialog;
import jsyntaxpane.util.Configuration;
/**
* This class will display line numbers for a related text component. The text
* component must use the same line height for each line.
*
* This class was designed to be used as a component added to the row header
* of a JScrollPane.
*
* Original code from http://tips4java.wordpress.com/2009/05/23/text-component-line-number/
*
* @author Rob Camick
*
* Revised for jsyntaxpane
*
* @author Ayman Al-Sairafi
*/
public class LineNumbersRuler extends JPanel
implements CaretListener, DocumentListener, PropertyChangeListener, SyntaxComponent {
public static final String PROPERTY_BACKGROUND = "LineNumbers.Background";
public static final String PROPERTY_FOREGROUND = "LineNumbers.Foreground";
public static final String PROPERTY_CURRENT_BACK = "LineNumbers.CurrentBack";
public static final String PROPERTY_LEFT_MARGIN = "LineNumbers.LeftMargin";
public static final String PROPERTY_RIGHT_MARGIN = "LineNumbers.RightMargin";
public static final String PROPERTY_Y_OFFSET = "LineNumbers.YOFFset";
public static final int DEFAULT_R_MARGIN = 5;
public static final int DEFAULT_L_MARGIN = 5;
private Status status;
private final static int MAX_HEIGHT = Integer.MAX_VALUE - 1000000;
// Text component this TextTextLineNumber component is in sync with
private JEditorPane editor;
private int minimumDisplayDigits = 2;
// Keep history information to reduce the number of times the component
// needs to be repainted
private int lastDigits;
private int lastHeight;
private int lastLine;
private MouseListener mouseListener = null;
// The formatting to use for displaying numbers. Use in String.format(numbersFormat, line)
private String numbersFormat = "%3d";
private Color currentLineColor;
/**
* Get the JscrollPane that contains this EditorPane, or null if no
* JScrollPane is the parent of this editor
* @param editorPane
* @return
*/
public JScrollPane getScrollPane(JTextComponent editorPane) {
Container p = editorPane.getParent();
while (p != null) {
if (p instanceof JScrollPane) {
return (JScrollPane) p;
}
p = p.getParent();
}
return null;
}
@Override
public void config(Configuration config) {
int right = config.getInteger(PROPERTY_RIGHT_MARGIN, DEFAULT_R_MARGIN);
int left = config.getInteger(PROPERTY_LEFT_MARGIN, DEFAULT_L_MARGIN);
Color foreground = config.getColor(PROPERTY_FOREGROUND, Color.BLACK);
setForeground(foreground);
Color back = config.getColor(PROPERTY_BACKGROUND, Color.WHITE);
setBackground(back);
setBorder(BorderFactory.createEmptyBorder(0, left, 0, right));
currentLineColor = config.getColor(PROPERTY_CURRENT_BACK, back);
}
@Override
public void install(final JEditorPane editor) {
this.editor = editor;
setFont(editor.getFont());
// setMinimumDisplayDigits(3);
editor.getDocument().addDocumentListener(this);
editor.addCaretListener(this);
editor.addPropertyChangeListener(this);
JScrollPane sp = getScrollPane(editor);
sp.setRowHeaderView(this);
mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
GotoLineDialog.showForEditor(editor);
}
};
addMouseListener(mouseListener);
status = Status.INSTALLING;
documentChanged();
}
@Override
public void deinstall(JEditorPane editor) {
removeMouseListener(mouseListener);
status = Status.DEINSTALLING;
this.editor.getDocument().removeDocumentListener(this);
editor.removeCaretListener(this);
editor.removePropertyChangeListener(this);
JScrollPane sp = getScrollPane(editor);
if (sp != null) {
editor.getDocument().removeDocumentListener(this);
sp.setRowHeaderView(null);
}
}
/**
* Gets the minimum display digits
*
* @return the minimum display digits
*/
public int getMinimumDisplayDigits() {
return minimumDisplayDigits;
}
/**
* Specify the minimum number of digits used to calculate the preferred
* width of the component. Default is 3.
*
* @param minimumDisplayDigits the number digits used in the preferred
* width calculation
*/
public void setMinimumDisplayDigits(int minimumDisplayDigits) {
this.minimumDisplayDigits = minimumDisplayDigits;
setPreferredWidth();
}
/**
* Calculate the width needed to display the maximum line number
*/
private void setPreferredWidth() {
int lines = ActionUtils.getLineCount(editor);
int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits);
// Update sizes when number of digits in the line number changes
if (lastDigits != digits) {
lastDigits = digits;
numbersFormat = "%" + digits + "d";
FontMetrics fontMetrics = getFontMetrics(getFont());
int width = fontMetrics.charWidth('0') * digits;
Insets insets = getInsets();
int preferredWidth = insets.left + insets.right + width;
Dimension d = getPreferredSize();
d.setSize(preferredWidth, MAX_HEIGHT);
setPreferredSize(d);
setSize(d);
}
}
/**
* Draw the line numbers
*/
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
FontMetrics fontMetrics = editor.getFontMetrics(editor.getFont());
Insets insets = getInsets();
int currentLine = -1;
try {
// get current line, and add one as we start from 1 for the display
currentLine = ActionUtils.getLineNumber(editor, editor.getCaretPosition()) + 1;
} catch (BadLocationException ex) {
// this wont happen, even if it does, we can ignore it and we will not have
// a current line to worry about...
}
int lh = fontMetrics.getHeight();
int maxLines = ActionUtils.getLineCount(editor);
SyntaxView.setRenderingHits((Graphics2D) g);
int topLine = (int) (g.getClip().getBounds().getY() / lh) + 1;
int bottomLine = (int) (g.getClip().getBounds().getHeight()) + topLine;
for (int line = topLine; line <= bottomLine; line++) {
String lineNumber = String.format(numbersFormat, line);
int y = line * lh;
if (line == currentLine) {
g.setColor(currentLineColor);
g.fillRect(0, y - lh + fontMetrics.getDescent() - 1, getWidth(), lh);
g.setColor(getForeground());
g.drawString(lineNumber, insets.left, y);
} else {
g.drawString(lineNumber, insets.left, y);
}
}
}
//
// Implement CaretListener interface
//
@Override
public void caretUpdate(CaretEvent e) {
// Get the line the caret is positioned on
int caretPosition = editor.getCaretPosition();
Element root = editor.getDocument().getDefaultRootElement();
int currentLine = root.getElementIndex(caretPosition);
// Need to repaint so the correct line number can be highlighted
if (lastLine != currentLine) {
repaint();
lastLine = currentLine;
}
}
//
// Implement DocumentListener interface
//
@Override
public void changedUpdate(DocumentEvent e) {
documentChanged();
}
@Override
public void insertUpdate(DocumentEvent e) {
documentChanged();
}
@Override
public void removeUpdate(DocumentEvent e) {
documentChanged();
}
/*
* A document change may affect the number of displayed lines of text.
* Therefore the lines numbers will also change.
*/
private void documentChanged() {
// Preferred size of the component has not been updated at the time
// the DocumentEvent is fired
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
int preferredHeight = editor.getPreferredSize().height;
// Document change has caused a change in the number of lines.
// Repaint to reflect the new line numbers
if (lastHeight != preferredHeight) {
setPreferredWidth();
repaint();
lastHeight = preferredHeight;
}
}
});
}
/**
* Implement PropertyChangeListener interface
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("document")) {
if (evt.getOldValue() instanceof SyntaxDocument) {
SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getOldValue();
syntaxDocument.removeDocumentListener(this);
}
if (evt.getNewValue() instanceof SyntaxDocument && status.equals(Status.INSTALLING)) {
SyntaxDocument syntaxDocument = (SyntaxDocument) evt.getNewValue();
syntaxDocument.addDocumentListener(this);
setPreferredWidth();
repaint();
}
} else if (evt.getNewValue() instanceof Font) {
setPreferredWidth();
repaint();
}
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/SyntaxComponent.java 0000644 0001750 0001750 00000003172 12127321546 032405 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.components;
import javax.swing.JEditorPane;
import jsyntaxpane.util.Configuration;
/**
* A Component that is installed to the EditorKit to perform GUI operations
* on the Editor.
*
* @author Ayman Al-Sairafi
*/
public interface SyntaxComponent {
/**
* Configure the component using the given properties. The keys
* needed for configuration will be prefixed by the given prefix
* @param config configuration data
*/
public void config(Configuration config);
/**
* Called to install the component on an editor
* @param editor
*/
public void install(JEditorPane editor);
/**
* Called when the component is to be removed from the editor
* @param editor
*/
public void deinstall(JEditorPane editor);
/**
* The status is used to have proper propertyCHange support. We need to know if we are INSTALLING
* the component or DE-INSTALLING it
*/
static enum Status {
INSTALLING,
DEINSTALLING
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/Markers.java 0000644 0001750 0001750 00000011560 12127321546 030640 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.components;
import jsyntaxpane.actions.*;
import java.awt.Color;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import jsyntaxpane.SyntaxDocument;
import jsyntaxpane.Token;
/**
* This class contains static utility methods to make highliting in text
* components easier.
*
* @author Ayman Al-Sairafi
*/
public class Markers {
// This subclass is used in our highlighting code
public static class SimpleMarker extends DefaultHighlighter.DefaultHighlightPainter {
public SimpleMarker(Color color) {
super(color);
}
}
/**
* Removes only our private highlights
* This is public so that we can remove the highlights when the editorKit
* is unregistered. SimpleMarker can be null, in which case all instances of
* our Markers are removed.
* @param component the text component whose markers are to be removed
* @param marker the SimpleMarker to remove
*/
public static void removeMarkers(JTextComponent component, SimpleMarker marker) {
Highlighter hilite = component.getHighlighter();
Highlighter.Highlight[] hilites = hilite.getHighlights();
for (int i = 0; i < hilites.length; i++) {
if (hilites[i].getPainter() instanceof SimpleMarker) {
SimpleMarker hMarker = (SimpleMarker) hilites[i].getPainter();
if (marker == null || hMarker.equals(marker)) {
hilite.removeHighlight(hilites[i]);
}
}
}
}
/**
* Remove all the markers from an JEditorPane
* @param editorPane
*/
public static void removeMarkers(JTextComponent editorPane) {
removeMarkers(editorPane, null);
}
/**
* add highlights for the given Token on the given pane
* @param pane
* @param token
* @param marker
*/
public static void markToken(JTextComponent pane, Token token, SimpleMarker marker) {
markText(pane, token.start, token.end(), marker);
}
/**
* add highlights for the given region on the given pane
* @param pane
* @param start
* @param end
* @param marker
*/
public static void markText(JTextComponent pane, int start, int end, SimpleMarker marker) {
try {
Highlighter hiliter = pane.getHighlighter();
int selStart = pane.getSelectionStart();
int selEnd = pane.getSelectionEnd();
// if there is no selection or selection does not overlap
if(selStart == selEnd || end < selStart || start > selStart) {
hiliter.addHighlight(start, end, marker);
return;
}
// selection starts within the highlight, highlight before slection
if(selStart > start && selStart < end ) {
hiliter.addHighlight(start, selStart, marker);
}
// selection ends within the highlight, highlight remaining
if(selEnd > start && selEnd < end ) {
hiliter.addHighlight(selEnd, end, marker);
}
} catch (BadLocationException ex) {
// nothing we can do if the request is out of bound
LOG.log(Level.SEVERE, null, ex);
}
}
/**
* Mark all text in the document that matches the given pattern
* @param pane control to use
* @param pattern pattern to match
* @param marker marker to use for highlighting
*/
public static void markAll(JTextComponent pane, Pattern pattern, SimpleMarker marker) {
SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(pane);
if(sDoc == null || pattern == null) {
return;
}
Matcher matcher = sDoc.getMatcher(pattern);
// we may not have any matcher (due to undo or something, so don't do anything.
if(matcher==null) {
return;
}
while(matcher.find()) {
markText(pane, matcher.start(), matcher.end(), marker);
}
}
private static final Logger LOG = Logger.getLogger(Markers.class.getName());
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/PairsMarker.java 0000644 0001750 0001750 00000006027 12127321546 031456 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.components;
import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import jsyntaxpane.actions.*;
import javax.swing.JEditorPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.JTextComponent;
import jsyntaxpane.SyntaxDocument;
import jsyntaxpane.Token;
import jsyntaxpane.util.Configuration;
/**
* This class highlights any pairs of the given language. Pairs are defined
* with the Token.pairValue.
*
* @author Ayman Al-Sairafi
*/
public class PairsMarker implements CaretListener, SyntaxComponent, PropertyChangeListener {
public static final String PROPERTY_COLOR = "PairMarker.Color";
private JTextComponent pane;
private Markers.SimpleMarker marker;
private Status status;
public PairsMarker() {
}
@Override
public void caretUpdate(CaretEvent e) {
removeMarkers();
int pos = e.getDot();
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
Token token = doc.getTokenAt(pos);
if (token != null && token.pairValue != 0) {
Markers.markToken(pane, token, marker);
Token other = doc.getPairFor(token);
if (other != null) {
Markers.markToken(pane, other, marker);
}
}
}
/**
* Remove all the highlights from the editor pane. This should be called
* when the editorkit is removed.
*/
public void removeMarkers() {
Markers.removeMarkers(pane, marker);
}
@Override
public void config(Configuration config) {
Color markerColor = config.getColor(PROPERTY_COLOR, new Color(0xeeee33));
this.marker = new Markers.SimpleMarker(markerColor);
}
@Override
public void install(JEditorPane editor) {
pane = editor;
pane.addCaretListener(this);
status = Status.INSTALLING;
}
@Override
public void deinstall(JEditorPane editor) {
status = Status.DEINSTALLING;
pane.removeCaretListener(this);
removeMarkers();
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("document")) {
pane.removeCaretListener(this);
if (status.equals(Status.INSTALLING)) {
pane.addCaretListener(this);
removeMarkers();
}
}
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/components/TokenMarker.java 0000644 0001750 0001750 00000011330 12127321546 031451 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.components;
import java.beans.PropertyChangeEvent;
import jsyntaxpane.actions.*;
import java.awt.Color;
import java.beans.PropertyChangeListener;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import javax.swing.JEditorPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import jsyntaxpane.SyntaxDocument;
import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
import jsyntaxpane.util.Configuration;
/**
* This class highlights Tokens within a document whenever the caret is moved
* to a TokenType provided in the config file.
*
* @author Ayman Al-Sairafi
*/
public class TokenMarker implements SyntaxComponent, CaretListener, PropertyChangeListener {
public static final String DEFAULT_TOKENTYPES = "IDENTIFIER, TYPE, TYPE2, TYPE3";
public static final String PROPERTY_COLOR = "TokenMarker.Color";
public static final String PROPERTY_TOKENTYPES = "TokenMarker.TokenTypes";
private static final Color DEFAULT_COLOR = new Color(0xFFEE66);
private JEditorPane pane;
private Set tokenTypes = new HashSet();
private Markers.SimpleMarker marker;
private Status status;
/**
* Constructs a new Token highlighter
*/
public TokenMarker() {
}
@Override
public void caretUpdate(CaretEvent e) {
markTokenAt(e.getDot());
}
public void markTokenAt(int pos) {
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
if (doc != null) {
Token token = doc.getTokenAt(pos);
removeMarkers();
if (token != null && tokenTypes.contains(token.type)) {
addMarkers(token);
}
}
}
/**
* removes all markers from the pane.
*/
public void removeMarkers() {
Markers.removeMarkers(pane, marker);
}
/**
* add highlights for the given pattern
* @param pattern
*/
void addMarkers(Token tok) {
SyntaxDocument sDoc = (SyntaxDocument) pane.getDocument();
sDoc.readLock();
// we need to create a STring, because the CharSequence does not have an
// equals method and Object.equals is called. It will not match
String text = tok.getText(sDoc).toString();
Iterator it = sDoc.getTokens(0, sDoc.getLength());
while (it.hasNext()) {
Token nextToken = it.next();
String nextText = nextToken.getText(sDoc).toString();
if (text.equals(nextText)) {
Markers.markToken(pane, nextToken, marker);
}
}
sDoc.readUnlock();
}
@Override
public void config(Configuration config) {
Color markerColor = config.getColor(
PROPERTY_COLOR, DEFAULT_COLOR);
this.marker = new Markers.SimpleMarker(markerColor);
String types = config.getString(
PROPERTY_TOKENTYPES, DEFAULT_TOKENTYPES);
for (String type : types.split("\\s*,\\s*")) {
try {
TokenType tt = TokenType.valueOf(type);
tokenTypes.add(tt);
} catch (IllegalArgumentException e) {
LOG.warning("Error in setting up TokenMarker " +
" - Invalid TokenType: " + type);
}
}
}
@Override
public void install(JEditorPane editor) {
this.pane = editor;
pane.addCaretListener(this);
markTokenAt(editor.getCaretPosition());
status = Status.INSTALLING;
}
@Override
public void deinstall(JEditorPane editor) {
status = Status.DEINSTALLING;
removeMarkers();
pane.removeCaretListener(this);
}
private static final Logger LOG = Logger.getLogger(TokenMarker.class.getName());
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("document")) {
pane.removeCaretListener(this);
if (status.equals(Status.INSTALLING)) {
pane.addCaretListener(this);
removeMarkers();
}
}
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxStyles.java 0000644 0001750 0001750 00000011320 12127321546 027533 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import jsyntaxpane.util.Configuration;
import jsyntaxpane.util.JarServiceProvider;
/**
* The Styles to use for each TokenType. The defaults are created here, and
* then the resource META-INF/services/syntaxstyles.properties is read and
* merged. You can also pass a properties instance and merge your prefered
* styles into the default styles.
*
* Text is drawn by forwarding the drawText request to the SyntaxStyle for the
* that matches the given TokenType
*
* @author Ayman Al-Sairafi
*/
public class SyntaxStyles {
public static final Pattern STYLE_PATTERN = Pattern.compile("Style\\.(\\w+)");
/**
* You can call the mergeStyles method with a Properties file to customize
* the existing styles. Any existing styles will be overwritten by the
* styles you provide.
* @param styles
*/
public void mergeStyles(Properties styles) {
for (Map.Entry e : styles.entrySet()) {
String tokenType = e.getKey().toString();
String style = e.getValue().toString();
try {
TokenType tt = TokenType.valueOf(tokenType);
SyntaxStyle tokenStyle = new SyntaxStyle(style);
put(tt, tokenStyle);
} catch (IllegalArgumentException ex) {
LOG.warning("illegal token type or style for: " + tokenType);
}
}
}
Map styles;
private static SyntaxStyles instance = createInstance();
private static final Logger LOG = Logger.getLogger(SyntaxStyles.class.getName());
private static SyntaxStyle DEFAULT_STYLE = new SyntaxStyle(Color.BLACK, Font.PLAIN);
private SyntaxStyles() {
}
/**
* Create default styles
* @return
*/
private static SyntaxStyles createInstance() {
SyntaxStyles syntaxstyles = new SyntaxStyles();
Properties styles = JarServiceProvider.readProperties(SyntaxStyles.class);
syntaxstyles.mergeStyles(styles);
return syntaxstyles;
}
/**
* Returns the Default Singleton
* @return
*/
public static SyntaxStyles getInstance() {
return instance;
}
public static SyntaxStyles read(Configuration config) {
SyntaxStyles ss = createInstance();
// Configuration styleConf = config.subConfig(STYLE_PROPERTY_KEY);
for (Configuration.StringKeyMatcher m : config.getKeys(STYLE_PATTERN)) {
String type = m.group1;
try {
ss.put(TokenType.valueOf(type), new SyntaxStyle(m.value));
} catch (IllegalArgumentException e) {
Logger.getLogger(SyntaxStyles.class.getName()).warning(
String.format("Invalid Token Type [%s] for Style of ", type));
}
}
return ss;
}
public void put(TokenType type, SyntaxStyle style) {
if (styles == null) {
styles = new HashMap();
}
styles.put(type, style);
}
/**
* Return the style for the given TokenType
* @param type
* @return
*/
public SyntaxStyle getStyle(TokenType type) {
if (styles != null && styles.containsKey(type)) {
return styles.get(type);
} else {
return DEFAULT_STYLE;
}
}
/**
* Draw the given Token. This will simply find the proper SyntaxStyle for
* the TokenType and then asks the proper Style to draw the text of the
* Token.
* @param segment
* @param x
* @param y
* @param graphics
* @param e
* @param token
* @return
*/
public int drawText(Segment segment, int x, int y,
Graphics graphics, TabExpander e, Token token) {
SyntaxStyle s = getStyle(token.type);
return s.drawText(segment, x, y, graphics, e, token.start);
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/Lexer.java 0000644 0001750 0001750 00000002676 12127321546 026136 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane;
import java.util.List;
import javax.swing.text.Segment;
/**
* Lexers must implement these methods. These are used in the Tokenizer
*
* A Lexer should be tied to one document.
*
* @author Ayman Al-Sairafi
*/
public interface Lexer {
/**
* This is the only method a Lexer needs to implement. It will be passed
* a Reader, and it should return non-overlapping Tokens for each recognized token
* in the stream.
* @param segment Text to parse.
* @param ofst offset to add to start of each token (useful for nesting)
* @param tokens List of Tokens to be added. This is done so that the caller creates the
* appropriate List implementation and size. The parse method just adds to the list
*/
public void parse(Segment segment, int ofst, List tokens);
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/Token.java 0000644 0001750 0001750 00000011075 12127321546 026130 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Segment;
/**
* A Token in a Document. Tokens do NOT store a reference to the
* underlying SyntaxDocument, and must generally be obtained from
* the SyntaxDocument methods. The reason for not storing the
* SyntaxDocument is simply for memory, as the number of Tokens
* per document can be large, you may end up with twice the memory
* in a SyntaxDocument with Tokens than a simple PlainDocument.
*
* @author Ayman Al-Sairafi
*/
public class Token implements Serializable, Comparable {
public final TokenType type;
public final int start;
public final int length;
/**
* the pair value to use if this token is one of a pair:
* This is how it is used:
* The openning part will have a positive number X
* The closing part will have a negative number X
* X should be unique for a pair:
* e.g. for [ pairValue = +1
* for ] pairValue = -1
*/
public final byte pairValue;
/**
* The kind of the Document. This is only needed if proper Parsing
* of a document is needed and it makes certain operations faster.
* You can use any of the supplied Generic Values, or create your
* language specific uses by using USER_FIRST + x;
*/
public final short kind = 0;
/**
* Constructs a new token
* @param type
* @param start
* @param length
*/
public Token(TokenType type, int start, int length) {
this.type = type;
this.start = start;
this.length = length;
this.pairValue = 0;
}
/**
* Construct a new part of pair token
* @param type
* @param start
* @param length
* @param pairValue
*/
public Token(TokenType type, int start, int length, byte pairValue) {
this.type = type;
this.start = start;
this.length = length;
this.pairValue = pairValue;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Object) {
Token token = (Token) obj;
return ((this.start == token.start) &&
(this.length == token.length) &&
(this.type.equals(token.type)));
} else {
return false;
}
}
@Override
public int hashCode() {
return start;
}
@Override
public String toString() {
if (pairValue == 0) {
return String.format("%s (%d, %d)", type, start, length);
} else {
return String.format("%s (%d, %d) (%d)", type, start, length, pairValue);
}
}
@Override
public int compareTo(Object o) {
Token t = (Token) o;
if (this.start != t.start) {
return (this.start - t.start);
} else if (this.length != t.length) {
return (this.length - t.length);
} else {
return this.type.compareTo(t.type);
}
}
/**
* return the end position of the token.
* @return start + length
*/
public int end() {
return start + length;
}
/**
* Get the text of the token from this document
* @param doc
* @return
*/
public CharSequence getText(Document doc) {
Segment text = new Segment();
try {
doc.getText(start, length, text);
} catch (BadLocationException ex) {
Logger.getLogger(Token.class.getName()).log(Level.SEVERE, null, ex);
} finally {
return text;
}
}
public String getString(Document doc) {
String result = "";
try {
result = doc.getText(start, length);
} catch (BadLocationException ex) {
Logger.getLogger(Token.class.getName()).log(Level.SEVERE, null, ex);
} finally {
return result;
}
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/SyntaxTester.form 0000644 0001750 0001750 00000016032 12127321546 027545 0 ustar sylvestre sylvestre
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/DefaultSyntaxKit.java 0000644 0001750 0001750 00000054725 12127321546 030324 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane;
import java.awt.Color;
import java.awt.Container;
import java.util.logging.Level;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JEditorPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import jsyntaxpane.actions.DefaultSyntaxAction;
import jsyntaxpane.actions.SyntaxAction;
import jsyntaxpane.components.SyntaxComponent;
import jsyntaxpane.util.Configuration;
import jsyntaxpane.util.JarServiceProvider;
/**
* The DefaultSyntaxKit is the main entry to SyntaxPane. To use the package, just
* set the EditorKit of the EditorPane to a new instance of this class.
*
* You need to pass a proper lexer to the class.
*
* @author ayman
*/
public class DefaultSyntaxKit extends DefaultEditorKit implements ViewFactory {
public static final String CONFIG_CARETCOLOR = "CaretColor";
public static final String CONFIG_SELECTION = "SelectionColor";
public static final String CONFIG_COMPONENTS = "Components";
public static final String CONFIG_MENU = "PopupMenu";
public static final String CONFIG_TOOLBAR = "Toolbar";
public static final String CONFIG_TOOLBAR_ROLLOVER = "Toolbar.Buttons.Rollover";
public static final String CONFIG_TOOLBAR_BORDER = "Toolbar.Buttons.BorderPainted";
public static final String CONFIG_TOOLBAR_OPAQUE = "Toolbar.Buttons.Opaque";
public static final String CONFIG_TOOLBAR_BORDER_SIZE = "Toolbar.Buttons.BorderSize";
private static final Pattern ACTION_KEY_PATTERN = Pattern.compile("Action\\.((\\w|-)+)");
private static final Pattern DEFAULT_ACTION_PATTERN = Pattern.compile("(DefaultAction.((\\w|-)+)).*");
private static Font DEFAULT_FONT;
private static Set CONTENT_TYPES = new HashSet();
private static Boolean initialized = false;
private static Map abbrvs;
private static String MENU_MASK_STRING = "control ";
private Lexer lexer;
private static final Logger LOG = Logger.getLogger(DefaultSyntaxKit.class.getName());
private Map> editorComponents =
new WeakHashMap>();
private Map popupMenu =
new WeakHashMap();
/**
* Main Configuration of JSyntaxPane EditorKits
*/
private static Map, Configuration> CONFIGS;
static {
// we only need to initialize once.
if (!initialized) {
initKit();
}
int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
if(menuMask == KeyEvent.ALT_DOWN_MASK) {
MENU_MASK_STRING = "alt ";
}
}
private static final String ACTION_MENU_TEXT = "MenuText";
/**
* Create a new Kit for the given language
* @param lexer
*/
public DefaultSyntaxKit(Lexer lexer) {
super();
this.lexer = lexer;
}
/**
* Adds UI components to the pane
* @param editorPane
*/
public void addComponents(JEditorPane editorPane) {
// install the components to the editor:
String[] components = getConfig().getPropertyList(CONFIG_COMPONENTS);
for (String c : components) {
installComponent(editorPane, c);
}
}
/**
* Creates a SyntaxComponent of the the given classname and installs
* it on the pane
* @param pane
* @param classname
*/
public void installComponent(JEditorPane pane, String classname) {
try {
@SuppressWarnings(value = "unchecked")
Class compClass = Class.forName(classname);
SyntaxComponent comp = (SyntaxComponent) compClass.newInstance();
comp.config(getConfig());
comp.install(pane);
if (editorComponents.get(pane) == null) {
editorComponents.put(pane, new ArrayList());
}
editorComponents.get(pane).add(comp);
} catch (InstantiationException ex) {
LOG.log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
LOG.log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
LOG.log(Level.SEVERE, null, ex);
}
}
/**
* Find the SyntaxCOmponent with given classname that is installed
* on the given pane, then deinstalls and removes it fom the
* editorComponents list
* @param pane
* @param classname
*/
public void deinstallComponent(JEditorPane pane, String classname) {
for (SyntaxComponent c : editorComponents.get(pane)) {
if (c.getClass().getName().equals(classname)) {
c.deinstall(pane);
editorComponents.get(pane).remove(c);
break;
}
}
}
/**
* Checks if the component with given classname is installed on the
* pane.
* @param pane
* @param classname
* @return true if component is installed, false otherwise
*/
public boolean isComponentInstalled(JEditorPane pane, String classname) {
for (SyntaxComponent c : editorComponents.get(pane)) {
if (c.getClass().getName().equals(classname)) {
return true;
}
}
return false;
}
/**
* Toggles the component with given classname. If component is found
* and installed, then it is deinstalled. Otherwise a new one is
* installed
* @param pane
* @param classname
* @return true if component was installed, false if it was removed
*/
public boolean toggleComponent(JEditorPane pane, String classname) {
for (SyntaxComponent c : editorComponents.get(pane)) {
if (c.getClass().getName().equals(classname)) {
c.deinstall(pane);
editorComponents.get(pane).remove(c);
return false;
}
}
installComponent(pane, classname);
return true;
}
/**
* Adds a popup menu to the editorPane if needed.
*
* @param editorPane
*/
public void addPopupMenu(JEditorPane editorPane) {
String[] menuItems = getConfig().getPropertyList(CONFIG_MENU);
if (menuItems == null || menuItems.length == 0) {
return;
}
popupMenu.put(editorPane, new JPopupMenu());
JMenu stack = null;
for (String menuString : menuItems) {
// create the Popup menu
if (menuString.equals("-")) {
popupMenu.get(editorPane).addSeparator();
} else if (menuString.startsWith(">")) {
JMenu sub = new JMenu(menuString.substring(1));
popupMenu.get(editorPane).add(sub);
stack = sub;
} else if (menuString.startsWith("<")) {
Container parent = stack.getParent();
if (parent instanceof JMenu) {
JMenu jMenu = (JMenu) parent;
stack = jMenu;
} else {
stack = null;
}
} else {
Action action = editorPane.getActionMap().get(menuString);
if (action != null) {
JMenuItem menuItem;
if (action.getValue(Action.SELECTED_KEY) != null) {
menuItem = new JCheckBoxMenuItem(action);
} else {
menuItem = new JMenuItem(action);
}
// Use our own property if it was set for the menu text
if (action.getValue(ACTION_MENU_TEXT) != null) {
menuItem.setText((String) action.getValue(ACTION_MENU_TEXT));
}
if (stack == null) {
popupMenu.get(editorPane).add(menuItem);
} else {
stack.add(menuItem);
}
}
}
}
editorPane.setComponentPopupMenu(popupMenu.get(editorPane));
}
/**
* Add all pop-up menu items to a Toolbar. You need to call the validate method
* on the toolbar after this is done to layout the buttons.
* Only Actions which have a SMALL_ICON property will be added to the toolbar
* There are three Configuration Keys that affect the appearance of the added buttons:
* CONFIG_TOOLBAR_ROLLOVER, CONFIG_TOOLBAR_BORDER, CONFIG_TOOLBAR_OPAQUE
*
* @param editorPane
* @param toolbar
*/
public void addToolBarActions(JEditorPane editorPane, JToolBar toolbar) {
String[] toolBarItems = getConfig().getPropertyList(CONFIG_TOOLBAR);
if (toolBarItems == null || toolBarItems.length == 0) {
toolBarItems = getConfig().getPropertyList(CONFIG_MENU);
if (toolBarItems == null || toolBarItems.length == 0) {
return;
}
}
boolean btnRolloverEnabled = getConfig().getBoolean(CONFIG_TOOLBAR_ROLLOVER, true);
boolean btnBorderPainted = getConfig().getBoolean(CONFIG_TOOLBAR_BORDER, false);
boolean btnOpaque = getConfig().getBoolean(CONFIG_TOOLBAR_OPAQUE, false);
int btnBorderSize = getConfig().getInteger(CONFIG_TOOLBAR_BORDER_SIZE, 2);
for (String menuString : toolBarItems) {
if (menuString.equals("-") ||
menuString.startsWith("<") ||
menuString.startsWith(">")) {
toolbar.addSeparator();
} else {
Action action = editorPane.getActionMap().get(menuString);
if (action != null && action.getValue(Action.SMALL_ICON) != null) {
JButton b = toolbar.add(action);
b.setRolloverEnabled(btnRolloverEnabled);
b.setBorderPainted(btnBorderPainted);
b.setOpaque(btnOpaque);
b.setFocusable(false);
b.setBorder(BorderFactory.createEmptyBorder(btnBorderSize,
btnBorderSize, btnBorderSize, btnBorderSize));
}
}
}
}
@Override
public ViewFactory getViewFactory() {
return this;
}
@Override
public View create(Element element) {
return new SyntaxView(element, getConfig());
}
/**
* Install the View on the given EditorPane. This is called by Swing and
* can be used to do anything you need on the JEditorPane control. Here
* I set some default Actions.
*
* @param editorPane
*/
@Override
public void install(JEditorPane editorPane) {
super.install(editorPane);
// get our font
String fontName = getProperty("DefaultFont");
Font font = DEFAULT_FONT;
if (fontName != null) {
font = Font.decode(fontName);
}
editorPane.setFont(font);
Configuration conf = getConfig();
Color caretColor = conf.getColor(CONFIG_CARETCOLOR, Color.BLACK);
editorPane.setCaretColor(caretColor);
Color selectionColor = getConfig().getColor(CONFIG_SELECTION, new Color(0x99ccff));
editorPane.setSelectionColor(selectionColor);
addActions(editorPane);
addComponents(editorPane);
addPopupMenu(editorPane);
}
@Override
public void deinstall(JEditorPane editorPane) {
List l = editorComponents.get(editorPane);
for (SyntaxComponent c : editorComponents.get(editorPane)) {
c.deinstall(editorPane);
}
editorComponents.clear();
editorPane.getInputMap().clear();
editorPane.getActionMap().clear();
}
/**
* Add keyboard actions to this control using the Configuration we have
* This is revised to properly use InputMap and ActionMap of the component
* instead of using the KeyMaps directly.
* @param editorPane
*/
public void addActions(JEditorPane editorPane) {
InputMap imap = new InputMap();
imap.setParent(editorPane.getInputMap());
ActionMap amap = new ActionMap();
amap.setParent(editorPane.getActionMap());
for (Configuration.StringKeyMatcher m : getConfig().getKeys(ACTION_KEY_PATTERN)) {
String[] values = Configuration.COMMA_SEPARATOR.split(
m.value);
String actionClass = values[0];
String actionName = m.group1;
SyntaxAction action = createAction(actionClass);
// The configuration keys will need to be prefixed by Action
// to make it more readable in the Configuration files.
action.config(getConfig(), DefaultSyntaxAction.ACTION_PREFIX + actionName);
// Add the action to the component also
amap.put(actionName, action);
// Now bind all the keys to the Action we have using the InputMap
for (int i = 1; i < values.length; i++) {
String keyStrokeString = values[i].replace("menu ", MENU_MASK_STRING);
KeyStroke ks = KeyStroke.getKeyStroke(keyStrokeString);
// we may have more than onr value ( for key action ), but we will use the
// last one in the single value here. This will display the key in the
// popup menus. Pretty neat.
if (ks == null) {
throw new IllegalArgumentException("Invalid KeyStroke: " +
keyStrokeString);
}
action.putValue(Action.ACCELERATOR_KEY, ks);
imap.put(ks, actionName);
}
}
// Now configure the Default actions for better display in the popup menu
for (Configuration.StringKeyMatcher m : getConfig().getKeys(DEFAULT_ACTION_PATTERN)) {
String name = m.matcher.group(2);
Action action = editorPane.getActionMap().get(name);
if (action != null) {
configActionProperties(action, name, m.group1);
}
// The below commented block does find the keys for the default Actions
// using InputMap, however there are multiple bound keys for the
// default actions that displaying them in the menu will probably not
// be the most obvious binding
/*
for (KeyStroke key : imap.allKeys()) {
Object o = imap.get(key);
if(name.equals(o)) {
action.putValue(Action.ACCELERATOR_KEY, key);
break;
}
}
*/
}
editorPane.setActionMap(amap);
editorPane.setInputMap(JTextComponent.WHEN_FOCUSED, imap);
}
private void configActionProperties(Action action, String actionName, String configKey) {
// if we have an icon, then load it:
String iconLoc = getConfig().getString(configKey + ".SmallIcon", actionName + ".png");
URL loc = this.getClass().getResource(DefaultSyntaxAction.SMALL_ICONS_LOC_PREFIX + iconLoc);
if (loc != null) {
ImageIcon i = new ImageIcon(loc);
action.putValue(Action.SMALL_ICON, i);
}
// Set the menu text. Use the Action.NAME property, unless it is
// already set.
// The NAME would be set for default actions, and we should not change those names.
// so we will put another property and use it for the menu text
String name = getProperty(configKey + ".MenuText");
if (action.getValue(Action.NAME) == null) {
action.putValue(Action.NAME, name);
} else {
action.putValue(ACTION_MENU_TEXT, name);
}
// Set the menu tooltips
String shortDesc = getProperty(configKey + ".ToolTip");
if (shortDesc != null) {
action.putValue(Action.SHORT_DESCRIPTION, shortDesc);
} else {
action.putValue(Action.SHORT_DESCRIPTION, name);
}
}
private SyntaxAction createAction(String actionClassName) {
SyntaxAction action = null;
try {
Class clazz = Class.forName(actionClassName);
action = (SyntaxAction) clazz.newInstance();
} catch (InstantiationException ex) {
throw new IllegalArgumentException("Cannot create action class: " +
actionClassName + ". Ensure it has default constructor.", ex);
} catch (IllegalAccessException ex) {
throw new IllegalArgumentException("Cannot create action class: " +
actionClassName, ex);
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException("Cannot create action class: " +
actionClassName, ex);
} catch (ClassCastException ex) {
throw new IllegalArgumentException("Cannot create action class: " +
actionClassName, ex);
}
return action;
}
/**
* This is called by Swing to create a Document for the JEditorPane document
* This may be called before you actually get a reference to the control.
* We use it here to create a proper lexer and pass it to the
* SyntaxDcument we return.
* @return
*/
@Override
public Document createDefaultDocument() {
return new SyntaxDocument(lexer);
}
/**
* This is called to initialize the list of Lexer
s we have.
* You can call this at initialization, or it will be called when needed.
* The method will also add the appropriate EditorKit classes to the
* corresponding ContentType of the JEditorPane. After this is called,
* you can simply call the editor.setCOntentType("text/java") on the
* control and you will be done.
*/
public synchronized static void initKit() {
// attempt to find a suitable default font
String defaultFont = getConfig(DefaultSyntaxKit.class).getString("DefaultFont");
if (defaultFont != null) {
DEFAULT_FONT = Font.decode(defaultFont);
} else {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fonts = ge.getAvailableFontFamilyNames();
Arrays.sort(fonts);
if (Arrays.binarySearch(fonts, "Courier New") >= 0) {
DEFAULT_FONT = new Font("Courier New", Font.PLAIN, 12);
} else if (Arrays.binarySearch(fonts, "Courier") >= 0) {
DEFAULT_FONT = new Font("Courier", Font.PLAIN, 12);
} else if (Arrays.binarySearch(fonts, "Monospaced") >= 0) {
DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 13);
}
}
// read the Default Kits and their associated types
Properties kitsForTypes = JarServiceProvider.readProperties("jsyntaxpane/kitsfortypes");
for (Map.Entry e : kitsForTypes.entrySet()) {
String type = e.getKey().toString();
String classname = e.getValue().toString();
registerContentType(type, classname);
}
initialized = true;
}
/**
* Register the given content type to use the given class name as its kit
* When this is called, an entry is added into the private HashMap of the
* registered editors kits. This is needed so that the SyntaxPane library
* has it's own registration of all the EditorKits
* @param type
* @param classname
*/
public static void registerContentType(String type, String classname) {
try {
// ensure the class is available and that it does supply a no args
// constructor. This saves debugging later if the classname is incorrect
// or does not behave correctly:
Class c = Class.forName(classname);
// attempt to create the class, if we cannot with an empty argument
// then the class is invalid
Object kit = c.newInstance();
if (!(kit instanceof EditorKit)) {
throw new IllegalArgumentException("Cannot register class: " + classname +
". It does not extend EditorKit");
}
JEditorPane.registerEditorKitForContentType(type, classname);
CONTENT_TYPES.add(type);
} catch (InstantiationException ex) {
throw new IllegalArgumentException("Cannot register class: " + classname +
". Ensure it has Default Constructor.", ex);
} catch (IllegalAccessException ex) {
throw new IllegalArgumentException("Cannot register class: " + classname, ex);
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException("Cannot register class: " + classname, ex);
} catch (RuntimeException ex) {
throw new IllegalArgumentException("Cannot register class: " + classname, ex);
}
}
/**
* Return all the content types supported by this library. This will be the
* content types in the file WEB-INF/services/resources/jsyntaxpane/kitsfortypes
* @return sorted array of all registered content types
*/
public static String[] getContentTypes() {
String[] types = CONTENT_TYPES.toArray(new String[0]);
Arrays.sort(types);
return types;
}
/**
* Merges the given properties with the configurations for this Object
*
* @param config
*/
public void setConfig(Properties config) {
getConfig().putAll(config);
}
/**
* Sets the given property to the given value. If the kit is not
* initialized, then calls initKit
* @param key
* @param value
*/
public void setProperty(String key, String value) {
getConfig().put(key, value);
}
/**
* Return the property with the given key. If the kit is not
* initialized, then calls initKit
* Be careful when changing property as the default property may be used
* @param key
* @return value for given key
*/
public String getProperty(String key) {
return getConfig().getString(key);
}
/**
* Get the configuration for this Object
* @return
*/
public Configuration getConfig() {
return getConfig(this.getClass());
}
/**
* Return the Configurations object for a Kit. Perfrom lazy creation of a
* Configuration object if nothing is created.
*
* @param kit
* @return
*/
public static synchronized Configuration getConfig(Class extends DefaultSyntaxKit> kit) {
if (CONFIGS == null) {
CONFIGS = new WeakHashMap, Configuration>();
Configuration defaultConfig = new Configuration(DefaultSyntaxKit.class);
loadConfig(defaultConfig, DefaultSyntaxKit.class);
CONFIGS.put(DefaultSyntaxKit.class, defaultConfig);
}
if (CONFIGS.containsKey(kit)) {
return CONFIGS.get(kit);
} else {
// recursive call until we read the Super duper DefaultSyntaxKit
Class superKit = kit.getSuperclass();
@SuppressWarnings("unchecked")
Configuration defaults = getConfig(superKit);
Configuration mine = new Configuration(kit, defaults);
loadConfig(mine, kit);
CONFIGS.put(kit, mine);
return mine;
}
}
public Map getAbbreviations() {
// if we have not loaded the abbreviations, then load them now:
if (abbrvs == null) {
String cl = this.getClass().getName().replace('.', '/').toLowerCase();
abbrvs = JarServiceProvider.readStringsMap(cl + "/abbreviations.properties");
}
return abbrvs;
}
/**
* Adds an abbrevisation to this kit's abbreviations.
* @param abbr
* @param template
*/
public static void addAbbreviation(String abbr, String template) {
if (abbrvs == null) {
abbrvs = new HashMap();
}
abbrvs.put(abbr, template);
}
/**
* Get the template for the given abbreviation
* @param abbr
* @return
*/
public static String getAbbreviation(String abbr) {
return abbrvs == null ? null : abbrvs.get(abbr);
}
private static void loadConfig(Configuration conf, Class extends EditorKit> kit) {
String url = kit.getName().replace(".", "/") + "/config";
Properties p = JarServiceProvider.readProperties(url, Locale.getDefault());
if (p.size() == 0) {
LOG.log(Level.INFO, "unable to load configuration for: {0} from: {1}.properties",
new Object[]{kit, url});
} else {
conf.putAll(p);
}
}
@Override
public String getContentType() {
return "text/" + this.getClass().getSimpleName().replace("SyntaxKit", "").toLowerCase();
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/JavaRegexKit.java 0000644 0001750 0001750 00000001635 12127321546 027375 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane;
import java.io.IOException;
import jsyntaxpane.lexers.SimpleRegexLexer;
/**
*
* @author Ayman Al-Sairafi
*/
public class JavaRegexKit extends DefaultSyntaxKit {
public JavaRegexKit() throws IOException {
super(new SimpleRegexLexer("javaRegex.properties"));
}
} libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/ 0000755 0001750 0001750 00000000000 12127321546 025156 5 ustar sylvestre sylvestre libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/StringUtils.java 0000644 0001750 0001750 00000003664 12127321546 030321 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.util;
import java.io.Serializable;
import java.util.Comparator;
/**
* Don't we all need one of those?
*
* @author Ayman Al-Sairafi
*/
public class StringUtils {
/**
* Perfrom a String startsWith match with support for CamelCase.
* @param word full word
* @param abbr abbriviated word
* @return true if the word startsWith abbr, or if any uppercase char in abbr
* matches the next uppercase char in word
*
* FIXME: not so effecient as it creates a StringBuilder, but works
* FIXME: add {@code Comparator}
*/
public static boolean camelCaseMatch(String word, String abbr) {
StringBuilder sb = new StringBuilder();
sb.append(word.charAt(0));
for (int i = 1; i < word.length(); i++) {
char c = word.charAt(i);
if (Character.isUpperCase(c)) {
sb.append(c);
}
}
String cc = sb.toString();
if (cc.startsWith(abbr)) {
return true;
} else {
return word.startsWith(abbr);
}
}
static class CamelCaseCompare implements Comparator, Serializable {
@Override
public int compare(String o1, String o2) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/ReflectUtils.java 0000644 0001750 0001750 00000030372 12127321546 030433 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.util;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Reflection Utility methods
* @author Ayman Al-Sairafi
*/
public class ReflectUtils {
/**
* Adds all methods (from Class.getMethodCalls) to the list
* @param aClass
* @param list
* @return number of methods added
*/
public static int addMethods(Class aClass, List list) {
Method[] methods = aClass.getMethods();
for (Method m : methods) {
list.add(m);
}
return methods.length;
}
/**
* Adds all static methods (from Class.getMethodCalls) to the list
* @param aClass
* @param list
* @return number of methods added
*/
public static int addStaticMethods(Class aClass, List list) {
Method[] methods = aClass.getMethods();
for (Method m : methods) {
if (Modifier.isStatic(m.getModifiers())) {
list.add(m);
}
}
return methods.length;
}
/**
* Adds all static Fields (from Class.getFields) to the list
* @param aClass
* @param list
* @return number of fields added
*/
public static int addStaticFields(Class aClass, List list) {
Field[] fields = aClass.getFields();
for (Field f : fields) {
if (Modifier.isStatic(f.getModifiers())) {
list.add(f);
}
}
return fields.length;
}
/**
* Adds all Fields (from Class.getFields) to the list
* @param aClass
* @param list
* @return number of fields added
*/
public static int addFields(Class aClass, List list) {
Field[] fields = aClass.getFields();
for (Field f : fields) {
list.add(f);
}
return fields.length;
}
/**
* Adds all Constructor (from Class.getConstructorCalls) to the list
* @param aClass
* @param list
* @return number of constructors added
*/
public static int addConstrcutors(Class aClass, List list) {
Constructor[] constructors = aClass.getConstructors();
for (Constructor c : constructors) {
list.add(c);
}
return constructors.length;
}
/**
* Convert the constructor to a Java Code String
* (arguments are replaced by the simple types)
* @param c Constructor
* @return
*/
public static String getJavaCallString(Constructor c) {
StringBuilder call = new StringBuilder();
call.append(c.getDeclaringClass().getSimpleName());
addParamsString(call, c.getParameterTypes());
return call.toString();
}
/**
* Convert the Method to a Java Code String
* (arguments are replaced by the simple types)
* @param method Method
* @return
*/
public static String getJavaCallString(Method method) {
StringBuilder call = new StringBuilder();
call.append(method.getName());
addParamsString(call, method.getParameterTypes());
return call.toString();
}
/**
* Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the
* call StringBuffer
* @param call
* @param params
* @return
*/
public static StringBuilder addParamsString(StringBuilder call, Class[] params) {
call.append("(");
boolean firstArg = true;
for (Class arg : params) {
if (firstArg) {
firstArg = false;
} else {
call.append(", ");
}
call.append(arg.getSimpleName());
}
call.append(")");
return call;
}
/**
* Gets a String array of all method calls for the given class
* @param aClass
* @return
*/
public static String[] getMethodCalls(Class aClass) {
String[] methods = new String[aClass.getMethods().length];
int i = 0;
for (Method method : aClass.getMethods()) {
methods[i++] = getJavaCallString(method);
}
return methods;
}
/**
* Gets an array of all Constructor calls for the given class
* @param aClass
* @return
*/
public static String[] getConstructorCalls(Class aClass) {
Constructor[] constructors = aClass.getConstructors();
String[] cons = new String[constructors.length];
int i = 0;
for (Constructor c : constructors) {
cons[i++] = getJavaCallString(c);
}
return cons;
}
/**
* Return a paranthesis enclosed, comma sepearated String of all
* SimpleClass names in params.
* @param params
* @return
*/
public static String getParamsString(Class[] params) {
StringBuilder sb = new StringBuilder();
addParamsString(sb, params);
return sb.toString();
}
/**
* Scans all classes accessible from the context class loader which belong to the given package and subpackages.
*
* @param packageName The base package
* @return The classes
* @throws ClassNotFoundException
* @throws IOException
*/
private static Class[] getClasses(String packageName)
throws ClassNotFoundException, IOException {
// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
assert classLoader != null;
String path = packageName.replace('.', '/');
Enumeration resources = classLoader.getResources(path);
List dirs = new ArrayList();
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
dirs.add(new File(resource.getFile()));
}
ArrayList classes = new ArrayList();
for (File directory : dirs) {
classes.addAll(findClasses(directory, packageName));
}
return classes.toArray(new Class[classes.size()]);
}
/**
* Recursive method used to find all classes in a given directory and subdirs.
*
* @param directory The base directory
* @param packageName The package name for classes found inside the base directory
* @return The classes
* @throws ClassNotFoundException
*/
private static List findClasses(File directory, String packageName) throws ClassNotFoundException {
List classes = new ArrayList();
if (!directory.exists()) {
return classes;
}
File[] files = directory.listFiles();
for (File file : files) {
if (file.isDirectory()) {
assert !file.getName().contains(".");
classes.addAll(findClasses(file, packageName + "." + file.getName()));
} else if (file.getName().endsWith(".class")) {
classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
}
}
return classes;
}
/**
* Attempt to find the given className within any of the packages.
* If the class is not found, then null is returned
* @param className Fully or partially qualified classname within any of the packages
* @param packages List of packages for search
* @return CLass object or null if not found.
*/
public static Class findClass(String className, List packages) {
try {
return Class.forName(className);
} catch (ClassNotFoundException ex) {
} catch (NoClassDefFoundError ex) {
}
for (String pack : packages) {
try {
return Class.forName(pack + "." + className);
} catch (ClassNotFoundException ex) {
} catch (NoClassDefFoundError ex) {
}
}
return null;
}
/**
* Find a setter method for the give object's property and try to call it.
* No exceptions are thrown. You typically call this method because either
* you are sure no exceptions will be thrown, or to silently ignore
* any that may be thrown.
* This will also find a setter that accepts an interface that the value
* implements.
* This is still not very effcient and should only be called if
* performance is not of an issue.
* You can check the return value to see if the call was seuccessful or
* not.
* @param obj Object to receive the call
* @param property property name (without set. First letter will be
* capitalized)
* @param value Value of the property.
* @return
*/
public static boolean callSetter(Object obj, String property, Object value) {
String key = String.format("%s.%s(%s)", obj.getClass().getName(),
property, value.getClass().getName());
Method m = null;
boolean result = false;
if(!SETTERS_MAP.containsKey(key)) {
m = findMethod(obj, property, value);
SETTERS_MAP.put(key, m);
} else {
m = SETTERS_MAP.get(key);
}
if(m != null) {
try {
m.invoke(obj, value);
result = true;
} catch (IllegalAccessException ex) {
Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(ReflectUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
return result;
}
private static synchronized Method findMethod(Object obj,
String property, Object value) {
Method m = null;
Class> theClass = obj.getClass();
String setter = String.format("set%C%s",
property.charAt(0), property.substring(1));
Class paramType = value.getClass();
while (paramType != null) {
try {
m = theClass.getMethod(setter, paramType);
return m;
} catch (NoSuchMethodException ex) {
// try on the interfaces of this class
for (Class iface : paramType.getInterfaces()) {
try {
m = theClass.getMethod(setter, iface);
return m;
} catch (NoSuchMethodException ex1) {
}
}
paramType = paramType.getSuperclass();
}
}
return m;
}
public static final List DEFAULT_PACKAGES = new ArrayList(3);
static {
DEFAULT_PACKAGES.add("java.lang");
DEFAULT_PACKAGES.add("java.util");
DEFAULT_PACKAGES.add("jsyntaxpane");
}
/**
* To speed up find setter methods, this map will be used.
* The Key String will be of the format objectClass.property(valueclass)
* Where:
* objectClass = obj.getClass().getName
* property = property (as passed in to callSetter), before set is appended
* valueCLass = value.getClass().getName()
* The Method will be either the method, or null if a search was not and no
* method is found.
*/
private static HashMap SETTERS_MAP = new HashMap();
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/SwingUtils.java 0000644 0001750 0001750 00000003147 12127321546 030136 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.util;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import jsyntaxpane.actions.gui.EscapeListener;
/**
* As always, some general purpose handy Swing Utility methods
* @author Ayman Al-Sairafi
*/
public class SwingUtils {
/**
* FIXME: These two addEscapeListener can be called on a new interface
* that implements RootPainCOntainer (Swing) and a new method that
* is called
* @param dialog
*/
public static void addEscapeListener(final EscapeListener dialog) {
ActionListener escListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.escapePressed();
}
};
dialog.getRootPane().registerKeyboardAction(escListener,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
}
}
libjsyntaxpane-java-0.9.6~r156/src/main/java/jsyntaxpane/util/JarServiceProvider.java 0000644 0001750 0001750 00000022500 12127321546 031570 0 ustar sylvestre sylvestre /*
* Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License
* at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jsyntaxpane.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author subwiz
* @author Ayman Al-Sairafi
*/
public class JarServiceProvider {
public static final String SERVICES_ROOT = "META-INF/services/";
private static final Logger LOG = Logger.getLogger(JarServiceProvider.class.getName());
/**
* Prevent anyone from instantiating this class.
* Just use the static method
*/
private JarServiceProvider() {
}
private static ClassLoader getClassLoader() {
ClassLoader cl = JarServiceProvider.class.getClassLoader();
return cl == null ? ClassLoader.getSystemClassLoader() : cl;
}
/**
* Return an Object array from the file in META-INF/resources/{classname}
* @param cls
* @return
* @throws java.io.IOException
*/
public static List