mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 10:10:43 +00:00
Normalize all the line endings
This commit is contained in:
@@ -1,365 +1,365 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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\`\\]
|
||||
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL>
|
||||
{
|
||||
/* 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 */ }
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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\`\\]
|
||||
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL>
|
||||
{
|
||||
/* 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 */ }
|
||||
|
||||
}
|
||||
|
||||
<<EOF>> { return null; }
|
||||
@@ -1,496 +1,496 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,170 +1,170 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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}?
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
/* 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 */ }
|
||||
}
|
||||
|
||||
<ECHO_TEXT> {
|
||||
"%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); }
|
||||
|
||||
"%" [:digit:]+ { return token(TokenType.KEYWORD2); }
|
||||
|
||||
. * { return token(TokenType.STRING); }
|
||||
{LineTerminator} { yybegin(YYINITIAL) ; }
|
||||
}
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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}?
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
/* 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 */ }
|
||||
}
|
||||
|
||||
<ECHO_TEXT> {
|
||||
"%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); }
|
||||
|
||||
"%" [:digit:]+ { return token(TokenType.KEYWORD2); }
|
||||
|
||||
. * { return token(TokenType.STRING); }
|
||||
{LineTerminator} { yybegin(YYINITIAL) ; }
|
||||
}
|
||||
<<EOF>> { return null; }
|
||||
@@ -1,491 +1,491 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
|
||||
\" {
|
||||
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); }
|
||||
|
||||
}
|
||||
|
||||
<GSTRING_EXPR> {
|
||||
"}" {
|
||||
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 ++; }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
|
||||
\"{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(); }
|
||||
|
||||
}
|
||||
|
||||
<ML_STRING_EXPR> {
|
||||
"}" {
|
||||
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 ++; }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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);
|
||||
}
|
||||
}
|
||||
|
||||
<REGEX> {
|
||||
"/" {
|
||||
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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
|
||||
\" {
|
||||
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); }
|
||||
|
||||
}
|
||||
|
||||
<GSTRING_EXPR> {
|
||||
"}" {
|
||||
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 ++; }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
|
||||
\"{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(); }
|
||||
|
||||
}
|
||||
|
||||
<ML_STRING_EXPR> {
|
||||
"}" {
|
||||
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 ++; }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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);
|
||||
}
|
||||
}
|
||||
|
||||
<REGEX> {
|
||||
"/" {
|
||||
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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,376 +1,376 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,400 +1,400 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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 */
|
||||
"<<EOF>>" |
|
||||
"[: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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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 */
|
||||
"<<EOF>>" |
|
||||
"[: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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,298 +1,298 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<LONGSTRING> {
|
||||
{LongEnd} {
|
||||
if (longLen == yylength()) {
|
||||
tokenLength += yylength();
|
||||
yybegin(YYINITIAL);
|
||||
return token(longType, tokenStart, tokenLength);
|
||||
} else {
|
||||
tokenLength++;
|
||||
yypushback(yylength() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
{LineTerminator} { tokenLength += yylength(); }
|
||||
. { tokenLength++; }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(longType, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{LongStart} {
|
||||
longType = TokenType.COMMENT;
|
||||
yybegin(LONGSTRING);
|
||||
tokenLength += yylength();
|
||||
longLen = yylength();
|
||||
}
|
||||
|
||||
{LineTerminator} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
|
||||
. {
|
||||
yybegin(LINECOMMENT);
|
||||
tokenLength += yylength();
|
||||
}
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<LINECOMMENT> {
|
||||
{LineTerminator} {
|
||||
yybegin(YYINITIAL);
|
||||
tokenLength += yylength();
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
{LineTerminator} { tokenLength += yylength(); }
|
||||
. { tokenLength++; }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<STRING1> {
|
||||
\" {
|
||||
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); }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<STRING2> {
|
||||
\' {
|
||||
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); }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<LONGSTRING> {
|
||||
{LongEnd} {
|
||||
if (longLen == yylength()) {
|
||||
tokenLength += yylength();
|
||||
yybegin(YYINITIAL);
|
||||
return token(longType, tokenStart, tokenLength);
|
||||
} else {
|
||||
tokenLength++;
|
||||
yypushback(yylength() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
{LineTerminator} { tokenLength += yylength(); }
|
||||
. { tokenLength++; }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(longType, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{LongStart} {
|
||||
longType = TokenType.COMMENT;
|
||||
yybegin(LONGSTRING);
|
||||
tokenLength += yylength();
|
||||
longLen = yylength();
|
||||
}
|
||||
|
||||
{LineTerminator} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
|
||||
. {
|
||||
yybegin(LINECOMMENT);
|
||||
tokenLength += yylength();
|
||||
}
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<LINECOMMENT> {
|
||||
{LineTerminator} {
|
||||
yybegin(YYINITIAL);
|
||||
tokenLength += yylength();
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
{LineTerminator} { tokenLength += yylength(); }
|
||||
. { tokenLength++; }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<STRING1> {
|
||||
\" {
|
||||
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); }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
<STRING2> {
|
||||
\' {
|
||||
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); }
|
||||
<<EOF>> {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.STRING, tokenStart, tokenLength);
|
||||
}
|
||||
}
|
||||
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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._ ]
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL>
|
||||
{
|
||||
{KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); }
|
||||
{StartComment} {InputCharacter}* {LineTerminator}?
|
||||
{ return token(TokenType.COMMENT); }
|
||||
. | {LineTerminator} { /* skip */ }
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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._ ]
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL>
|
||||
{
|
||||
{KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); }
|
||||
{StartComment} {InputCharacter}* {LineTerminator}?
|
||||
{ return token(TokenType.COMMENT); }
|
||||
. | {LineTerminator} { /* skip */ }
|
||||
}
|
||||
|
||||
<<EOF>> { return null; }
|
||||
@@ -1,386 +1,386 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
\"{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 ++; }
|
||||
}
|
||||
|
||||
<SQSTRING> {
|
||||
"'" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<SQML_STRING> {
|
||||
\'{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
\"{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 ++; }
|
||||
}
|
||||
|
||||
<SQSTRING> {
|
||||
"'" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<SQML_STRING> {
|
||||
\'{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,276 +1,276 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
\"{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<ML_STRING> {
|
||||
\"{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,344 +1,344 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
}
|
||||
|
||||
|
||||
<STRING> {
|
||||
\" {
|
||||
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); }
|
||||
}
|
||||
|
||||
<CHARLITERAL> {
|
||||
\' {
|
||||
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); }
|
||||
}
|
||||
|
||||
<JDOC> {
|
||||
"*/" {
|
||||
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 ++; }
|
||||
|
||||
}
|
||||
|
||||
<JDOC_TAG> {
|
||||
([: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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,383 +1,383 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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"
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
|
||||
}
|
||||
|
||||
<DQ_STRING> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<SQ_STRING> {
|
||||
{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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"
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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); }
|
||||
|
||||
}
|
||||
|
||||
<DQ_STRING> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<SQ_STRING> {
|
||||
{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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,166 +1,166 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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\'\\]
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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\'\\]
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
/* 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 { }
|
||||
<<EOF>> { return null; }
|
||||
|
||||
|
||||
@@ -1,371 +1,371 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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 = "<!--"
|
||||
CommentEnd = "-->"
|
||||
|
||||
NameStartChar = ":" | [A-Z] | "_" | [a-z]
|
||||
NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7
|
||||
Name = {NameStartChar} {NameChar}*
|
||||
|
||||
/* XML Processing Instructions */
|
||||
InstrStart = "<?" {Name}
|
||||
InstrEnd = "?>"
|
||||
|
||||
DocTypeStart = "<!doctype"
|
||||
|
||||
/* CDATA */
|
||||
CDataStart = "<![CDATA["
|
||||
CDataEnd = "]]>"
|
||||
|
||||
/* 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\']
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
"&" [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);
|
||||
}
|
||||
}
|
||||
|
||||
<INSTR> {
|
||||
{Attribute} { return token(TokenType.IDENTIFIER); }
|
||||
|
||||
\"{DQuoteStringChar}*\" |
|
||||
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
|
||||
|
||||
{InstrEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<DOCTYPE> {
|
||||
[^>]* { }
|
||||
|
||||
{OpenTagEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<TAG> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{CommentEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, COMMENT_CLOSE);
|
||||
}
|
||||
~{CommentEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<CDATA> {
|
||||
{CDataEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, CDATA_CLOSE);
|
||||
}
|
||||
~{CDataEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<YYINITIAL,TAG,INSTR,CDATA,COMMENT> {
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
}
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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 = "<!--"
|
||||
CommentEnd = "-->"
|
||||
|
||||
NameStartChar = ":" | [A-Z] | "_" | [a-z]
|
||||
NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7
|
||||
Name = {NameStartChar} {NameChar}*
|
||||
|
||||
/* XML Processing Instructions */
|
||||
InstrStart = "<?" {Name}
|
||||
InstrEnd = "?>"
|
||||
|
||||
DocTypeStart = "<!doctype"
|
||||
|
||||
/* CDATA */
|
||||
CDataStart = "<![CDATA["
|
||||
CDataEnd = "]]>"
|
||||
|
||||
/* 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\']
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
"&" [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);
|
||||
}
|
||||
}
|
||||
|
||||
<INSTR> {
|
||||
{Attribute} { return token(TokenType.IDENTIFIER); }
|
||||
|
||||
\"{DQuoteStringChar}*\" |
|
||||
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
|
||||
|
||||
{InstrEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<DOCTYPE> {
|
||||
[^>]* { }
|
||||
|
||||
{OpenTagEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<TAG> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{CommentEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, COMMENT_CLOSE);
|
||||
}
|
||||
~{CommentEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<CDATA> {
|
||||
{CDataEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, CDATA_CLOSE);
|
||||
}
|
||||
~{CDataEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<YYINITIAL,TAG,INSTR,CDATA,COMMENT> {
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
}
|
||||
|
||||
@@ -1,196 +1,196 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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 = "<!--"
|
||||
CommentEnd = "-->"
|
||||
|
||||
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 = "<![CDATA["
|
||||
CDataEnd = "]]>"
|
||||
|
||||
/* Tags */
|
||||
OpenTagStart = "<" {Name}
|
||||
OpenTagClose = "/>"
|
||||
OpenTagEnd = ">"
|
||||
|
||||
CloseTag = "</" {Name} {S}* ">"
|
||||
|
||||
/* attribute */
|
||||
Attribute = {Name} "="
|
||||
|
||||
/* string and character literals */
|
||||
DQuoteStringChar = [^\r\n\"]
|
||||
SQuoteStringChar = [^\r\n\']
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
"&" [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);
|
||||
}
|
||||
}
|
||||
|
||||
<INSTR> {
|
||||
{Attribute} { return token(TokenType.IDENTIFIER); }
|
||||
|
||||
\"{DQuoteStringChar}*\" |
|
||||
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
|
||||
|
||||
{InstrEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<TAG> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{CommentEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, COMMENT_CLOSE);
|
||||
}
|
||||
~{CommentEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<CDATA> {
|
||||
{CDataEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, CDATA_CLOSE);
|
||||
}
|
||||
~{CDataEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<YYINITIAL,TAG,INSTR,CDATA,COMMENT> {
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
}
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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 = "<!--"
|
||||
CommentEnd = "-->"
|
||||
|
||||
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 = "<![CDATA["
|
||||
CDataEnd = "]]>"
|
||||
|
||||
/* Tags */
|
||||
OpenTagStart = "<" {Name}
|
||||
OpenTagClose = "/>"
|
||||
OpenTagEnd = ">"
|
||||
|
||||
CloseTag = "</" {Name} {S}* ">"
|
||||
|
||||
/* attribute */
|
||||
Attribute = {Name} "="
|
||||
|
||||
/* string and character literals */
|
||||
DQuoteStringChar = [^\r\n\"]
|
||||
SQuoteStringChar = [^\r\n\']
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
|
||||
"&" [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);
|
||||
}
|
||||
}
|
||||
|
||||
<INSTR> {
|
||||
{Attribute} { return token(TokenType.IDENTIFIER); }
|
||||
|
||||
\"{DQuoteStringChar}*\" |
|
||||
\'{SQuoteStringChar}*\' { return token(TokenType.STRING); }
|
||||
|
||||
{InstrEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.TYPE2, INSTR_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
<TAG> {
|
||||
{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);
|
||||
}
|
||||
}
|
||||
|
||||
<COMMENT> {
|
||||
{CommentEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, COMMENT_CLOSE);
|
||||
}
|
||||
~{CommentEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<CDATA> {
|
||||
{CDataEnd} {
|
||||
yybegin(YYINITIAL);
|
||||
return token(TokenType.COMMENT2, CDATA_CLOSE);
|
||||
}
|
||||
~{CDataEnd} {
|
||||
yypushback(3);
|
||||
return token(TokenType.COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
<YYINITIAL,TAG,INSTR,CDATA,COMMENT> {
|
||||
/* error fallback */
|
||||
.|\n { }
|
||||
<<EOF>> { return null; }
|
||||
}
|
||||
|
||||
@@ -1,266 +1,266 @@
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
{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 */ }
|
||||
}
|
||||
|
||||
<STRING_DOUBLE> {
|
||||
\" {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
[^\"] { tokenLength += yylength(); }
|
||||
}
|
||||
|
||||
<STRING_SINGLE> {
|
||||
\' {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
[^\'] { tokenLength += yylength(); }
|
||||
}
|
||||
/*
|
||||
* Copyright 2008 Ayman Al-Sairafi [email protected]
|
||||
*
|
||||
* 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
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {
|
||||
{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 */ }
|
||||
}
|
||||
|
||||
<STRING_DOUBLE> {
|
||||
\" {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
[^\"] { tokenLength += yylength(); }
|
||||
}
|
||||
|
||||
<STRING_SINGLE> {
|
||||
\' {
|
||||
yybegin(YYINITIAL);
|
||||
// length also includes the trailing quote
|
||||
return token(TokenType.STRING, tokenStart, tokenLength + 1);
|
||||
}
|
||||
|
||||
[^\'] { tokenLength += yylength(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user