From 07d4b7d906599d318341bf4715841887d2cef188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 12 Aug 2016 22:59:50 +0200 Subject: [PATCH] Normalize all the line endings --- .../main/jflex/jsyntaxpane/lexers/bash.flex | 728 ++++++------- .../jflex/jsyntaxpane/lexers/clojure.flex | 992 +++++++++--------- .../jflex/jsyntaxpane/lexers/dosbatch.flex | 338 +++--- .../main/jflex/jsyntaxpane/lexers/groovy.flex | 982 ++++++++--------- .../main/jflex/jsyntaxpane/lexers/java.flex | 752 ++++++------- .../main/jflex/jsyntaxpane/lexers/jflex.flex | 800 +++++++------- .../main/jflex/jsyntaxpane/lexers/lua.flex | 596 +++++------ .../jflex/jsyntaxpane/lexers/properties.flex | 124 +-- .../main/jflex/jsyntaxpane/lexers/python.flex | 772 +++++++------- .../main/jflex/jsyntaxpane/lexers/ruby.flex | 552 +++++----- .../main/jflex/jsyntaxpane/lexers/scala.flex | 688 ++++++------ .../main/jflex/jsyntaxpane/lexers/sql.flex | 766 +++++++------- .../main/jflex/jsyntaxpane/lexers/tal.flex | 332 +++--- .../main/jflex/jsyntaxpane/lexers/xhtml.flex | 742 ++++++------- .../main/jflex/jsyntaxpane/lexers/xml.flex | 392 +++---- .../main/jflex/jsyntaxpane/lexers/xpath.flex | 532 +++++----- src/com/jpexs/browsers/cache/CacheEntry.java | 222 ++-- .../cache/chrome/BlockFileHeader.java | 166 +-- .../browsers/cache/chrome/CacheAddr.java | 302 +++--- .../browsers/cache/chrome/EntryStore.java | 348 +++--- .../cache/chrome/HttpResponseInfo.java | 254 ++--- .../browsers/cache/chrome/IndexHeader.java | 152 +-- .../cache/chrome/IndexInputStream.java | 166 +-- .../jpexs/browsers/cache/chrome/LruData.java | 158 +-- .../browsers/cache/firefox/FirefoxCache.java | 334 +++--- .../browsers/cache/firefox/MapBucket.java | 264 ++--- .../browsers/cache/firefox/MetaData.java | 186 ++-- .../flash/console/ContextMenuTools.java | 470 ++++----- 28 files changed, 6555 insertions(+), 6555 deletions(-) diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/bash.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/bash.flex index 98e8d1791..d76031627 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/bash.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/bash.flex @@ -1,365 +1,365 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class BashLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public BashLexer() { - super(); - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - private static final byte DO = 4; - private static final byte CASE = 5; - private static final byte IF = 5; - private static final byte INT_EXPR = 6; - - @Override - public int yychar() { - return yychar; - } - -%} - -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -Identifier = [a-zA-Z][a-zA-Z0-9_]* - -Comment = "#" {InputCharacter}* {LineTerminator}? -Shebang = "#!" {InputCharacter}* {LineTerminator}? - -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] -BackQuoteChars = [^\r\n\`\\] - - -%% - - -{ - /* Bash keywords */ - "if" { return token(TokenType.KEYWORD, IF); } - "fi" { return token(TokenType.KEYWORD, -IF); } - "do" { return token(TokenType.KEYWORD, DO); } - "done" { return token(TokenType.KEYWORD, -DO); } - "case" { return token(TokenType.KEYWORD, CASE); } - "esac" { return token(TokenType.KEYWORD, -CASE); } - "$((" { return token(TokenType.KEYWORD, INT_EXPR); } - "))" { return token(TokenType.KEYWORD, -INT_EXPR); } - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - - "-eq" | - "-ne" | - "-lt" | - "-gt" | - "-ge" | - "-le" | - ">=" | - "<=" | - "==" | - "!=" | - "-z" | - "-n" | - "=~" | - - "$" | - "#" | - "&" | - "." | - ";" | - "+" | - "-" | - "=" | - "/" | - "++" | - "@" { return token(TokenType.OPERATOR); } - - "then" | - "else" | - "elif" | - "for" | - "in" | - "until" | - "while" | - "break" | - "local" | - "continue" { return token(TokenType.KEYWORD); } - - /* string literal */ - \"{StringCharacter}+\" | - - \'{SingleCharacter}+\ { return token(TokenType.STRING); } - - \`{BackQuoteChars}+\` { return token(TokenType.STRING2); } - - - /* Other commands */ - "alias" | - "apropos" | - "apt" | - "aspell" | - "awk" | - "bash" | - "basename" | - "bc" | - "bg" | - "builtin" | - "bzip2" | - "cal" | - "cat" | - "cd" | - "cfdisk" | - "chgrp" | - "chmod" | - "chown" | - "chroot" | - "chkconfig" | - "cksum" | - "clear" | - "cmp" | - "comm" | - "command" | - "continue" | - "cp" | - "cron" | - "crontab" | - "csplit" | - "cut" | - "date" | - "dc" | - "dd" | - "ddrescue" | - "declare" | - "df" | - "diff" | - "diff3" | - "dig" | - "dir" | - "dircolors" | - "dirname" | - "dirs" | - "dmesg" | - "du" | - "echo" | - "egrep" | - "eject" | - "enable" | - "env" | - "ethtool" | - "eval" | - "exec" | - "exit" | - "expect" | - "expand" | - "export" | - "expr" | - "false" | - "fdformat" | - "fdisk" | - "fg" | - "fgrep" | - "file" | - "find" | - "fmt" | - "fold" | - "format" | - "free" | - "fsck" | - "ftp" | - "function" | - "gawk" | - "getopts" | - "grep" | - "groups" | - "gzip" | - "hash" | - "head" | - "history" | - "hostname" | - "id" | - "ifconfig" | - "ifdown" | - "ifup" | - "import" | - "install" | - "join" | - "kill" | - "killall" | - "less" | - "let" | - "ln" | - "locate" | - "logname" | - "logout" | - "look" | - "lpc" | - "lpr" | - "lprint" | - "lprintd" | - "lprintq" | - "lprm" | - "ls" | - "lsof" | - "man" | - "mkdir" | - "mkfifo" | - "mkisofs" | - "mknod" | - "more" | - "mount" | - "mtools" | - "mv" | - "mmv" | - "netstat" | - "nice" | - "nl" | - "nohup" | - "nslookup" | - "open" | - "op" | - "passwd" | - "paste" | - "pathchk" | - "ping" | - "popd" | - "pr" | - "printcap" | - "printenv" | - "printf" | - "ps" | - "pushd" | - "pwd" | - "quota" | - "quotacheck" | - "quotactl" | - "ram" | - "rcp" | - "read" | - "readonly" | - "reboot" | - "renice" | - "remsync" | - "return" | - "rev" | - "rm" | - "rmdir" | - "rsync" | - "screen" | - "scp" | - "sdiff" | - "sed" | - "select" | - "seq" | - "set" | - "sftp" | - "shift" | - "shopt" | - "shutdown" | - "sleep" | - "slocate" | - "sort" | - "source" | - "split" | - "ssh" | - "strace" | - "su" | - "sudo" | - "sum" | - "symlink" | - "sync" | - "tail" | - "tar" | - "tee" | - "test" | - "time" | - "times" | - "touch" | - "top" | - "traceroute" | - "trap" | - "tr" | - "true" | - "tsort" | - "tty" | - "type" | - "ulimit" | - "umask" | - "umount" | - "unalias" | - "uname" | - "unexpand" | - "uniq" | - "units" | - "unset" | - "unshar" | - "useradd" | - "usermod" | - "users" | - "uuencode" | - "uudecode" | - "v" | - "vdir" | - "vi" | - "vmstat" | - "watch" | - "wc" | - "whereis" | - "which" | - "who" | - "whoami" | - "Wget" | - "write" | - "xargs" | - "yes" { return token(TokenType.KEYWORD); } - - {Identifier} { return token(TokenType.IDENTIFIER); } - - /* labels */ - ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE); } - - /* comments */ - {Shebang} { return token(TokenType.COMMENT2); } - {Comment} { return token(TokenType.COMMENT); } - . | {LineTerminator} { /* skip */ } - -} - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class BashLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public BashLexer() { + super(); + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte DO = 4; + private static final byte CASE = 5; + private static final byte IF = 5; + private static final byte INT_EXPR = 6; + + @Override + public int yychar() { + return yychar; + } + +%} + +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +Identifier = [a-zA-Z][a-zA-Z0-9_]* + +Comment = "#" {InputCharacter}* {LineTerminator}? +Shebang = "#!" {InputCharacter}* {LineTerminator}? + +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] +BackQuoteChars = [^\r\n\`\\] + + +%% + + +{ + /* Bash keywords */ + "if" { return token(TokenType.KEYWORD, IF); } + "fi" { return token(TokenType.KEYWORD, -IF); } + "do" { return token(TokenType.KEYWORD, DO); } + "done" { return token(TokenType.KEYWORD, -DO); } + "case" { return token(TokenType.KEYWORD, CASE); } + "esac" { return token(TokenType.KEYWORD, -CASE); } + "$((" { return token(TokenType.KEYWORD, INT_EXPR); } + "))" { return token(TokenType.KEYWORD, -INT_EXPR); } + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + "-eq" | + "-ne" | + "-lt" | + "-gt" | + "-ge" | + "-le" | + ">=" | + "<=" | + "==" | + "!=" | + "-z" | + "-n" | + "=~" | + + "$" | + "#" | + "&" | + "." | + ";" | + "+" | + "-" | + "=" | + "/" | + "++" | + "@" { return token(TokenType.OPERATOR); } + + "then" | + "else" | + "elif" | + "for" | + "in" | + "until" | + "while" | + "break" | + "local" | + "continue" { return token(TokenType.KEYWORD); } + + /* string literal */ + \"{StringCharacter}+\" | + + \'{SingleCharacter}+\ { return token(TokenType.STRING); } + + \`{BackQuoteChars}+\` { return token(TokenType.STRING2); } + + + /* Other commands */ + "alias" | + "apropos" | + "apt" | + "aspell" | + "awk" | + "bash" | + "basename" | + "bc" | + "bg" | + "builtin" | + "bzip2" | + "cal" | + "cat" | + "cd" | + "cfdisk" | + "chgrp" | + "chmod" | + "chown" | + "chroot" | + "chkconfig" | + "cksum" | + "clear" | + "cmp" | + "comm" | + "command" | + "continue" | + "cp" | + "cron" | + "crontab" | + "csplit" | + "cut" | + "date" | + "dc" | + "dd" | + "ddrescue" | + "declare" | + "df" | + "diff" | + "diff3" | + "dig" | + "dir" | + "dircolors" | + "dirname" | + "dirs" | + "dmesg" | + "du" | + "echo" | + "egrep" | + "eject" | + "enable" | + "env" | + "ethtool" | + "eval" | + "exec" | + "exit" | + "expect" | + "expand" | + "export" | + "expr" | + "false" | + "fdformat" | + "fdisk" | + "fg" | + "fgrep" | + "file" | + "find" | + "fmt" | + "fold" | + "format" | + "free" | + "fsck" | + "ftp" | + "function" | + "gawk" | + "getopts" | + "grep" | + "groups" | + "gzip" | + "hash" | + "head" | + "history" | + "hostname" | + "id" | + "ifconfig" | + "ifdown" | + "ifup" | + "import" | + "install" | + "join" | + "kill" | + "killall" | + "less" | + "let" | + "ln" | + "locate" | + "logname" | + "logout" | + "look" | + "lpc" | + "lpr" | + "lprint" | + "lprintd" | + "lprintq" | + "lprm" | + "ls" | + "lsof" | + "man" | + "mkdir" | + "mkfifo" | + "mkisofs" | + "mknod" | + "more" | + "mount" | + "mtools" | + "mv" | + "mmv" | + "netstat" | + "nice" | + "nl" | + "nohup" | + "nslookup" | + "open" | + "op" | + "passwd" | + "paste" | + "pathchk" | + "ping" | + "popd" | + "pr" | + "printcap" | + "printenv" | + "printf" | + "ps" | + "pushd" | + "pwd" | + "quota" | + "quotacheck" | + "quotactl" | + "ram" | + "rcp" | + "read" | + "readonly" | + "reboot" | + "renice" | + "remsync" | + "return" | + "rev" | + "rm" | + "rmdir" | + "rsync" | + "screen" | + "scp" | + "sdiff" | + "sed" | + "select" | + "seq" | + "set" | + "sftp" | + "shift" | + "shopt" | + "shutdown" | + "sleep" | + "slocate" | + "sort" | + "source" | + "split" | + "ssh" | + "strace" | + "su" | + "sudo" | + "sum" | + "symlink" | + "sync" | + "tail" | + "tar" | + "tee" | + "test" | + "time" | + "times" | + "touch" | + "top" | + "traceroute" | + "trap" | + "tr" | + "true" | + "tsort" | + "tty" | + "type" | + "ulimit" | + "umask" | + "umount" | + "unalias" | + "uname" | + "unexpand" | + "uniq" | + "units" | + "unset" | + "unshar" | + "useradd" | + "usermod" | + "users" | + "uuencode" | + "uudecode" | + "v" | + "vdir" | + "vi" | + "vmstat" | + "watch" | + "wc" | + "whereis" | + "which" | + "who" | + "whoami" | + "Wget" | + "write" | + "xargs" | + "yes" { return token(TokenType.KEYWORD); } + + {Identifier} { return token(TokenType.IDENTIFIER); } + + /* labels */ + ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE); } + + /* comments */ + {Shebang} { return token(TokenType.COMMENT2); } + {Comment} { return token(TokenType.COMMENT); } + . | {LineTerminator} { /* skip */ } + +} + <> { return null; } \ No newline at end of file diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/clojure.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/clojure.flex index 7b0216676..f3117c901 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/clojure.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/clojure.flex @@ -1,496 +1,496 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class ClojureLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public ClojureLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = {EndOfLineComment} - -EndOfLineComment = ";" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -%state STRING, CHARLITERAL - -%% - - { - - /* keywords */ - "fn" | - "fn*" | - "if" | - "def" | - "let" | - "let*" | - "loop*" | - "new" | - "nil" | - "recur" | - "loop" | - "do" | - "quote" | - "the-var" | - "identical?" | - "throw" | - "set!" | - "monitor-enter" | - "monitor-exit" | - "try" | - "catch" | - "finally" | - "in-ns" { return token(TokenType.KEYWORD); } - - /* Built-ins */ - "*agent*" | - "*command-line-args*" | - "*in*" | - "*macro-meta*" | - "*ns*" | - "*out*" | - "*print-meta*" | - "*print-readably*" | - "*proxy-classes*" | - "*warn-on-reflection*" | - "+" | - "-" | - "->" | - ".." | - "/" | - "<" | - "<=" | - "=" | - "==" | - ">" | - ">=" | - "accessor" | - "agent" | - "agent-errors" | - "aget" | - "alength" | - "all-ns" | - "alter" | - "and" | - "apply" | - "array-map" | - "aset" | - "aset-boolean" | - "aset-byte" | - "aset-char" | - "aset-double" | - "aset-float" | - "aset-int" | - "aset-long" | - "aset-short" | - "assert" | - "assoc" | - "await" | - "await-for" | - "bean" | - "binding" | - "bit-and" | - "bit-not" | - "bit-or" | - "bit-shift-left" | - "bit-shift-right" | - "bit-xor" | - "boolean" | - "butlast" | - "byte" | - "cast" | - "char" | - "class" | - "clear-agent-errors" | - "comment" | - "commute" | - "comp" | - "comparator" | - "complement" | - "concat" | - "cond" | - "conj" | - "cons" | - "constantly" | - "construct-proxy" | - "contains?" | - "count" | - "create-ns" | - "create-struct" | - "cycle" | - "dec" | - "defmacro" | - "defmethod" | - "defmulti" | - "defn" | - "defn-" | - "defstruct" | - "deref" | - "destructure" | - "disj" | - "dissoc" | - "distinct" | - "doall" | - "doc" | - "dorun" | - "doseq" | - "dosync" | - "dotimes" | - "doto" | - "double" | - "drop" | - "drop-while" | - "ensure" | - "eval" | - "every?" | - "false?" | - "ffirst" | - "file-seq" | - "filter" | - "find" | - "find-doc" | - "find-ns" | - "find-var" | - "first" | - "float" | - "flush" | - "fnseq" | - "for" | - "frest" | - "gensym" | - "gen-class" | - "gen-interface" | - "get" | - "get-proxy-class" | - "hash-map" | - "hash-set" | - "identity" | - "if-let" | - "import" | - "inc" | - "instance?" | - "int" | - "interleave" | - "into" | - "into-array" | - "iterate" | - "key" | - "keys" | - "keyword" | - "keyword?" | - "last" | - "lazy-cat" | - "lazy-cons" | - "line-seq" | - "list" | - "list*" | - "load" | - "load-file" | - "locking" | - "long" | - "macroexpand" | - "macroexpand-1" | - "make-array" | - "map" | - "map?" | - "mapcat" | - "max" | - "max-key" | - "memfn" | - "merge" | - "merge-with" | - "meta" | - "min" | - "min-key" | - "name" | - "namespace" | - "neg?" | - "newline" | - "nil?" | - "not" | - "not-any?" | - "not-every?" | - "not=" | - "ns-imports" | - "ns-interns" | - "ns-map" | - "ns-name" | - "ns-publics" | - "ns-refers" | - "ns-resolve" | - "ns-unmap" | - "nth" | - "nthrest" | - "or" | - "partial" | - "peek" | - "pmap" | - "pop" | - "pos?" | - "pr" | - "pr-str" | - "print" | - "print-doc" | - "print-str" | - "println" | - "println-str" | - "prn" | - "prn-str" | - "proxy" | - "proxy-mappings" | - "quot" | - "rand" | - "rand-int" | - "range" | - "re-find" | - "re-groups" | - "re-matcher" | - "re-matches" | - "re-pattern" | - "re-seq" | - "read" | - "read-line" | - "reduce" | - "ref" | - "ref-set" | - "refer" | - "rem" | - "remove-method" | - "remove-ns" | - "repeat" | - "replace" | - "replicate" | - "require" | - "resolve" | - "rest" | - "resultset-seq" | - "reverse" | - "rfirst" | - "rrest" | - "rseq" | - "scan" | - "second" | - "select-keys" | - "send" | - "send-off" | - "seq" | - "seq?" | - "set" | - "short" | - "slurp" | - "some" | - "sort" | - "sort-by" | - "sorted-map" | - "sorted-map-by" | - "sorted-set" | - "special-symbol?" | - "split-at" | - "split-with" | - "str" | - "string?" | - "struct" | - "struct-map" | - "subs" | - "subvec" | - "symbol" | - "symbol?" | - "sync" | - "take" | - "take-nth" | - "take-while" | - "test" | - "time" | - "to-array" | - "to-array-2d" | - "touch" | - "tree-seq" | - "true?" | - "update-proxy" | - "val" | - "vals" | - "var-get" | - "var-set" | - "var?" | - "vector" | - "vector?" | - "when" | - "when-first" | - "when-let" | - "when-not" | - "while" | - "with-local-vars" | - "with-meta" | - "with-open" | - "with-out-str" | - "xml-seq" | - "zero?" | - "zipmap" | - "repeatedly" | - "add-classpath" | - "vec" | - "hash" { return token(TokenType.KEYWORD2); } - - - /* operators */ - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - - /* string literal */ - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* character literal */ - \' { - yybegin(CHARLITERAL); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SingleCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class ClojureLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public ClojureLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {EndOfLineComment} + +EndOfLineComment = ";" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +%state STRING, CHARLITERAL + +%% + + { + + /* keywords */ + "fn" | + "fn*" | + "if" | + "def" | + "let" | + "let*" | + "loop*" | + "new" | + "nil" | + "recur" | + "loop" | + "do" | + "quote" | + "the-var" | + "identical?" | + "throw" | + "set!" | + "monitor-enter" | + "monitor-exit" | + "try" | + "catch" | + "finally" | + "in-ns" { return token(TokenType.KEYWORD); } + + /* Built-ins */ + "*agent*" | + "*command-line-args*" | + "*in*" | + "*macro-meta*" | + "*ns*" | + "*out*" | + "*print-meta*" | + "*print-readably*" | + "*proxy-classes*" | + "*warn-on-reflection*" | + "+" | + "-" | + "->" | + ".." | + "/" | + "<" | + "<=" | + "=" | + "==" | + ">" | + ">=" | + "accessor" | + "agent" | + "agent-errors" | + "aget" | + "alength" | + "all-ns" | + "alter" | + "and" | + "apply" | + "array-map" | + "aset" | + "aset-boolean" | + "aset-byte" | + "aset-char" | + "aset-double" | + "aset-float" | + "aset-int" | + "aset-long" | + "aset-short" | + "assert" | + "assoc" | + "await" | + "await-for" | + "bean" | + "binding" | + "bit-and" | + "bit-not" | + "bit-or" | + "bit-shift-left" | + "bit-shift-right" | + "bit-xor" | + "boolean" | + "butlast" | + "byte" | + "cast" | + "char" | + "class" | + "clear-agent-errors" | + "comment" | + "commute" | + "comp" | + "comparator" | + "complement" | + "concat" | + "cond" | + "conj" | + "cons" | + "constantly" | + "construct-proxy" | + "contains?" | + "count" | + "create-ns" | + "create-struct" | + "cycle" | + "dec" | + "defmacro" | + "defmethod" | + "defmulti" | + "defn" | + "defn-" | + "defstruct" | + "deref" | + "destructure" | + "disj" | + "dissoc" | + "distinct" | + "doall" | + "doc" | + "dorun" | + "doseq" | + "dosync" | + "dotimes" | + "doto" | + "double" | + "drop" | + "drop-while" | + "ensure" | + "eval" | + "every?" | + "false?" | + "ffirst" | + "file-seq" | + "filter" | + "find" | + "find-doc" | + "find-ns" | + "find-var" | + "first" | + "float" | + "flush" | + "fnseq" | + "for" | + "frest" | + "gensym" | + "gen-class" | + "gen-interface" | + "get" | + "get-proxy-class" | + "hash-map" | + "hash-set" | + "identity" | + "if-let" | + "import" | + "inc" | + "instance?" | + "int" | + "interleave" | + "into" | + "into-array" | + "iterate" | + "key" | + "keys" | + "keyword" | + "keyword?" | + "last" | + "lazy-cat" | + "lazy-cons" | + "line-seq" | + "list" | + "list*" | + "load" | + "load-file" | + "locking" | + "long" | + "macroexpand" | + "macroexpand-1" | + "make-array" | + "map" | + "map?" | + "mapcat" | + "max" | + "max-key" | + "memfn" | + "merge" | + "merge-with" | + "meta" | + "min" | + "min-key" | + "name" | + "namespace" | + "neg?" | + "newline" | + "nil?" | + "not" | + "not-any?" | + "not-every?" | + "not=" | + "ns-imports" | + "ns-interns" | + "ns-map" | + "ns-name" | + "ns-publics" | + "ns-refers" | + "ns-resolve" | + "ns-unmap" | + "nth" | + "nthrest" | + "or" | + "partial" | + "peek" | + "pmap" | + "pop" | + "pos?" | + "pr" | + "pr-str" | + "print" | + "print-doc" | + "print-str" | + "println" | + "println-str" | + "prn" | + "prn-str" | + "proxy" | + "proxy-mappings" | + "quot" | + "rand" | + "rand-int" | + "range" | + "re-find" | + "re-groups" | + "re-matcher" | + "re-matches" | + "re-pattern" | + "re-seq" | + "read" | + "read-line" | + "reduce" | + "ref" | + "ref-set" | + "refer" | + "rem" | + "remove-method" | + "remove-ns" | + "repeat" | + "replace" | + "replicate" | + "require" | + "resolve" | + "rest" | + "resultset-seq" | + "reverse" | + "rfirst" | + "rrest" | + "rseq" | + "scan" | + "second" | + "select-keys" | + "send" | + "send-off" | + "seq" | + "seq?" | + "set" | + "short" | + "slurp" | + "some" | + "sort" | + "sort-by" | + "sorted-map" | + "sorted-map-by" | + "sorted-set" | + "special-symbol?" | + "split-at" | + "split-with" | + "str" | + "string?" | + "struct" | + "struct-map" | + "subs" | + "subvec" | + "symbol" | + "symbol?" | + "sync" | + "take" | + "take-nth" | + "take-while" | + "test" | + "time" | + "to-array" | + "to-array-2d" | + "touch" | + "tree-seq" | + "true?" | + "update-proxy" | + "val" | + "vals" | + "var-get" | + "var-set" | + "var?" | + "vector" | + "vector?" | + "when" | + "when-first" | + "when-let" | + "when-not" | + "while" | + "with-local-vars" | + "with-meta" | + "with-open" | + "with-out-str" | + "xml-seq" | + "zero?" | + "zipmap" | + "repeatedly" | + "add-classpath" | + "vec" | + "hash" { return token(TokenType.KEYWORD2); } + + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + /* string literal */ + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* character literal */ + \' { + yybegin(CHARLITERAL); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SingleCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex index f733059ab..1b3893e10 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/dosbatch.flex @@ -1,170 +1,170 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class DOSBatchLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token -%ignorecase -%state ECHO_TEXT - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public DOSBatchLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } -%} - -StartComment = "rem" -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -Comment = {StartComment} {InputCharacter}* {LineTerminator}? - -%% - - { - /* DOS keywords */ - "@" | - "goto" | - "call" | - "exit" | - "if" | - "else" | - "for" | - "copy" | - "set" | - "dir" | - "cd" | - "set" | - "errorlevel" { return token(TokenType.KEYWORD); } - - "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } - - "%" [:digit:]+ { return token(TokenType.KEYWORD2); } - - "echo" { - yybegin(ECHO_TEXT); - return token(TokenType.KEYWORD); - } - - /* DOS commands */ - "append" | - "assoc" | - "at" | - "attrib" | - "break" | - "cacls" | - "cd" | - "chcp" | - "chdir" | - "chkdsk" | - "chkntfs" | - "cls" | - "cmd" | - "color" | - "comp" | - "compact" | - "convert" | - "copy" | - "date" | - "del" | - "dir" | - "diskcomp" | - "diskcopy" | - "doskey" | - "exist" | - "endlocal" | - "erase" | - "fc" | - "find" | - "findstr" | - "format" | - "ftype" | - "graftabl" | - "help" | - "keyb" | - "label" | - "md" | - "mkdir" | - "mode" | - "more" | - "move" | - "path" | - "pause" | - "popd" | - "print" | - "prompt" | - "pushd" | - "rd" | - "recover" | - "rem" | - "ren" | - "rename" | - "replace" | - "restore" | - "rmdir" | - "set" | - "setlocal" | - "shift" | - "sort" | - "start" | - "subst" | - "time" | - "title" | - "tree" | - "type" | - "ver" | - "verify" | - "vol" | - "xcopy" { return token(TokenType.KEYWORD); } - - [:jletterdigit:]+ { return token(TokenType.IDENTIFIER); } - - /* labels */ - ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE3); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - . | {LineTerminator} { /* skip */ } -} - - { - "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } - - "%" [:digit:]+ { return token(TokenType.KEYWORD2); } - - . * { return token(TokenType.STRING); } - {LineTerminator} { yybegin(YYINITIAL) ; } -} +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class DOSBatchLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token +%ignorecase +%state ECHO_TEXT + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public DOSBatchLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } +%} + +StartComment = "rem" +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +Comment = {StartComment} {InputCharacter}* {LineTerminator}? + +%% + + { + /* DOS keywords */ + "@" | + "goto" | + "call" | + "exit" | + "if" | + "else" | + "for" | + "copy" | + "set" | + "dir" | + "cd" | + "set" | + "errorlevel" { return token(TokenType.KEYWORD); } + + "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } + + "%" [:digit:]+ { return token(TokenType.KEYWORD2); } + + "echo" { + yybegin(ECHO_TEXT); + return token(TokenType.KEYWORD); + } + + /* DOS commands */ + "append" | + "assoc" | + "at" | + "attrib" | + "break" | + "cacls" | + "cd" | + "chcp" | + "chdir" | + "chkdsk" | + "chkntfs" | + "cls" | + "cmd" | + "color" | + "comp" | + "compact" | + "convert" | + "copy" | + "date" | + "del" | + "dir" | + "diskcomp" | + "diskcopy" | + "doskey" | + "exist" | + "endlocal" | + "erase" | + "fc" | + "find" | + "findstr" | + "format" | + "ftype" | + "graftabl" | + "help" | + "keyb" | + "label" | + "md" | + "mkdir" | + "mode" | + "more" | + "move" | + "path" | + "pause" | + "popd" | + "print" | + "prompt" | + "pushd" | + "rd" | + "recover" | + "rem" | + "ren" | + "rename" | + "replace" | + "restore" | + "rmdir" | + "set" | + "setlocal" | + "shift" | + "sort" | + "start" | + "subst" | + "time" | + "title" | + "tree" | + "type" | + "ver" | + "verify" | + "vol" | + "xcopy" { return token(TokenType.KEYWORD); } + + [:jletterdigit:]+ { return token(TokenType.IDENTIFIER); } + + /* labels */ + ":" [a-zA-Z][a-zA-Z0-9_]* { return token(TokenType.TYPE3); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + . | {LineTerminator} { /* skip */ } +} + + { + "%" [:jletter:] [:jletterdigit:]* "%" { return token(TokenType.STRING2); } + + "%" [:digit:]+ { return token(TokenType.KEYWORD2); } + + . * { return token(TokenType.STRING); } + {LineTerminator} { yybegin(YYINITIAL) ; } +} <> { return null; } \ No newline at end of file diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/groovy.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/groovy.flex index 3560a120d..ccb52a08a 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/groovy.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/groovy.flex @@ -1,491 +1,491 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class GroovyLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Default constructor is needed as we will always call the yyreset - */ - public GroovyLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f] - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} - -TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" -EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* Groovy and generally Java types have first UpperCase Letter */ -// Type = [:uppercase:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\\$] -SingleCharacter = [^\r\n\'\\] -RegexCharacter = [^\r\n\/] - -%state STRING, CHARLITERAL, REGEX, GSTRING_EXPR, CHARLITERAL, JDOC, JDOC_TAG -%state ML_STRING, ML_STRING_EXPR - -%% - - { - - /* keywords */ - "abstract" | - "boolean" | - "break" | - "byte" | - "case" | - "catch" | - "char" | - "class" | - "const" | - "continue" | - "do" | - "double" | - "enum" | - "else" | - "extends" | - "final" | - "finally" | - "float" | - "for" | - "default" | - "implements" | - "import" | - "instanceof" | - "int" | - "interface" | - "long" | - "native" | - "new" | - "goto" | - "if" | - "public" | - "short" | - "super" | - "switch" | - "synchronized" | - "package" | - "private" | - "protected" | - "transient" | - "return" | - "void" | - "static" | - "while" | - "this" | - "throw" | - "throws" | - "try" | - "volatile" | - "strictfp" | - - /* Groovy reserved words not in Java */ - "as" | - "asssert" | - "def" | - "in" | - "threadsafe" | - - /* Booleans and null */ - "true" | - "false" | - "null" { return token(TokenType.KEYWORD); } - - - /* Builtin Types and Object Wrappers */ - "Boolean" | - "Byte" | - "Character" | - "Double" | - "Float" | - "Integer" | - "Object" | - "Short" | - "String" | - "Void" | - "Class" | - "Number" | - "Package" | - "StringBuffer" | - "StringBuilder" | - "CharSequence" | - "Thread" | - "Regex" { return token(TokenType.TYPE); } - - /* Some Java standard Library Types */ - "Throwable" | - "Cloneable" | - "Comparable" | - "Serializable" | - "Runnable" { return token(TokenType.TYPE); } - - /* Groovy commonly used methods */ - "print" | - "println" { return token(TokenType.KEYWORD); } - - /* Frequently used Standard Exceptions */ - "ArithmeticException" | - "ArrayIndexOutOfBoundsException" | - "ClassCastException" | - "ClassNotFoundException" | - "CloneNotSupportedException" | - "Exception" | - "IllegalAccessException" | - "IllegalArgumentException" | - "IllegalStateException" | - "IllegalThreadStateException" | - "IndexOutOfBoundsException" | - "InstantiationException" | - "InterruptedException" | - "NegativeArraySizeException" | - "NoSuchFieldException" | - "NoSuchMethodException" | - "NullPointerException" | - "NumberFormatException" | - "RuntimeException" | - "SecurityException" | - "StringIndexOutOfBoundsException" | - "UnsupportedOperationException" { return token(TokenType.TYPE2); } - - /* operators */ - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - - ";" | - "," | - "." | - "@" | - "=" | - ">" | - "<" | - "!" | - "~" | - "?" | - ":" | - "==" | - "<=" | - ">=" | - "!=" | - "&&" | - "||" | - "++" | - "--" | - "+" | - "-" | - "*" | - "/" | - "&" | - "|" | - "^" | - "%" | - "<<" | - ">>" | - ">>>" | - "+=" | - "-=" | - "*=" | - "/=" | - "&=" | - "|=" | - "^=" | - "%=" | - "<<=" | - ">>=" | - ">>>=" { return token(TokenType.OPERATOR); } - - "~=" | - "?." { return token(TokenType.OPERATOR); } - - /* string literal */ - \"{3} { - yybegin(ML_STRING); - tokenStart = yychar; - tokenLength = 3; - } - - /* string literal */ - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* character literal */ - \' { - yybegin(CHARLITERAL); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } - - // JavaDoc comments need a state so that we can highlight the @ controls - "/**" { - yybegin(JDOC); - tokenStart = yychar; - tokenLength = 3; - } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace}+ { /* skip */ } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } - - /* - Groovy Regex -- state cannot be easily used here due to / by itself being - a valid operator. So if we flip into the REGEX state, we cannot distinguish - a regular / - */ - "/" [^*] {RegexCharacter}+ "/" { return token(TokenType.REGEX); } - -} - - - { - - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - "${" { - yybegin(GSTRING_EXPR); - // length also includes the trailing quote - int s = tokenStart; - int l = tokenLength; - tokenStart = yychar; - tokenLength = 2; - return token(TokenType.STRING, s, l); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } - -} - - { - "}" { - yybegin(STRING); - // length also includes the trailing quote - int s = tokenStart; - int l = tokenLength + 1; - tokenStart = yychar + 1; - tokenLength = 0; - return token(TokenType.STRING2, s, l); - } - - {StringCharacter} { tokenLength ++; } -} - - { - - \"{3} { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 3); - } - - "${" { - yybegin(ML_STRING_EXPR); - // length also includes the trailing quote - int s = tokenStart; - int l = tokenLength; - tokenStart = yychar; - tokenLength = 2; - return token(TokenType.STRING, s, l); - } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - .|{LineTerminator} { tokenLength += yylength(); } - -} - - { - "}" { - yybegin(ML_STRING); - // length also includes the trailing quote - int s = tokenStart; - int l = tokenLength + 1; - tokenStart = yychar + 1; - tokenLength = 0; - return token(TokenType.STRING2, s, l); - } - - .|\n|\r { tokenLength ++; } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SingleCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - "@" { - yybegin(JDOC_TAG); - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT, start, len); - } - - .|\n { tokenLength ++; } - -} - - { - ([:letter:])+ ":"? { tokenLength += yylength(); } - - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - .|\n { - yybegin(JDOC); - // length also includes the trailing quote - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT2, start, len); - } -} - - { - "/" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.REGEX, tokenStart, tokenLength + 1); - } - - {RegexCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class GroovyLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Default constructor is needed as we will always call the yyreset + */ + public GroovyLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f] + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* Groovy and generally Java types have first UpperCase Letter */ +// Type = [:uppercase:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\\$] +SingleCharacter = [^\r\n\'\\] +RegexCharacter = [^\r\n\/] + +%state STRING, CHARLITERAL, REGEX, GSTRING_EXPR, CHARLITERAL, JDOC, JDOC_TAG +%state ML_STRING, ML_STRING_EXPR + +%% + + { + + /* keywords */ + "abstract" | + "boolean" | + "break" | + "byte" | + "case" | + "catch" | + "char" | + "class" | + "const" | + "continue" | + "do" | + "double" | + "enum" | + "else" | + "extends" | + "final" | + "finally" | + "float" | + "for" | + "default" | + "implements" | + "import" | + "instanceof" | + "int" | + "interface" | + "long" | + "native" | + "new" | + "goto" | + "if" | + "public" | + "short" | + "super" | + "switch" | + "synchronized" | + "package" | + "private" | + "protected" | + "transient" | + "return" | + "void" | + "static" | + "while" | + "this" | + "throw" | + "throws" | + "try" | + "volatile" | + "strictfp" | + + /* Groovy reserved words not in Java */ + "as" | + "asssert" | + "def" | + "in" | + "threadsafe" | + + /* Booleans and null */ + "true" | + "false" | + "null" { return token(TokenType.KEYWORD); } + + + /* Builtin Types and Object Wrappers */ + "Boolean" | + "Byte" | + "Character" | + "Double" | + "Float" | + "Integer" | + "Object" | + "Short" | + "String" | + "Void" | + "Class" | + "Number" | + "Package" | + "StringBuffer" | + "StringBuilder" | + "CharSequence" | + "Thread" | + "Regex" { return token(TokenType.TYPE); } + + /* Some Java standard Library Types */ + "Throwable" | + "Cloneable" | + "Comparable" | + "Serializable" | + "Runnable" { return token(TokenType.TYPE); } + + /* Groovy commonly used methods */ + "print" | + "println" { return token(TokenType.KEYWORD); } + + /* Frequently used Standard Exceptions */ + "ArithmeticException" | + "ArrayIndexOutOfBoundsException" | + "ClassCastException" | + "ClassNotFoundException" | + "CloneNotSupportedException" | + "Exception" | + "IllegalAccessException" | + "IllegalArgumentException" | + "IllegalStateException" | + "IllegalThreadStateException" | + "IndexOutOfBoundsException" | + "InstantiationException" | + "InterruptedException" | + "NegativeArraySizeException" | + "NoSuchFieldException" | + "NoSuchMethodException" | + "NullPointerException" | + "NumberFormatException" | + "RuntimeException" | + "SecurityException" | + "StringIndexOutOfBoundsException" | + "UnsupportedOperationException" { return token(TokenType.TYPE2); } + + /* operators */ + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + ";" | + "," | + "." | + "@" | + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "==" | + "<=" | + ">=" | + "!=" | + "&&" | + "||" | + "++" | + "--" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" | + "<<" | + ">>" | + ">>>" | + "+=" | + "-=" | + "*=" | + "/=" | + "&=" | + "|=" | + "^=" | + "%=" | + "<<=" | + ">>=" | + ">>>=" { return token(TokenType.OPERATOR); } + + "~=" | + "?." { return token(TokenType.OPERATOR); } + + /* string literal */ + \"{3} { + yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + + /* string literal */ + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* character literal */ + \' { + yybegin(CHARLITERAL); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } + + // JavaDoc comments need a state so that we can highlight the @ controls + "/**" { + yybegin(JDOC); + tokenStart = yychar; + tokenLength = 3; + } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace}+ { /* skip */ } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } + + /* + Groovy Regex -- state cannot be easily used here due to / by itself being + a valid operator. So if we flip into the REGEX state, we cannot distinguish + a regular / + */ + "/" [^*] {RegexCharacter}+ "/" { return token(TokenType.REGEX); } + +} + + + { + + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + "${" { + yybegin(GSTRING_EXPR); + // length also includes the trailing quote + int s = tokenStart; + int l = tokenLength; + tokenStart = yychar; + tokenLength = 2; + return token(TokenType.STRING, s, l); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } + +} + + { + "}" { + yybegin(STRING); + // length also includes the trailing quote + int s = tokenStart; + int l = tokenLength + 1; + tokenStart = yychar + 1; + tokenLength = 0; + return token(TokenType.STRING2, s, l); + } + + {StringCharacter} { tokenLength ++; } +} + + { + + \"{3} { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 3); + } + + "${" { + yybegin(ML_STRING_EXPR); + // length also includes the trailing quote + int s = tokenStart; + int l = tokenLength; + tokenStart = yychar; + tokenLength = 2; + return token(TokenType.STRING, s, l); + } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + .|{LineTerminator} { tokenLength += yylength(); } + +} + + { + "}" { + yybegin(ML_STRING); + // length also includes the trailing quote + int s = tokenStart; + int l = tokenLength + 1; + tokenStart = yychar + 1; + tokenLength = 0; + return token(TokenType.STRING2, s, l); + } + + .|\n|\r { tokenLength ++; } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SingleCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + "@" { + yybegin(JDOC_TAG); + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT, start, len); + } + + .|\n { tokenLength ++; } + +} + + { + ([:letter:])+ ":"? { tokenLength += yylength(); } + + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + .|\n { + yybegin(JDOC); + // length also includes the trailing quote + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT2, start, len); + } +} + + { + "/" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.REGEX, tokenStart, tokenLength + 1); + } + + {RegexCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/java.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/java.flex index e67524635..6b282dd54 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/java.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/java.flex @@ -1,376 +1,376 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class JavaLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public JavaLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} - -TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" -EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -%state STRING, CHARLITERAL, JDOC, JDOC_TAG - -%% - - { - - /* keywords */ - "abstract" | - "boolean" | - "break" | - "byte" | - "case" | - "catch" | - "char" | - "class" | - "const" | - "continue" | - "do" | - "double" | - "enum" | - "else" | - "extends" | - "final" | - "finally" | - "float" | - "for" | - "default" | - "implements" | - "import" | - "instanceof" | - "int" | - "interface" | - "long" | - "native" | - "new" | - "goto" | - "if" | - "public" | - "short" | - "super" | - "switch" | - "synchronized" | - "package" | - "private" | - "protected" | - "transient" | - "return" | - "void" | - "static" | - "while" | - "this" | - "throw" | - "throws" | - "try" | - "volatile" | - "strictfp" | - - "true" | - "false" | - "null" { return token(TokenType.KEYWORD); } - - /* Java Built in types and wrappers */ - "Boolean" | - "Byte" | - "Character" | - "Double" | - "Float" | - "Integer" | - "Object" | - "Short" | - "Void" | - "Class" | - "Number" | - "Package" | - "StringBuffer" | - "StringBuilder" | - "CharSequence" | - "Thread" | - "String" { return token(TokenType.TYPE); } - - /* Some Java standard Library Types */ - "Throwable" | - "Cloneable" | - "Comparable" | - "Serializable" | - "Runnable" { return token(TokenType.TYPE); } - - "WARNING" { return token(TokenType.WARNING); } - "ERROR" { return token(TokenType.ERROR); } - - /* Frequently used Standard Exceptions */ - "ArithmeticException" | - "ArrayIndexOutOfBoundsException" | - "ClassCastException" | - "ClassNotFoundException" | - "CloneNotSupportedException" | - "Exception" | - "IllegalAccessException" | - "IllegalArgumentException" | - "IllegalStateException" | - "IllegalThreadStateException" | - "IndexOutOfBoundsException" | - "InstantiationException" | - "InterruptedException" | - "NegativeArraySizeException" | - "NoSuchFieldException" | - "NoSuchMethodException" | - "NullPointerException" | - "NumberFormatException" | - "RuntimeException" | - "SecurityException" | - "StringIndexOutOfBoundsException" | - "UnsupportedOperationException" { return token(TokenType.TYPE2); } - - /* operators */ - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - ";" | - "," | - "." | - "=" | - ">" | - "<" | - "!" | - "~" | - "?" | - ":" | - "==" | - "<=" | - ">=" | - "!=" | - "&&" | - "||" | - "++" | - "--" | - "+" | - "-" | - "*" | - "/" | - "&" | - "|" | - "^" | - "%" | - "<<" | - ">>" | - ">>>" | - "+=" | - "-=" | - "*=" | - "/=" | - "&=" | - "|=" | - "^=" | - "%=" | - "<<=" | - ">>=" | - ">>>=" { return token(TokenType.OPERATOR); } - - /* string literal */ - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* character literal */ - \' { - yybegin(CHARLITERAL); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } - - // JavaDoc comments need a state so that we can highlight the @ controls - "/**" { - yybegin(JDOC); - tokenStart = yychar; - tokenLength = 3; - } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SingleCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - "@" { - yybegin(JDOC_TAG); - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT, start, len); - } - - .|\n { tokenLength ++; } - -} - - { - ([:letter:])+ ":"? { tokenLength += yylength(); } - - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - .|\n { - yybegin(JDOC); - // length also includes the trailing quote - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT2, start, len); - } -} - - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class JavaLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public JavaLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +%state STRING, CHARLITERAL, JDOC, JDOC_TAG + +%% + + { + + /* keywords */ + "abstract" | + "boolean" | + "break" | + "byte" | + "case" | + "catch" | + "char" | + "class" | + "const" | + "continue" | + "do" | + "double" | + "enum" | + "else" | + "extends" | + "final" | + "finally" | + "float" | + "for" | + "default" | + "implements" | + "import" | + "instanceof" | + "int" | + "interface" | + "long" | + "native" | + "new" | + "goto" | + "if" | + "public" | + "short" | + "super" | + "switch" | + "synchronized" | + "package" | + "private" | + "protected" | + "transient" | + "return" | + "void" | + "static" | + "while" | + "this" | + "throw" | + "throws" | + "try" | + "volatile" | + "strictfp" | + + "true" | + "false" | + "null" { return token(TokenType.KEYWORD); } + + /* Java Built in types and wrappers */ + "Boolean" | + "Byte" | + "Character" | + "Double" | + "Float" | + "Integer" | + "Object" | + "Short" | + "Void" | + "Class" | + "Number" | + "Package" | + "StringBuffer" | + "StringBuilder" | + "CharSequence" | + "Thread" | + "String" { return token(TokenType.TYPE); } + + /* Some Java standard Library Types */ + "Throwable" | + "Cloneable" | + "Comparable" | + "Serializable" | + "Runnable" { return token(TokenType.TYPE); } + + "WARNING" { return token(TokenType.WARNING); } + "ERROR" { return token(TokenType.ERROR); } + + /* Frequently used Standard Exceptions */ + "ArithmeticException" | + "ArrayIndexOutOfBoundsException" | + "ClassCastException" | + "ClassNotFoundException" | + "CloneNotSupportedException" | + "Exception" | + "IllegalAccessException" | + "IllegalArgumentException" | + "IllegalStateException" | + "IllegalThreadStateException" | + "IndexOutOfBoundsException" | + "InstantiationException" | + "InterruptedException" | + "NegativeArraySizeException" | + "NoSuchFieldException" | + "NoSuchMethodException" | + "NullPointerException" | + "NumberFormatException" | + "RuntimeException" | + "SecurityException" | + "StringIndexOutOfBoundsException" | + "UnsupportedOperationException" { return token(TokenType.TYPE2); } + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + ";" | + "," | + "." | + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "==" | + "<=" | + ">=" | + "!=" | + "&&" | + "||" | + "++" | + "--" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" | + "<<" | + ">>" | + ">>>" | + "+=" | + "-=" | + "*=" | + "/=" | + "&=" | + "|=" | + "^=" | + "%=" | + "<<=" | + ">>=" | + ">>>=" { return token(TokenType.OPERATOR); } + + /* string literal */ + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* character literal */ + \' { + yybegin(CHARLITERAL); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } + + // JavaDoc comments need a state so that we can highlight the @ controls + "/**" { + yybegin(JDOC); + tokenStart = yychar; + tokenLength = 3; + } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SingleCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + "@" { + yybegin(JDOC_TAG); + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT, start, len); + } + + .|\n { tokenLength ++; } + +} + + { + ([:letter:])+ ":"? { tokenLength += yylength(); } + + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + .|\n { + yybegin(JDOC); + // length also includes the trailing quote + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT2, start, len); + } +} + + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/jflex.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/jflex.flex index a0696912a..8e1d88c9e 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/jflex.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/jflex.flex @@ -1,400 +1,400 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class JFlexLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public JFlexLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} - -TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" -EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -%state STRING, CHARLITERAL, JDOC, JDOC_TAG - -%% - - { - - /* keywords */ - "abstract" | - "boolean" | - "break" | - "byte" | - "case" | - "catch" | - "char" | - "class" | - "const" | - "continue" | - "do" | - "double" | - "enum" | - "else" | - "extends" | - "final" | - "finally" | - "float" | - "for" | - "default" | - "implements" | - "import" | - "instanceof" | - "int" | - "interface" | - "long" | - "native" | - "new" | - "goto" | - "if" | - "public" | - "short" | - "super" | - "switch" | - "synchronized" | - "package" | - "private" | - "protected" | - "transient" | - "return" | - "void" | - "static" | - "while" | - "this" | - "throw" | - "throws" | - "try" | - "volatile" | - "strictfp" | - "true" | - "false" | - "null" { return token(TokenType.KEYWORD); } - - /* JFlex special types */ - "<>" | - "[:jletter:]" | - "[:jletterdigit:]" | - "[:letter:]" | - "[:digit:]" | - "[:uppercase:]" | - "[:lowercase:]" | - "<" [a-zA-Z][a-zA-Z0-9_]* ">" { return token(TokenType.TYPE2); } - - /* JFlex Specials */ - "%%" | - "%{" | - "%}" | - "%class" | - "%implements" | - "%extends" | - "%public" | - "%final" | - "%abstract" | - "%apiprivate" | - "%init{" | - "%init}" | - "%initthrow{" | - "%initthrow}" | - "%initthrow" | - "%ctorarg" | - "%scanerror" | - "%buffer" | - "%include" | - "%function" | - "%integer" | - "%int" | - "%intwrap" | - "%yylexthrow{" | - "%yylexthrow}" | - "%yylexthrow" | - "%eofval{" | - "%eofval}" | - "%eof{" | - "%eof}" | - "%eofthrow{" | - "%eofthrow}" | - "%eofthrow" | - "%eofclose" | - "%debug" | - "%standalone" | - "%cup" | - "%cupsym" | - "%cupdebug" | - "%byacc" | - "%switch" | - "%table" | - "%pack" | - "%7bit" | - "%8bit" | - "%full" | - "%unicode" | - "%16bit" | - "%caseless" | - "%ignorecase" | - "%char" | - "%line" | - "%column" | - "%notunix" | - "%yyeof" | - "%s" | - "%state" | - "%x" | - "%xstate" | - "%type" { return token(TokenType.KEYWORD2); } - - - /* Java Built in types and wrappers */ - "Boolean" | - "Byte" | - "Double" | - "Float" | - "Integer" | - "Object" | - "Short" | - "String" { return token(TokenType.TYPE); } - - /* operators */ - - "(" | - ")" | - "{" | - "}" | - "[" | - "]" | - ";" | - "," | - "." | - "=" | - ">" | - "<" | - "!" | - "~" | - "?" | - ":" | - "==" | - "<=" | - ">=" | - "!=" | - "&&" | - "||" | - "++" | - "--" | - "+" | - "-" | - "*" | - "/" | - "&" | - "|" | - "^" | - "%" | - "<<" | - ">>" | - ">>>" | - "+=" | - "-=" | - "*=" | - "/=" | - "&=" | - "|=" | - "^=" | - "%=" | - "<<=" | - ">>=" | - ">>>=" { return token(TokenType.OPERATOR); } - - /* string literal */ - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* character literal */ - \' { - yybegin(CHARLITERAL); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } - - // JavaDoc comments need a state so that we can highlight the @ controls - "/**" { - yybegin(JDOC); - tokenStart = yychar; - tokenLength = 3; - } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SingleCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - "@" { - yybegin(JDOC_TAG); - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT, start, len); - } - - .|\n { tokenLength ++; } - -} - - { - ([:letter:])+ ":"? { tokenLength += yylength(); } - - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - .|\n { - yybegin(JDOC); - // length also includes the trailing quote - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT2, start, len); - } -} - - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class JFlexLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public JFlexLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +%state STRING, CHARLITERAL, JDOC, JDOC_TAG + +%% + + { + + /* keywords */ + "abstract" | + "boolean" | + "break" | + "byte" | + "case" | + "catch" | + "char" | + "class" | + "const" | + "continue" | + "do" | + "double" | + "enum" | + "else" | + "extends" | + "final" | + "finally" | + "float" | + "for" | + "default" | + "implements" | + "import" | + "instanceof" | + "int" | + "interface" | + "long" | + "native" | + "new" | + "goto" | + "if" | + "public" | + "short" | + "super" | + "switch" | + "synchronized" | + "package" | + "private" | + "protected" | + "transient" | + "return" | + "void" | + "static" | + "while" | + "this" | + "throw" | + "throws" | + "try" | + "volatile" | + "strictfp" | + "true" | + "false" | + "null" { return token(TokenType.KEYWORD); } + + /* JFlex special types */ + "<>" | + "[:jletter:]" | + "[:jletterdigit:]" | + "[:letter:]" | + "[:digit:]" | + "[:uppercase:]" | + "[:lowercase:]" | + "<" [a-zA-Z][a-zA-Z0-9_]* ">" { return token(TokenType.TYPE2); } + + /* JFlex Specials */ + "%%" | + "%{" | + "%}" | + "%class" | + "%implements" | + "%extends" | + "%public" | + "%final" | + "%abstract" | + "%apiprivate" | + "%init{" | + "%init}" | + "%initthrow{" | + "%initthrow}" | + "%initthrow" | + "%ctorarg" | + "%scanerror" | + "%buffer" | + "%include" | + "%function" | + "%integer" | + "%int" | + "%intwrap" | + "%yylexthrow{" | + "%yylexthrow}" | + "%yylexthrow" | + "%eofval{" | + "%eofval}" | + "%eof{" | + "%eof}" | + "%eofthrow{" | + "%eofthrow}" | + "%eofthrow" | + "%eofclose" | + "%debug" | + "%standalone" | + "%cup" | + "%cupsym" | + "%cupdebug" | + "%byacc" | + "%switch" | + "%table" | + "%pack" | + "%7bit" | + "%8bit" | + "%full" | + "%unicode" | + "%16bit" | + "%caseless" | + "%ignorecase" | + "%char" | + "%line" | + "%column" | + "%notunix" | + "%yyeof" | + "%s" | + "%state" | + "%x" | + "%xstate" | + "%type" { return token(TokenType.KEYWORD2); } + + + /* Java Built in types and wrappers */ + "Boolean" | + "Byte" | + "Double" | + "Float" | + "Integer" | + "Object" | + "Short" | + "String" { return token(TokenType.TYPE); } + + /* operators */ + + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." | + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "==" | + "<=" | + ">=" | + "!=" | + "&&" | + "||" | + "++" | + "--" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" | + "<<" | + ">>" | + ">>>" | + "+=" | + "-=" | + "*=" | + "/=" | + "&=" | + "|=" | + "^=" | + "%=" | + "<<=" | + ">>=" | + ">>>=" { return token(TokenType.OPERATOR); } + + /* string literal */ + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* character literal */ + \' { + yybegin(CHARLITERAL); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } + + // JavaDoc comments need a state so that we can highlight the @ controls + "/**" { + yybegin(JDOC); + tokenStart = yychar; + tokenLength = 3; + } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SingleCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + "@" { + yybegin(JDOC_TAG); + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT, start, len); + } + + .|\n { tokenLength ++; } + +} + + { + ([:letter:])+ ":"? { tokenLength += yylength(); } + + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + .|\n { + yybegin(JDOC); + // length also includes the trailing quote + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT2, start, len); + } +} + + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/lua.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/lua.flex index 7ddcdce35..1c9b391b9 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/lua.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/lua.flex @@ -1,298 +1,298 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class LuaLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public LuaLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - private static final byte ENDBLOCK = 4; - private static final byte REPEATBLOCK = 5; - - TokenType longType; - int longLen; -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -LongStart = \[=*\[ -LongEnd = \]=*\] - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = [0-9]+ -HexDigit = [0-9a-fA-F] - -HexIntegerLiteral = 0x{HexDigit}+ - -/* floating point literals */ -DoubleLiteral = ({FLit1}|{FLit2}) {Exponent}? - -FLit1 = [0-9]+(\.[0-9]*)? -FLit2 = \.[0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter1 = [^\r\n\"\\] -StringCharacter2 = [^\r\n\'\\] - -%state STRING1 -%state STRING2 -%state LONGSTRING - -%state COMMENT -%state LINECOMMENT - -%% - - { - - /* keywords */ - "and" | - "break" | - "for" | - "if" | - "in" | - "local" | - "not" | - "or" | - "return" | - "while" | - - /* boolean literals */ - "true" | - "false" | - - /* nil literal */ - "nil" { return token(TokenType.KEYWORD); } - - "repeat" { return token(TokenType.KEYWORD, REPEATBLOCK); } - "until" { return token(TokenType.KEYWORD, -REPEATBLOCK); } - - "function" { return token(TokenType.KEYWORD, ENDBLOCK); } - "then" { return token(TokenType.KEYWORD, ENDBLOCK); } - "do" { return token(TokenType.KEYWORD, ENDBLOCK); } - - "else" { return token(TokenType.KEYWORD); } - "elseif" { return token(TokenType.KEYWORD); } - - "end" { return token(TokenType.KEYWORD, -ENDBLOCK); } - - /* operators */ - - "+" | - "-" | - "*" | - "/" | - "%" | - "^" | - "#" | - "==" | - "~=" | - "<=" | - ">=" | - "<" | - ">" | - "=" | - ";" | - ":" | - "," | - "." | - ".." | - "..." { return token(TokenType.OPERATOR); } - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - - - {LongStart} { - longType = TokenType.STRING; - yybegin(LONGSTRING); - tokenStart = yychar; - tokenLength = yylength(); - longLen = tokenLength; - } - - "--" { - yybegin(COMMENT); - tokenStart = yychar; - tokenLength = yylength(); - } - - - /* string literal */ - \" { - yybegin(STRING1); - tokenStart = yychar; - tokenLength = 1; - } - \' { - yybegin(STRING2); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - - {HexIntegerLiteral} | - - {DoubleLiteral} { return token(TokenType.NUMBER); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - { - {LongEnd} { - if (longLen == yylength()) { - tokenLength += yylength(); - yybegin(YYINITIAL); - return token(longType, tokenStart, tokenLength); - } else { - tokenLength++; - yypushback(yylength() - 1); - } - - } - {LineTerminator} { tokenLength += yylength(); } - . { tokenLength++; } - <> { - yybegin(YYINITIAL); - return token(longType, tokenStart, tokenLength); - } -} - - { - {LongStart} { - longType = TokenType.COMMENT; - yybegin(LONGSTRING); - tokenLength += yylength(); - longLen = yylength(); - } - - {LineTerminator} { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength); - } - - . { - yybegin(LINECOMMENT); - tokenLength += yylength(); - } - <> { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength); - } - -} - - { - {LineTerminator} { - yybegin(YYINITIAL); - tokenLength += yylength(); - return token(TokenType.COMMENT, tokenStart, tokenLength); - } - {LineTerminator} { tokenLength += yylength(); } - . { tokenLength++; } - <> { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength); - } -} - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter1}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } - <> { - yybegin(YYINITIAL); - return token(TokenType.STRING, tokenStart, tokenLength); - } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter2}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } - <> { - yybegin(YYINITIAL); - return token(TokenType.STRING, tokenStart, tokenLength); - } -} - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class LuaLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public LuaLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte ENDBLOCK = 4; + private static final byte REPEATBLOCK = 5; + + TokenType longType; + int longLen; +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +LongStart = \[=*\[ +LongEnd = \]=*\] + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = [0-9]+ +HexDigit = [0-9a-fA-F] + +HexIntegerLiteral = 0x{HexDigit}+ + +/* floating point literals */ +DoubleLiteral = ({FLit1}|{FLit2}) {Exponent}? + +FLit1 = [0-9]+(\.[0-9]*)? +FLit2 = \.[0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter1 = [^\r\n\"\\] +StringCharacter2 = [^\r\n\'\\] + +%state STRING1 +%state STRING2 +%state LONGSTRING + +%state COMMENT +%state LINECOMMENT + +%% + + { + + /* keywords */ + "and" | + "break" | + "for" | + "if" | + "in" | + "local" | + "not" | + "or" | + "return" | + "while" | + + /* boolean literals */ + "true" | + "false" | + + /* nil literal */ + "nil" { return token(TokenType.KEYWORD); } + + "repeat" { return token(TokenType.KEYWORD, REPEATBLOCK); } + "until" { return token(TokenType.KEYWORD, -REPEATBLOCK); } + + "function" { return token(TokenType.KEYWORD, ENDBLOCK); } + "then" { return token(TokenType.KEYWORD, ENDBLOCK); } + "do" { return token(TokenType.KEYWORD, ENDBLOCK); } + + "else" { return token(TokenType.KEYWORD); } + "elseif" { return token(TokenType.KEYWORD); } + + "end" { return token(TokenType.KEYWORD, -ENDBLOCK); } + + /* operators */ + + "+" | + "-" | + "*" | + "/" | + "%" | + "^" | + "#" | + "==" | + "~=" | + "<=" | + ">=" | + "<" | + ">" | + "=" | + ";" | + ":" | + "," | + "." | + ".." | + "..." { return token(TokenType.OPERATOR); } + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + + + {LongStart} { + longType = TokenType.STRING; + yybegin(LONGSTRING); + tokenStart = yychar; + tokenLength = yylength(); + longLen = tokenLength; + } + + "--" { + yybegin(COMMENT); + tokenStart = yychar; + tokenLength = yylength(); + } + + + /* string literal */ + \" { + yybegin(STRING1); + tokenStart = yychar; + tokenLength = 1; + } + \' { + yybegin(STRING2); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + + {HexIntegerLiteral} | + + {DoubleLiteral} { return token(TokenType.NUMBER); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + { + {LongEnd} { + if (longLen == yylength()) { + tokenLength += yylength(); + yybegin(YYINITIAL); + return token(longType, tokenStart, tokenLength); + } else { + tokenLength++; + yypushback(yylength() - 1); + } + + } + {LineTerminator} { tokenLength += yylength(); } + . { tokenLength++; } + <> { + yybegin(YYINITIAL); + return token(longType, tokenStart, tokenLength); + } +} + + { + {LongStart} { + longType = TokenType.COMMENT; + yybegin(LONGSTRING); + tokenLength += yylength(); + longLen = yylength(); + } + + {LineTerminator} { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength); + } + + . { + yybegin(LINECOMMENT); + tokenLength += yylength(); + } + <> { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength); + } + +} + + { + {LineTerminator} { + yybegin(YYINITIAL); + tokenLength += yylength(); + return token(TokenType.COMMENT, tokenStart, tokenLength); + } + {LineTerminator} { tokenLength += yylength(); } + . { tokenLength++; } + <> { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength); + } +} + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter1}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } + <> { + yybegin(YYINITIAL); + return token(TokenType.STRING, tokenStart, tokenLength); + } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter2}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } + <> { + yybegin(YYINITIAL); + return token(TokenType.STRING, tokenStart, tokenLength); + } +} + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/properties.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/properties.flex index 68fdaad14..2e06030af 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/properties.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/properties.flex @@ -1,63 +1,63 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class PropertiesLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public PropertiesLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } -%} - -StartComment = # -WhiteSpace = [ \t] -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] -KeyCharacter = [a-zA-Z0-9._ ] - -%% - - -{ - {KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); } - {StartComment} {InputCharacter}* {LineTerminator}? - { return token(TokenType.COMMENT); } - . | {LineTerminator} { /* skip */ } -} - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class PropertiesLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public PropertiesLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } +%} + +StartComment = # +WhiteSpace = [ \t] +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] +KeyCharacter = [a-zA-Z0-9._ ] + +%% + + +{ + {KeyCharacter}+{WhiteSpace}*= { return token(TokenType.KEYWORD); } + {StartComment} {InputCharacter}* {LineTerminator}? + { return token(TokenType.COMMENT); } + . | {LineTerminator} { /* skip */ } +} + <> { return null; } \ No newline at end of file diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/python.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/python.flex index 5f32d45fe..fc417acdb 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/python.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/python.flex @@ -1,386 +1,386 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class PythonLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public PythonLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = "#" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [a-zA-Z][a-zA-Z0-9_]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SQStringCharacter = [^\r\n\'\\] - -%state STRING, ML_STRING, SQSTRING, SQML_STRING - -%% - - { - - /* keywords */ - "and" | - "as" | - "assert" | - "break" | - "class" | - "continue" | - "def" | - "del" | - "elif" | - "else" | - "except" | - "exec" | - "finally" | - "for" | - "from" | - "global" | - "if" | - "import" | - "in" | - "is" | - "lambda" | - "not" | - "or" | - "pass" | - "print" | - "self" | /* not exactly keyword, but almost */ - "raise" | - "return" | - "try" | - "while" | - "with" | - "yield" { return token(TokenType.KEYWORD); } - - /* Built-in Types*/ - "yield" | - "Ellipsis" | - "False" | - "None" | - "NotImplemented" | - "True" | - "__import__" | - "__name__" | - "abs" | - "apply" | - "bool" | - "buffer" | - "callable" | - "chr" | - "classmethod" | - "cmp" | - "coerce" | - "compile" | - "complex" | - "delattr" | - "dict" | - "dir" | - "divmod" | - "enumerate" | - "eval" | - "execfile" | - "file" | - "filter" | - "float" | - "frozenset" | - "getattr" | - "globals" | - "hasattr" | - "hash" | - "help" | - "hex" | - "id" | - "input" | - "int" | - "intern" | - "isinstance" | - "issubclass" | - "iter" | - "len" | - "list" | - "locals" | - "long" | - "map" | - "max" | - "min" | - "object" | - "oct" | - "open" | - "ord" | - "pow" | - "property" | - "range" | - "raw_input" | - "reduce" | - "reload" | - "repr" | - "reversed" | - "round" | - "set" | - "setattr" | - "slice" | - "sorted" | - "staticmethod" | - "str" | - "sum" | - "super" | - "tuple" | - "type" | - "unichr" | - "unicode" | - "vars" | - "xrange" | - "zip" { return token(TokenType.TYPE); } - - - - /* operators */ - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - "+" | - "-" | - "*" | - "**" | - "/" | - "//" | - "%" | - "<<" | - ">>" | - "&" | - "|" | - "^" | - "~" | - "<" | - ">" | - "<=" | - ">=" | - "==" | - "!=" | - "<>" | - "@" | - "," | - ":" | - "." | - "`" | - "=" | - ";" | - "+=" | - "-=" | - "*=" | - "/=" | - "//=" | - "%=" | - "&=" | - "|=" | - "^=" | - ">>=" | - "<<=" | - "**=" { return token(TokenType.OPERATOR); } - - /* string literal */ - \"{3} { - yybegin(ML_STRING); - tokenStart = yychar; - tokenLength = 3; - } - - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - \'{3} { - yybegin(SQML_STRING); - tokenStart = yychar; - tokenLength = 3; - } - - \' { - yybegin(SQSTRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } - - "$" | "?" { return token(TokenType.ERROR); } -} - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \"{3} { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 3); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - \" { tokenLength ++; } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { tokenLength ++; } -} - - { - "'" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SQStringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \'{3} { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 3); - } - - {SQStringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - \' { tokenLength ++; } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { tokenLength ++; } -} - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class PythonLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public PythonLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = "#" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [a-zA-Z][a-zA-Z0-9_]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SQStringCharacter = [^\r\n\'\\] + +%state STRING, ML_STRING, SQSTRING, SQML_STRING + +%% + + { + + /* keywords */ + "and" | + "as" | + "assert" | + "break" | + "class" | + "continue" | + "def" | + "del" | + "elif" | + "else" | + "except" | + "exec" | + "finally" | + "for" | + "from" | + "global" | + "if" | + "import" | + "in" | + "is" | + "lambda" | + "not" | + "or" | + "pass" | + "print" | + "self" | /* not exactly keyword, but almost */ + "raise" | + "return" | + "try" | + "while" | + "with" | + "yield" { return token(TokenType.KEYWORD); } + + /* Built-in Types*/ + "yield" | + "Ellipsis" | + "False" | + "None" | + "NotImplemented" | + "True" | + "__import__" | + "__name__" | + "abs" | + "apply" | + "bool" | + "buffer" | + "callable" | + "chr" | + "classmethod" | + "cmp" | + "coerce" | + "compile" | + "complex" | + "delattr" | + "dict" | + "dir" | + "divmod" | + "enumerate" | + "eval" | + "execfile" | + "file" | + "filter" | + "float" | + "frozenset" | + "getattr" | + "globals" | + "hasattr" | + "hash" | + "help" | + "hex" | + "id" | + "input" | + "int" | + "intern" | + "isinstance" | + "issubclass" | + "iter" | + "len" | + "list" | + "locals" | + "long" | + "map" | + "max" | + "min" | + "object" | + "oct" | + "open" | + "ord" | + "pow" | + "property" | + "range" | + "raw_input" | + "reduce" | + "reload" | + "repr" | + "reversed" | + "round" | + "set" | + "setattr" | + "slice" | + "sorted" | + "staticmethod" | + "str" | + "sum" | + "super" | + "tuple" | + "type" | + "unichr" | + "unicode" | + "vars" | + "xrange" | + "zip" { return token(TokenType.TYPE); } + + + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + "+" | + "-" | + "*" | + "**" | + "/" | + "//" | + "%" | + "<<" | + ">>" | + "&" | + "|" | + "^" | + "~" | + "<" | + ">" | + "<=" | + ">=" | + "==" | + "!=" | + "<>" | + "@" | + "," | + ":" | + "." | + "`" | + "=" | + ";" | + "+=" | + "-=" | + "*=" | + "/=" | + "//=" | + "%=" | + "&=" | + "|=" | + "^=" | + ">>=" | + "<<=" | + "**=" { return token(TokenType.OPERATOR); } + + /* string literal */ + \"{3} { + yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + \'{3} { + yybegin(SQML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + + \' { + yybegin(SQSTRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } + + "$" | "?" { return token(TokenType.ERROR); } +} + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \"{3} { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 3); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + \" { tokenLength ++; } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { tokenLength ++; } +} + + { + "'" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SQStringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \'{3} { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 3); + } + + {SQStringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + \' { tokenLength ++; } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { tokenLength ++; } +} + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/ruby.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/ruby.flex index 61b49d3dd..d475642aa 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/ruby.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/ruby.flex @@ -1,276 +1,276 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class RubyLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public RubyLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - private static final byte WORD = 4; - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = "#" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [a-zA-Z][a-zA-Z0-9_]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] - -%state STRING, ML_STRING - -%% - - { - - /* keywords */ - "BEGIN" | - "ensure" | - "assert" | - "nil" | - "self" | - "when" | - "END" | - "false" | - "not" | - "super" | - "alias" | - "defined" | - "or" | - "then" | - "yield" | - "and" | - "redo" | - "true" | - "else" | - "in" | - "rescue" | - "undef" | - "break" | - "elsif" | - "module" | - "retry" | - "unless" | - "next" | - "return" { return token(TokenType.KEYWORD); } - - "begin" | - "case" | - "class" | - "def" | - "for" | - "while" | - "until" | - "do" | - "if" { return token(TokenType.KEYWORD, WORD); } - - "end" { return token(TokenType.KEYWORD, -WORD); } - - - /* Built-in Types*/ - "self" | - "nil" | - "true" | - "false" | - "__FILE__" | - "__LINE__" { return token(TokenType.TYPE); } - - - - /* operators */ - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - "+" | - "-" | - "*" | - "**" | - "/" | - "//" | - "%" | - "<<" | - ">>" | - "&" | - "|" | - "^" | - "~" | - "<" | - ">" | - "<=" | - ">=" | - "==" | - "!=" | - "<>" | - "@" | - "," | - ":" | - "." | - ".." | - "`" | - "=" | - ";" | - "+=" | - "-=" | - "*=" | - "/=" | - "//=" | - "%=" | - "&=" | - "|=" | - "^=" | - ">>=" | - "<<=" | - "**=" { return token(TokenType.OPERATOR); } - - /* string literal */ - \"{3} { - yybegin(ML_STRING); - tokenStart = yychar; - tokenLength = 3; - } - - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier}"?" { return token(TokenType.TYPE2); } - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \"{3} { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 3); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { tokenLength ++; } -} - - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class RubyLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public RubyLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + private static final byte WORD = 4; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = "#" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [a-zA-Z][a-zA-Z0-9_]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] + +%state STRING, ML_STRING + +%% + + { + + /* keywords */ + "BEGIN" | + "ensure" | + "assert" | + "nil" | + "self" | + "when" | + "END" | + "false" | + "not" | + "super" | + "alias" | + "defined" | + "or" | + "then" | + "yield" | + "and" | + "redo" | + "true" | + "else" | + "in" | + "rescue" | + "undef" | + "break" | + "elsif" | + "module" | + "retry" | + "unless" | + "next" | + "return" { return token(TokenType.KEYWORD); } + + "begin" | + "case" | + "class" | + "def" | + "for" | + "while" | + "until" | + "do" | + "if" { return token(TokenType.KEYWORD, WORD); } + + "end" { return token(TokenType.KEYWORD, -WORD); } + + + /* Built-in Types*/ + "self" | + "nil" | + "true" | + "false" | + "__FILE__" | + "__LINE__" { return token(TokenType.TYPE); } + + + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + "+" | + "-" | + "*" | + "**" | + "/" | + "//" | + "%" | + "<<" | + ">>" | + "&" | + "|" | + "^" | + "~" | + "<" | + ">" | + "<=" | + ">=" | + "==" | + "!=" | + "<>" | + "@" | + "," | + ":" | + "." | + ".." | + "`" | + "=" | + ";" | + "+=" | + "-=" | + "*=" | + "/=" | + "//=" | + "%=" | + "&=" | + "|=" | + "^=" | + ">>=" | + "<<=" | + "**=" { return token(TokenType.OPERATOR); } + + /* string literal */ + \"{3} { + yybegin(ML_STRING); + tokenStart = yychar; + tokenLength = 3; + } + + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {FloatLiteral}[jJ] { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier}"?" { return token(TokenType.TYPE2); } + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \"{3} { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 3); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { tokenLength ++; } +} + + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/scala.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/scala.flex index 34376a318..8bbe9654e 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/scala.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/scala.flex @@ -1,344 +1,344 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class ScalaLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public ScalaLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} - -TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" -EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* -DecLongLiteral = {DecIntegerLiteral} [lL] - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] -DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -%state STRING, CHARLITERAL, JDOC, JDOC_TAG - -%% - - { - - /* keywords */ - "def" | - "import" | - "package" | - "if" | - "then" | - "else" | - "while" | - "for" | - "do" | - "boolean" | - "int" | - "double" | - "byte" | - "short" | - "char" | - "long" | - "float" | - "unit" | - "val" | - "with" | - "type" | - "var" | - "yield" | - "return" | - "true" | - "false" | - "null" | - "this" | - "super" | - "String" | - "Array" | - "private" | - "protected" | - "override" | - "abstract" | - "final" | - "sealed" | - "throw" | - "try" | - "catch" | - "finally" | - "extends" { return token(TokenType.KEYWORD); } - - /* Java Built in types and wrappers */ - "object" | - "Boolean" | - "Byte" | - "Character" | - "Double" | - "Float" | - "Integer" | - "Object" | - "Short" | - "Void" | - "Class" | - "Number" | - "Package" | - "StringBuffer" | - "StringBuilder" | - "CharSequence" | - "Thread" | - "String" { return token(TokenType.TYPE); } - - /* Some Scala predefines */ - "println" { return token(TokenType.KEYWORD2); } - - /* Some Java standard Library Types */ - "Throwable" | - "Cloneable" | - "Comparable" | - "Serializable" | - "Runnable" { return token(TokenType.TYPE); } - - "WARNING" { return token(TokenType.WARNING); } - "ERROR" { return token(TokenType.ERROR); } - - /* operators */ - - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - ";" | - "," | - "." | - "=" | - ">" | - "<" | - "!" | - "~" | - "?" | - ":" | - "==" | - "<=" | - ">=" | - "!=" | - "&&" | - "||" | - "++" | - "--" | - "+" | - "-" | - "*" | - "/" | - "&" | - "|" | - "^" | - "%" | - "<<" | - ">>" | - ">>>" | - "+=" | - "-=" | - "*=" | - "/=" | - "&=" | - "|=" | - "^=" | - "%=" | - "<<=" | - ">>=" | - ">>>=" { return token(TokenType.OPERATOR); } - - /* string literal */ - \" { - yybegin(STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* character literal */ - \' { - yybegin(CHARLITERAL); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - {DecLongLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FloatLiteral} | - {DoubleLiteral} | - {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } - - // JavaDoc comments need a state so that we can highlight the @ controls - "/**" { - yybegin(JDOC); - tokenStart = yychar; - tokenLength = 3; - } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {StringCharacter}+ { tokenLength += yylength(); } - - \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - {SingleCharacter}+ { tokenLength += yylength(); } - - /* escape sequences */ - - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } -} - - { - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - "@" { - yybegin(JDOC_TAG); - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT, start, len); - } - - .|\n { tokenLength ++; } - -} - - { - ([:letter:])+ ":"? { tokenLength += yylength(); } - - "*/" { - yybegin(YYINITIAL); - return token(TokenType.COMMENT, tokenStart, tokenLength + 2); - } - - .|\n { - yybegin(JDOC); - // length also includes the trailing quote - int start = tokenStart; - tokenStart = yychar; - int len = tokenLength; - tokenLength = 1; - return token(TokenType.COMMENT2, start, len); - } -} - - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class ScalaLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public ScalaLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +EndOfLineComment = "//" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* +DecLongLiteral = {DecIntegerLiteral} [lL] + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = 0+ [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] +DoubleLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +%state STRING, CHARLITERAL, JDOC, JDOC_TAG + +%% + + { + + /* keywords */ + "def" | + "import" | + "package" | + "if" | + "then" | + "else" | + "while" | + "for" | + "do" | + "boolean" | + "int" | + "double" | + "byte" | + "short" | + "char" | + "long" | + "float" | + "unit" | + "val" | + "with" | + "type" | + "var" | + "yield" | + "return" | + "true" | + "false" | + "null" | + "this" | + "super" | + "String" | + "Array" | + "private" | + "protected" | + "override" | + "abstract" | + "final" | + "sealed" | + "throw" | + "try" | + "catch" | + "finally" | + "extends" { return token(TokenType.KEYWORD); } + + /* Java Built in types and wrappers */ + "object" | + "Boolean" | + "Byte" | + "Character" | + "Double" | + "Float" | + "Integer" | + "Object" | + "Short" | + "Void" | + "Class" | + "Number" | + "Package" | + "StringBuffer" | + "StringBuilder" | + "CharSequence" | + "Thread" | + "String" { return token(TokenType.TYPE); } + + /* Some Scala predefines */ + "println" { return token(TokenType.KEYWORD2); } + + /* Some Java standard Library Types */ + "Throwable" | + "Cloneable" | + "Comparable" | + "Serializable" | + "Runnable" { return token(TokenType.TYPE); } + + "WARNING" { return token(TokenType.WARNING); } + "ERROR" { return token(TokenType.ERROR); } + + /* operators */ + + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + ";" | + "," | + "." | + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" | + "==" | + "<=" | + ">=" | + "!=" | + "&&" | + "||" | + "++" | + "--" | + "+" | + "-" | + "*" | + "/" | + "&" | + "|" | + "^" | + "%" | + "<<" | + ">>" | + ">>>" | + "+=" | + "-=" | + "*=" | + "/=" | + "&=" | + "|=" | + "^=" | + "%=" | + "<<=" | + ">>=" | + ">>>=" { return token(TokenType.OPERATOR); } + + /* string literal */ + \" { + yybegin(STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* character literal */ + \' { + yybegin(CHARLITERAL); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + {DecLongLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FloatLiteral} | + {DoubleLiteral} | + {DoubleLiteral}[dD] { return token(TokenType.NUMBER); } + + // JavaDoc comments need a state so that we can highlight the @ controls + "/**" { + yybegin(JDOC); + tokenStart = yychar; + tokenLength = 3; + } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + {SingleCharacter}+ { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } +} + + { + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + "@" { + yybegin(JDOC_TAG); + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT, start, len); + } + + .|\n { tokenLength ++; } + +} + + { + ([:letter:])+ ":"? { tokenLength += yylength(); } + + "*/" { + yybegin(YYINITIAL); + return token(TokenType.COMMENT, tokenStart, tokenLength + 2); + } + + .|\n { + yybegin(JDOC); + // length also includes the trailing quote + int start = tokenStart; + tokenStart = yychar; + int len = tokenLength; + tokenLength = 1; + return token(TokenType.COMMENT2, start, len); + } +} + + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/sql.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/sql.flex index f3c20e2fb..cd762876d 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/sql.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/sql.flex @@ -1,383 +1,383 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class SqlLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token -%caseless - - -%{ - /** - * Default constructor is needed as we will always call the yyreset - */ - public SqlLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f] - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment} - -TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" -DocumentationComment = "/**" {CommentContent} "*"+ "/" -CommentContent = ( [^*] | \*+ [^/*] )* -EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [:jletter:][:jletterdigit:]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* - -/* floating point literals */ -FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] - -FLit1 = [0-9]+ \. [0-9]* -FLit2 = \. [0-9]+ -FLit3 = [0-9]+ -Exponent = [eE] [+-]? [0-9]+ - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -// Create states for Double Quoted and Single Quoted Strings -%state DQ_STRING, SQ_STRING - -Reserved = - "ADD" | - "ALL" | - "ALLOW REVERSE SCANS" | - "ALTER" | - "ANALYZE" | - "AND" | - "AS" | - "ASC" | - "AUTOMATIC" | - "BEGIN" | - "BEFORE" | - "BETWEEN" | - "BIGINT" | - "BINARY" | - "BLOB" | - "BOTH" | - "BUFFERPOOL" | - "BY" | - "CACHE" | - "CALL" | - "CASCADE" | - "CASE" | - "CHANGE" | - "CHAR" | - "CHARACTER" | - "CHECK" | - "COLLATE" | - "COLUMN" | - "COMMIT" | - "CONDITION" | - "CONSTANT" | - "CONSTRAINT" | - "CONTINUE" | - "CONVERT" | - "CREATE" | - "CROSS" | - "CURSOR" | - "DATE" | - "DATABASE" | - "DATABASES" | - "DEC" | - "DECIMAL" | - "DECODE" | - "DECLARE" | - "DEFAULT" | - "DELAYED" | - "DELETE" | - "DESC" | - "DESCRIBE" | - "DETERMINISTIC" | - "DISTINCT" | - "DISTINCTROW" | - "DIV" | - "DOUBLE" | - "DROP" | - "DUAL" | - "EACH" | - "ELSE" | - "ELSEIF" | - "ENCLOSED" | - "END" | - "ESCAPED" | - "EXCEPTION" | - "EXISTS" | - "EXIT" | - "EXPLAIN" | - "FALSE" | - "FETCH" | - "FLOAT" | - "FLOAT4" | - "FLOAT8" | - "FOR" | - "FORCE" | - "FOREIGN" | - "FROM" | - "FUNCTION" | - "FULLTEXT" | - "GLOBAL TEMPORARY" | - "GRANT" | - "GROUP" | - "HAVING" | - "IF" | - "IGNORE" | - "IN" | - "INDEX" | - "INFILE" | - "INNER" | - "INOUT" | - "INSENSITIVE" | - "INSERT" | - "INT" | - "INTEGER" | - "INTERVAL" | - "INTO" | - "IS" | - "IS REF CURSOR" | - "ITERATE" | - "JOIN" | - "KEY" | - "KEYS" | - "KILL" | - "LEADING" | - "LEAVE" | - "LEFT" | - "LIKE" | - "LIMIT" | - "LINES" | - "LOAD" | - "LOCK" | - "LONG" | - "LOOP" | - "MATCH" | - "MERGE" | - "MINVALUE" | - "MAXVALUE" | - "MOD" | - "MODIFIES" | - "NATURAL" | - "NOCYCLE" | - "NOORDER" | - "NOT" | - "NULL" | - "NUMERIC" | - "NUMBER" | - "ON" | - "OPEN" | - "OPTIMIZE" | - "OPTION" | - "OPTIONALLY" | - "OR" | - "ORDER" | - "OTHERS" | - "OUT" | - "OUTER" | - "OUTFILE" | - "PACKAGE" | - "PACKAGE BODY" | - "PAGESIZE" | - "PLS_INTEGER" | - "PRAGMA" | - "PRECISION" | - "PRIMARY" | - "PROCEDURE" | - "PURGE" | - "RAISE" | - "READ" | - "READS" | - "REAL" | - "REFERENCES" | - "REGEXP" | - "RELEASE" | - "RENAME" | - "REPEAT" | - "REPLACE" | - "REQUIRE" | - "RESTRICT" | - "RETURN" | - "REVOKE" | - "RIGHT" | - "RLIKE" | - "ROLLBACK" | - "ROWCOUNT" | - "ROWTYPE" | - "SIZE" | - "SCHEMA" | - "SCHEMAS" | - "SELECT" | - "SENSITIVE" | - "SEPARATOR" | - "SEQUENCE" | - "SET" | - "SHOW" | - "SMALLINT" | - "SONAME" | - "SPATIAL" | - "SPECIFIC" | - "SQL" | - "SQLEXCEPTION" | - "SQLSTATE" | - "SQLWARNING" | - "STARTING" | - "SYSDATE" | - "TABLE" | - "TABLESPACE" | - "TERMINATED" | - "THEN" | - "TO" | - "TO_CHAR" | - "TO_DATE" | - "TRAILING" | - "TRIGGER" | - "TRUE" | - "TRUNCATE" | - "TYPE" | - "UNDO" | - "UNION" | - "UNIQUE" | - "UNLOCK" | - "UNSIGNED" | - "UPDATE" | - "USAGE" | - "USE" | - "USER" | - "USING" | - "VALUES" | - "VARBINARY" | - "VARCHAR" | - "VARCHAR2" | - "VARCHARACTER" | - "VARYING" | - "WHEN" | - "WHERE" | - "WHILE" | - "WITH" | - "WRITE" | - "XOR" | - "ZEROFILL" -%% - - { - - /* keywords */ - {Reserved} { return token(TokenType.KEYWORD); } - - /* operators */ - - "(" | - ")" | - "{" | - "}" | - "[" | - "]" | - ";" | - "," | - "." | - "@" | - "=" | - ">" | - "<" | - "!" | - "~" | - "?" | - ":" { return token(TokenType.OPERATOR); } - - /* string literal */ - \" { - yybegin(DQ_STRING); - tokenStart = yychar; - tokenLength = 1; - } - \' { - yybegin(SQ_STRING); - tokenStart = yychar; - tokenLength = 1; - } - - /* numeric literals */ - - {DecIntegerLiteral} | - - {FloatLiteral} { return token(TokenType.NUMBER); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace}+ { /* skip */ } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } - -} - - { - {StringCharacter}+ { tokenLength += yylength(); } - \"\" { tokenLength += 2; } - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } -} - - { - {SingleCharacter}+ { tokenLength += yylength(); } - \'\' { tokenLength += 2; } - \\. { tokenLength += 2; } - {LineTerminator} { yybegin(YYINITIAL); } - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } -} - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class SqlLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token +%caseless + + +%{ + /** + * Default constructor is needed as we will always call the yyreset + */ + public SqlLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f] + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment} + +TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" +DocumentationComment = "/**" {CommentContent} "*"+ "/" +CommentContent = ( [^*] | \*+ [^/*] )* +EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [:jletter:][:jletterdigit:]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* + +/* floating point literals */ +FloatLiteral = ({FLit1}|{FLit2}|{FLit3}) {Exponent}? [fF] + +FLit1 = [0-9]+ \. [0-9]* +FLit2 = \. [0-9]+ +FLit3 = [0-9]+ +Exponent = [eE] [+-]? [0-9]+ + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +// Create states for Double Quoted and Single Quoted Strings +%state DQ_STRING, SQ_STRING + +Reserved = + "ADD" | + "ALL" | + "ALLOW REVERSE SCANS" | + "ALTER" | + "ANALYZE" | + "AND" | + "AS" | + "ASC" | + "AUTOMATIC" | + "BEGIN" | + "BEFORE" | + "BETWEEN" | + "BIGINT" | + "BINARY" | + "BLOB" | + "BOTH" | + "BUFFERPOOL" | + "BY" | + "CACHE" | + "CALL" | + "CASCADE" | + "CASE" | + "CHANGE" | + "CHAR" | + "CHARACTER" | + "CHECK" | + "COLLATE" | + "COLUMN" | + "COMMIT" | + "CONDITION" | + "CONSTANT" | + "CONSTRAINT" | + "CONTINUE" | + "CONVERT" | + "CREATE" | + "CROSS" | + "CURSOR" | + "DATE" | + "DATABASE" | + "DATABASES" | + "DEC" | + "DECIMAL" | + "DECODE" | + "DECLARE" | + "DEFAULT" | + "DELAYED" | + "DELETE" | + "DESC" | + "DESCRIBE" | + "DETERMINISTIC" | + "DISTINCT" | + "DISTINCTROW" | + "DIV" | + "DOUBLE" | + "DROP" | + "DUAL" | + "EACH" | + "ELSE" | + "ELSEIF" | + "ENCLOSED" | + "END" | + "ESCAPED" | + "EXCEPTION" | + "EXISTS" | + "EXIT" | + "EXPLAIN" | + "FALSE" | + "FETCH" | + "FLOAT" | + "FLOAT4" | + "FLOAT8" | + "FOR" | + "FORCE" | + "FOREIGN" | + "FROM" | + "FUNCTION" | + "FULLTEXT" | + "GLOBAL TEMPORARY" | + "GRANT" | + "GROUP" | + "HAVING" | + "IF" | + "IGNORE" | + "IN" | + "INDEX" | + "INFILE" | + "INNER" | + "INOUT" | + "INSENSITIVE" | + "INSERT" | + "INT" | + "INTEGER" | + "INTERVAL" | + "INTO" | + "IS" | + "IS REF CURSOR" | + "ITERATE" | + "JOIN" | + "KEY" | + "KEYS" | + "KILL" | + "LEADING" | + "LEAVE" | + "LEFT" | + "LIKE" | + "LIMIT" | + "LINES" | + "LOAD" | + "LOCK" | + "LONG" | + "LOOP" | + "MATCH" | + "MERGE" | + "MINVALUE" | + "MAXVALUE" | + "MOD" | + "MODIFIES" | + "NATURAL" | + "NOCYCLE" | + "NOORDER" | + "NOT" | + "NULL" | + "NUMERIC" | + "NUMBER" | + "ON" | + "OPEN" | + "OPTIMIZE" | + "OPTION" | + "OPTIONALLY" | + "OR" | + "ORDER" | + "OTHERS" | + "OUT" | + "OUTER" | + "OUTFILE" | + "PACKAGE" | + "PACKAGE BODY" | + "PAGESIZE" | + "PLS_INTEGER" | + "PRAGMA" | + "PRECISION" | + "PRIMARY" | + "PROCEDURE" | + "PURGE" | + "RAISE" | + "READ" | + "READS" | + "REAL" | + "REFERENCES" | + "REGEXP" | + "RELEASE" | + "RENAME" | + "REPEAT" | + "REPLACE" | + "REQUIRE" | + "RESTRICT" | + "RETURN" | + "REVOKE" | + "RIGHT" | + "RLIKE" | + "ROLLBACK" | + "ROWCOUNT" | + "ROWTYPE" | + "SIZE" | + "SCHEMA" | + "SCHEMAS" | + "SELECT" | + "SENSITIVE" | + "SEPARATOR" | + "SEQUENCE" | + "SET" | + "SHOW" | + "SMALLINT" | + "SONAME" | + "SPATIAL" | + "SPECIFIC" | + "SQL" | + "SQLEXCEPTION" | + "SQLSTATE" | + "SQLWARNING" | + "STARTING" | + "SYSDATE" | + "TABLE" | + "TABLESPACE" | + "TERMINATED" | + "THEN" | + "TO" | + "TO_CHAR" | + "TO_DATE" | + "TRAILING" | + "TRIGGER" | + "TRUE" | + "TRUNCATE" | + "TYPE" | + "UNDO" | + "UNION" | + "UNIQUE" | + "UNLOCK" | + "UNSIGNED" | + "UPDATE" | + "USAGE" | + "USE" | + "USER" | + "USING" | + "VALUES" | + "VARBINARY" | + "VARCHAR" | + "VARCHAR2" | + "VARCHARACTER" | + "VARYING" | + "WHEN" | + "WHERE" | + "WHILE" | + "WITH" | + "WRITE" | + "XOR" | + "ZEROFILL" +%% + + { + + /* keywords */ + {Reserved} { return token(TokenType.KEYWORD); } + + /* operators */ + + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." | + "@" | + "=" | + ">" | + "<" | + "!" | + "~" | + "?" | + ":" { return token(TokenType.OPERATOR); } + + /* string literal */ + \" { + yybegin(DQ_STRING); + tokenStart = yychar; + tokenLength = 1; + } + \' { + yybegin(SQ_STRING); + tokenStart = yychar; + tokenLength = 1; + } + + /* numeric literals */ + + {DecIntegerLiteral} | + + {FloatLiteral} { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace}+ { /* skip */ } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } + +} + + { + {StringCharacter}+ { tokenLength += yylength(); } + \"\" { tokenLength += 2; } + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } +} + + { + {SingleCharacter}+ { tokenLength += yylength(); } + \'\' { tokenLength += 2; } + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(YYINITIAL); } + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } +} + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/tal.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/tal.flex index 74cb7272e..973f5b108 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/tal.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/tal.flex @@ -1,166 +1,166 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class TALLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token -%caseless - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public TALLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } -%} - -/* main character classes */ -LineTerminator = \r|\n|\r\n -InputCharacter = [^\r\n] - -WhiteSpace = {LineTerminator} | [ \t\f]+ - -/* comments */ -Comment = {TraditionalComment} | {EndOfLineComment} - -TraditionalComment = "!" [^\r\n!]* ( "!" | {LineTerminator} ) -EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? - -/* identifiers */ -Identifier = [A-Za-z_][A-Za-z0-9\^_]* - -/* integer literals */ -DecIntegerLiteral = 0 | [1-9][0-9]* - -HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} -HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] -HexDigit = [0-9a-fA-F] - -OctIntegerLiteral = "%" [1-3]? {OctDigit} {1,15} -OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] -OctDigit = [0-7] - -FixedLiteral = DecIntegerLiteral [fF] -DoubleLiteral = DecIntegerLiteral [dD] - -/* string and character literals */ -StringCharacter = [^\r\n\"\\] -SingleCharacter = [^\r\n\'\\] - -%% - - { - - /* keywords */ - "begin" | - "end" | - "struct" | - "fieldalign" | - "shared" | - "shared2" | - "literal" | - "for" | - "do" | - "while" | - "?page" | - "?section" { return token(TokenType.KEYWORD); } - - "int" | - "string" | - "int(32)" | - "fixed" | - "byte" | - "float" | - "filler" { return token(TokenType.TYPE); } - - - "(" | - ")" | - "{" | - "}" | - "[" | - "]" | - ";" | - "," | - "." | - "=" | - ">" | - "<" | - "!" | - "?" | - ":" | - ":=" | - "':='" | - "'=:'" | - "<>" | - "+" | - "-" | - "*" | - "/" | - "<<" | - ">>" { return token(TokenType.OPERATOR); } - - /* string literal */ - \"{StringCharacter}+\" { return token(TokenType.STRING); } - - /* character literal */ - \'{SingleCharacter}\' { return token(TokenType.STRING); } - - /* numeric literals */ - - {DecIntegerLiteral} | - - {HexIntegerLiteral} | - {HexLongLiteral} | - - {OctIntegerLiteral} | - {OctLongLiteral} | - - {FixedLiteral} | - {DoubleLiteral} { return token(TokenType.NUMBER); } - - /* comments */ - {Comment} { return token(TokenType.COMMENT); } - - /* whitespace */ - {WhiteSpace} { } - - /* identifiers */ - {Identifier} { return token(TokenType.IDENTIFIER); } -} - - -/* error fallback */ -.|\n { } -<> { return null; } - +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class TALLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token +%caseless + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public TALLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } +%} + +/* main character classes */ +LineTerminator = \r|\n|\r\n +InputCharacter = [^\r\n] + +WhiteSpace = {LineTerminator} | [ \t\f]+ + +/* comments */ +Comment = {TraditionalComment} | {EndOfLineComment} + +TraditionalComment = "!" [^\r\n!]* ( "!" | {LineTerminator} ) +EndOfLineComment = "--" {InputCharacter}* {LineTerminator}? + +/* identifiers */ +Identifier = [A-Za-z_][A-Za-z0-9\^_]* + +/* integer literals */ +DecIntegerLiteral = 0 | [1-9][0-9]* + +HexIntegerLiteral = 0 [xX] 0* {HexDigit} {1,8} +HexLongLiteral = 0 [xX] 0* {HexDigit} {1,16} [lL] +HexDigit = [0-9a-fA-F] + +OctIntegerLiteral = "%" [1-3]? {OctDigit} {1,15} +OctLongLiteral = 0+ 1? {OctDigit} {1,21} [lL] +OctDigit = [0-7] + +FixedLiteral = DecIntegerLiteral [fF] +DoubleLiteral = DecIntegerLiteral [dD] + +/* string and character literals */ +StringCharacter = [^\r\n\"\\] +SingleCharacter = [^\r\n\'\\] + +%% + + { + + /* keywords */ + "begin" | + "end" | + "struct" | + "fieldalign" | + "shared" | + "shared2" | + "literal" | + "for" | + "do" | + "while" | + "?page" | + "?section" { return token(TokenType.KEYWORD); } + + "int" | + "string" | + "int(32)" | + "fixed" | + "byte" | + "float" | + "filler" { return token(TokenType.TYPE); } + + + "(" | + ")" | + "{" | + "}" | + "[" | + "]" | + ";" | + "," | + "." | + "=" | + ">" | + "<" | + "!" | + "?" | + ":" | + ":=" | + "':='" | + "'=:'" | + "<>" | + "+" | + "-" | + "*" | + "/" | + "<<" | + ">>" { return token(TokenType.OPERATOR); } + + /* string literal */ + \"{StringCharacter}+\" { return token(TokenType.STRING); } + + /* character literal */ + \'{SingleCharacter}\' { return token(TokenType.STRING); } + + /* numeric literals */ + + {DecIntegerLiteral} | + + {HexIntegerLiteral} | + {HexLongLiteral} | + + {OctIntegerLiteral} | + {OctLongLiteral} | + + {FixedLiteral} | + {DoubleLiteral} { return token(TokenType.NUMBER); } + + /* comments */ + {Comment} { return token(TokenType.COMMENT); } + + /* whitespace */ + {WhiteSpace} { } + + /* identifiers */ + {Identifier} { return token(TokenType.IDENTIFIER); } +} + + +/* error fallback */ +.|\n { } +<> { return null; } + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xhtml.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xhtml.flex index 07b9bb166..cdf456789 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xhtml.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xhtml.flex @@ -1,371 +1,371 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class XHTMLLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token -%ignorecase - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public XHTMLLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte TAG_OPEN = 1; - private static final byte TAG_CLOSE = -1; - - private static final byte INSTR_OPEN = 2; - private static final byte INSTR_CLOSE = -2; - - private static final byte CDATA_OPEN = 3; - private static final byte CDATA_CLOSE = -3; - - private static final byte COMMENT_OPEN = 4; - private static final byte COMMENT_CLOSE = -4; -%} - -%xstate COMMENT, CDATA, TAG, INSTR, DOCTYPE - -/* main character classes */ - -/* white space */ -S = (\u0020 | \u0009 | \u000D | \u000A)+ - -/* characters */ -// Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] - -/* comments */ -CommentStart = "" - -NameStartChar = ":" | [A-Z] | "_" | [a-z] -NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 -Name = {NameStartChar} {NameChar}* - -/* XML Processing Instructions */ -InstrStart = "" - -DocTypeStart = "" - -/* Tags */ -OpenTagStart = "<" {Name} -OpenTagClose = "/>" -OpenTagEnd = ">" -CloseTag = "" - -/* 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 = "" -HTMLAttribute = {HTMLAttrName} "=" - -/* string and character literals */ -DQuoteStringChar = [^\r\n\"] -SQuoteStringChar = [^\r\n\'] - -%% - - { - - "&" [a-z]+ ";" | - "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } - - {InstrStart} { - yybegin(INSTR); - return token(TokenType.TYPE2, INSTR_OPEN); - } - {DocTypeStart} { - yybegin(DOCTYPE); - return token(TokenType.TYPE2, INSTR_OPEN); - } - {HTMLOpenTagStart} { - yybegin(TAG); - return token(TokenType.KEYWORD2, TAG_OPEN); - } - {HTMLCloseTag} { return token(TokenType.KEYWORD2, TAG_CLOSE); } - {OpenTagStart} { - yybegin(TAG); - return token(TokenType.KEYWORD, TAG_OPEN); - } - {CloseTag} { return token(TokenType.KEYWORD, TAG_CLOSE); } - {CommentStart} { - yybegin(COMMENT); - return token(TokenType.COMMENT2, COMMENT_OPEN); - } - {CDataStart} { - yybegin(CDATA); - return token(TokenType.COMMENT2, CDATA_OPEN); - } -} - - { - {Attribute} { return token(TokenType.IDENTIFIER); } - - \"{DQuoteStringChar}*\" | - \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } - - {InstrEnd} { - yybegin(YYINITIAL); - return token(TokenType.TYPE2, INSTR_CLOSE); - } -} - - { - [^>]* { } - - {OpenTagEnd} { - yybegin(YYINITIAL); - return token(TokenType.TYPE2, INSTR_CLOSE); - } -} - - { - {HTMLAttribute} { return token(TokenType.KEYWORD2); } - {Attribute} { return token(TokenType.IDENTIFIER); } - - \"{DQuoteStringChar}*\" | - \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } - - - {OpenTagClose} { - yybegin(YYINITIAL); - return token(TokenType.KEYWORD, TAG_CLOSE); -} - - {OpenTagEnd} { - yybegin(YYINITIAL); - return token(TokenType.KEYWORD); - } -} - - { - {CommentEnd} { - yybegin(YYINITIAL); - return token(TokenType.COMMENT2, COMMENT_CLOSE); - } - ~{CommentEnd} { - yypushback(3); - return token(TokenType.COMMENT); - } -} - - { - {CDataEnd} { - yybegin(YYINITIAL); - return token(TokenType.COMMENT2, CDATA_CLOSE); - } - ~{CDataEnd} { - yypushback(3); - return token(TokenType.COMMENT); - } -} - - { -/* error fallback */ - .|\n { } - <> { return null; } -} +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class XHTMLLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token +%ignorecase + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public XHTMLLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte TAG_OPEN = 1; + private static final byte TAG_CLOSE = -1; + + private static final byte INSTR_OPEN = 2; + private static final byte INSTR_CLOSE = -2; + + private static final byte CDATA_OPEN = 3; + private static final byte CDATA_CLOSE = -3; + + private static final byte COMMENT_OPEN = 4; + private static final byte COMMENT_CLOSE = -4; +%} + +%xstate COMMENT, CDATA, TAG, INSTR, DOCTYPE + +/* main character classes */ + +/* white space */ +S = (\u0020 | \u0009 | \u000D | \u000A)+ + +/* characters */ +// Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] + +/* comments */ +CommentStart = "" + +NameStartChar = ":" | [A-Z] | "_" | [a-z] +NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 +Name = {NameStartChar} {NameChar}* + +/* XML Processing Instructions */ +InstrStart = "" + +DocTypeStart = "" + +/* Tags */ +OpenTagStart = "<" {Name} +OpenTagClose = "/>" +OpenTagEnd = ">" +CloseTag = "" + +/* 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 = "" +HTMLAttribute = {HTMLAttrName} "=" + +/* string and character literals */ +DQuoteStringChar = [^\r\n\"] +SQuoteStringChar = [^\r\n\'] + +%% + + { + + "&" [a-z]+ ";" | + "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } + + {InstrStart} { + yybegin(INSTR); + return token(TokenType.TYPE2, INSTR_OPEN); + } + {DocTypeStart} { + yybegin(DOCTYPE); + return token(TokenType.TYPE2, INSTR_OPEN); + } + {HTMLOpenTagStart} { + yybegin(TAG); + return token(TokenType.KEYWORD2, TAG_OPEN); + } + {HTMLCloseTag} { return token(TokenType.KEYWORD2, TAG_CLOSE); } + {OpenTagStart} { + yybegin(TAG); + return token(TokenType.KEYWORD, TAG_OPEN); + } + {CloseTag} { return token(TokenType.KEYWORD, TAG_CLOSE); } + {CommentStart} { + yybegin(COMMENT); + return token(TokenType.COMMENT2, COMMENT_OPEN); + } + {CDataStart} { + yybegin(CDATA); + return token(TokenType.COMMENT2, CDATA_OPEN); + } +} + + { + {Attribute} { return token(TokenType.IDENTIFIER); } + + \"{DQuoteStringChar}*\" | + \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } + + {InstrEnd} { + yybegin(YYINITIAL); + return token(TokenType.TYPE2, INSTR_CLOSE); + } +} + + { + [^>]* { } + + {OpenTagEnd} { + yybegin(YYINITIAL); + return token(TokenType.TYPE2, INSTR_CLOSE); + } +} + + { + {HTMLAttribute} { return token(TokenType.KEYWORD2); } + {Attribute} { return token(TokenType.IDENTIFIER); } + + \"{DQuoteStringChar}*\" | + \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } + + + {OpenTagClose} { + yybegin(YYINITIAL); + return token(TokenType.KEYWORD, TAG_CLOSE); +} + + {OpenTagEnd} { + yybegin(YYINITIAL); + return token(TokenType.KEYWORD); + } +} + + { + {CommentEnd} { + yybegin(YYINITIAL); + return token(TokenType.COMMENT2, COMMENT_CLOSE); + } + ~{CommentEnd} { + yypushback(3); + return token(TokenType.COMMENT); + } +} + + { + {CDataEnd} { + yybegin(YYINITIAL); + return token(TokenType.COMMENT2, CDATA_CLOSE); + } + ~{CDataEnd} { + yypushback(3); + return token(TokenType.COMMENT); + } +} + + { +/* error fallback */ + .|\n { } + <> { return null; } +} diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xml.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xml.flex index 741b71773..5fbf40981 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xml.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xml.flex @@ -1,196 +1,196 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jsyntaxpane.lexers; - - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class XmlLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public XmlLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte TAG_OPEN = 1; - private static final byte TAG_CLOSE = -1; - - private static final byte INSTR_OPEN = 2; - private static final byte INSTR_CLOSE = -2; - - private static final byte CDATA_OPEN = 3; - private static final byte CDATA_CLOSE = -3; - - private static final byte COMMENT_OPEN = 4; - private static final byte COMMENT_CLOSE = -4; -%} - -%xstate COMMENT, CDATA, TAG, INSTR - -/* main character classes */ - -/* white space */ -S = (\u0020 | \u0009 | \u000D | \u000A)+ - -/* characters */ - -Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] - -/* comments */ -CommentStart = "" - -NameStartChar = ":" | [A-Z] | "_" | [a-z] -NameStartCharUnicode = [\u00C0-\u00D6] | - [\u00D8-\u00F6] | - [\u00F8-\u02FF] | - [\u0370-\u037D] | - [\u037F-\u1FFF] | - [\u200C-\u200D] | - [\u2070-\u218F] | - [\u2C00-\u2FEF] | - [\u3001-\uD7FF] | - [\uF900-\uFDCF] | - [\uFDF0-\uFFFD] | - [\u10000-\uEFFFF] - -NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 -NameCharUnicode = [\u0300-\u036F] | [\u0203F-\u2040] -Name = {NameStartChar} {NameChar}* -NameUnicode = ({NameStartChar}|{NameStartCharUnicode}) ({NameChar}|{NameCharUnicode})* - -/* XML Processing Instructions */ -InstrStart = "" - -/* CDATA */ -CDataStart = "" - -/* Tags */ -OpenTagStart = "<" {Name} -OpenTagClose = "/>" -OpenTagEnd = ">" - -CloseTag = "" - -/* attribute */ -Attribute = {Name} "=" - -/* string and character literals */ -DQuoteStringChar = [^\r\n\"] -SQuoteStringChar = [^\r\n\'] - -%% - - { - - "&" [a-z]+ ";" | - "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } - - {InstrStart} { - yybegin(INSTR); - return token(TokenType.TYPE2, INSTR_OPEN); - } - {OpenTagStart} { - yybegin(TAG); - return token(TokenType.TYPE, TAG_OPEN); - } - {CloseTag} { return token(TokenType.TYPE, TAG_CLOSE); } - {CommentStart} { - yybegin(COMMENT); - return token(TokenType.COMMENT2, COMMENT_OPEN); - } - {CDataStart} { - yybegin(CDATA); - return token(TokenType.COMMENT2, CDATA_OPEN); - } -} - - { - {Attribute} { return token(TokenType.IDENTIFIER); } - - \"{DQuoteStringChar}*\" | - \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } - - {InstrEnd} { - yybegin(YYINITIAL); - return token(TokenType.TYPE2, INSTR_CLOSE); - } - } - - { - {Attribute} { return token(TokenType.IDENTIFIER); } - - \"{DQuoteStringChar}*\" | - \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } - - - {OpenTagClose} { - yybegin(YYINITIAL); - return token(TokenType.TYPE, TAG_CLOSE); -} - - {OpenTagEnd} { - yybegin(YYINITIAL); - return token(TokenType.TYPE); - } -} - - { - {CommentEnd} { - yybegin(YYINITIAL); - return token(TokenType.COMMENT2, COMMENT_CLOSE); - } - ~{CommentEnd} { - yypushback(3); - return token(TokenType.COMMENT); - } -} - - { - {CDataEnd} { - yybegin(YYINITIAL); - return token(TokenType.COMMENT2, CDATA_CLOSE); - } - ~{CDataEnd} { - yypushback(3); - return token(TokenType.COMMENT); - } -} - - { -/* error fallback */ - .|\n { } - <> { return null; } -} +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jsyntaxpane.lexers; + + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class XmlLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public XmlLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte TAG_OPEN = 1; + private static final byte TAG_CLOSE = -1; + + private static final byte INSTR_OPEN = 2; + private static final byte INSTR_CLOSE = -2; + + private static final byte CDATA_OPEN = 3; + private static final byte CDATA_CLOSE = -3; + + private static final byte COMMENT_OPEN = 4; + private static final byte COMMENT_CLOSE = -4; +%} + +%xstate COMMENT, CDATA, TAG, INSTR + +/* main character classes */ + +/* white space */ +S = (\u0020 | \u0009 | \u000D | \u000A)+ + +/* characters */ + +Char = \u0009 | \u000A | \u000D | [\u0020-\uD7FF] | [\uE000-\uFFFD] | [\u10000-\u10FFFF] + +/* comments */ +CommentStart = "" + +NameStartChar = ":" | [A-Z] | "_" | [a-z] +NameStartCharUnicode = [\u00C0-\u00D6] | + [\u00D8-\u00F6] | + [\u00F8-\u02FF] | + [\u0370-\u037D] | + [\u037F-\u1FFF] | + [\u200C-\u200D] | + [\u2070-\u218F] | + [\u2C00-\u2FEF] | + [\u3001-\uD7FF] | + [\uF900-\uFDCF] | + [\uFDF0-\uFFFD] | + [\u10000-\uEFFFF] + +NameChar = {NameStartChar} | "-" | "." | [0-9] | \u00B7 +NameCharUnicode = [\u0300-\u036F] | [\u0203F-\u2040] +Name = {NameStartChar} {NameChar}* +NameUnicode = ({NameStartChar}|{NameStartCharUnicode}) ({NameChar}|{NameCharUnicode})* + +/* XML Processing Instructions */ +InstrStart = "" + +/* CDATA */ +CDataStart = "" + +/* Tags */ +OpenTagStart = "<" {Name} +OpenTagClose = "/>" +OpenTagEnd = ">" + +CloseTag = "" + +/* attribute */ +Attribute = {Name} "=" + +/* string and character literals */ +DQuoteStringChar = [^\r\n\"] +SQuoteStringChar = [^\r\n\'] + +%% + + { + + "&" [a-z]+ ";" | + "&#" [:digit:]+ ";" { return token(TokenType.KEYWORD2); } + + {InstrStart} { + yybegin(INSTR); + return token(TokenType.TYPE2, INSTR_OPEN); + } + {OpenTagStart} { + yybegin(TAG); + return token(TokenType.TYPE, TAG_OPEN); + } + {CloseTag} { return token(TokenType.TYPE, TAG_CLOSE); } + {CommentStart} { + yybegin(COMMENT); + return token(TokenType.COMMENT2, COMMENT_OPEN); + } + {CDataStart} { + yybegin(CDATA); + return token(TokenType.COMMENT2, CDATA_OPEN); + } +} + + { + {Attribute} { return token(TokenType.IDENTIFIER); } + + \"{DQuoteStringChar}*\" | + \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } + + {InstrEnd} { + yybegin(YYINITIAL); + return token(TokenType.TYPE2, INSTR_CLOSE); + } + } + + { + {Attribute} { return token(TokenType.IDENTIFIER); } + + \"{DQuoteStringChar}*\" | + \'{SQuoteStringChar}*\' { return token(TokenType.STRING); } + + + {OpenTagClose} { + yybegin(YYINITIAL); + return token(TokenType.TYPE, TAG_CLOSE); +} + + {OpenTagEnd} { + yybegin(YYINITIAL); + return token(TokenType.TYPE); + } +} + + { + {CommentEnd} { + yybegin(YYINITIAL); + return token(TokenType.COMMENT2, COMMENT_CLOSE); + } + ~{CommentEnd} { + yypushback(3); + return token(TokenType.COMMENT); + } +} + + { + {CDataEnd} { + yybegin(YYINITIAL); + return token(TokenType.COMMENT2, CDATA_CLOSE); + } + ~{CDataEnd} { + yypushback(3); + return token(TokenType.COMMENT); + } +} + + { +/* error fallback */ + .|\n { } + <> { return null; } +} diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xpath.flex b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xpath.flex index fe514e1c4..5c6b035ec 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xpath.flex +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/jflex/jsyntaxpane/lexers/xpath.flex @@ -1,266 +1,266 @@ -/* - * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License - * at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This flex file originally donated to the project by HeyChinaski - * - */ - -package jsyntaxpane.lexers; - -import jsyntaxpane.Token; -import jsyntaxpane.TokenType; - -%% - -%public -%class XPathLexer -%extends DefaultJFlexLexer -%final -%unicode -%char -%type Token - - -%{ - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public XPathLexer() { - super(); - } - - @Override - public int yychar() { - return yychar; - } - - private static final byte PARAN = 1; - private static final byte BRACKET = 2; - private static final byte CURLY = 3; - -%} - -Digits = [0-9]+ -Letter = {BaseChar} | {Ideographic} -BaseChar = [\u0041-\u005A] | [\u0061-\u007A] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] | [\u0100-\u0131] | [\u0134-\u013E] | [\u0141-\u0148] | [\u014A-\u017E] | [\u0180-\u01C3] | [\u01CD-\u01F0] | [\u01F4-\u01F5] | [\u01FA-\u0217] | [\u0250-\u02A8] | [\u02BB-\u02C1] | \u0386 | [\u0388-\u038A] | \u038C | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D6] | \u03DA | \u03DC | \u03DE | \u03E0 | [\u03E2-\u03F3] | [\u0401-\u040C] | [\u040E-\u044F] | [\u0451-\u045C] | [\u045E-\u0481] | [\u0490-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04EB] | [\u04EE-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | \u0559 | [\u0561-\u0586] | [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0641-\u064A] | [\u0671-\u06B7] | [\u06BA-\u06BE] | [\u06C0-\u06CE] | [\u06D0-\u06D3] | \u06D5 | [\u06E5-\u06E6] | [\u0905-\u0939] | \u093D | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | \u09B2 | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | \u0A5E | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | \u0A8D | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | \u0ABD | \u0AE0 | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | \u0B3D | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | \u0B9C | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | \u0CDE | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0E01-\u0E2E] | \u0E30 | [\u0E32-\u0E33] | [\u0E40-\u0E45] | [\u0E81-\u0E82] | \u0E84 | [\u0E87-\u0E88] | \u0E8A | \u0E8D | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | \u0EA5 | \u0EA7 | [\u0EAA-\u0EAB] | [\u0EAD-\u0EAE] | \u0EB0 | [\u0EB2-\u0EB3] | \u0EBD | [\u0EC0-\u0EC4] | [\u0F40-\u0F47] | [\u0F49-\u0F69] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | \u1100 | [\u1102-\u1103] | [\u1105-\u1107] | \u1109 | [\u110B-\u110C] | [\u110E-\u1112] | \u113C | \u113E | \u1140 | \u114C | \u114E | \u1150 | [\u1154-\u1155] | \u1159 | [\u115F-\u1161] | \u1163 | \u1165 | \u1167 | \u1169 | [\u116D-\u116E] | [\u1172-\u1173] | \u1175 | \u119E | \u11A8 | \u11AB | [\u11AE-\u11AF] | [\u11B7-\u11B8] | \u11BA | [\u11BC-\u11C2] | \u11EB | \u11F0 | \u11F9 | [\u1E00-\u1E9B] | [\u1EA0-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | \u1F59 | \u1F5B | \u1F5D | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | \u1FBE | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | \u2126 | [\u212A-\u212B] | \u212E | [\u2180-\u2182] | [\u3041-\u3094] | [\u30A1-\u30FA] | [\u3105-\u312C] | [\uAC00-\uD7A3] -Ideographic = [\u4E00-\u9FA5] | \u3007 | [\u3021-\u3029] -NCNameStartChar = {Letter} | "_" -NameStartCharMinusColon = [A-Z] | "_" | [a-z] | [\uC0-\uD6] | [\uD8-\uF6] | [\uF8-\u2FF] | [\u370-\u37D] | [\u37F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] -NCNameChar = {NameStartCharMinusColon} | "-" | "." | [0-9] | \uB7 | [\u0300-\u036F] | [\u203F-\u2040] -NCName = {NCNameStartChar} {NCNameChar}* -LocalPart = {NCName} -UnprefixedName = {LocalPart} -Prefix = {NCName} -PrefixedName = {Prefix} ":" {LocalPart} -QName = {PrefixedName} | {UnprefixedName} -NameTest = "*" | {NCName} ":" "*" | {QName} -VariableReference = "$" {QName} -LineTerminator = \r|\n|\r\n - -NodeType = "comment" - | "text" - | "processing-instruction" - | "node" - -OperatorName = "and" | "or" | "mod" | "div" - -Operator = {OperatorName} | "*" | "/" | "//" | "|" | "+" | "-" | "=" | "!=" | "<" | "<=" | ">" | ">=" - -FunctionName = {QName} - -XPathFunction = "default" - | "node-name" - | "nilled" - | "data" - | "base-uri" - | "document-uri" - | "error" - | "trace" - | "number" - | "abs" - | "ceiling" - | "floor" - | "round" - | "round-half-to-even" - | "string" - | "codepoints-to-string" - | "string-to-codepoints" - | "codepoint-equal" - | "compare" - | "concat" - | "string-join" - | "substring" - | "string-length" - | "normalize-space" - | "normalize-unicode" - | "upper-case" - | "lower-case" - | "translate" - | "escape-uri" - | "contains" - | "starts-with" - | "ends-with" - | "substring-before" - | "substring-after" - | "matches" - | "replace" - | "tokenize" - | "resolve-uri" - | "boolean" - | "not" - | "true" - | "false" - | "dateTime" - | "years-from-duration" - | "months-from-duration" - | "days-from-duration" - | "hours-from-duration" - | "minutes-from-duration" - | "seconds-from-duration" - | "year-from-dateTime" - | "month-from-dateTime" - | "day-from-dateTime" - | "hours-from-dateTime" - | "minutes-from-dateTime" - | "seconds-from-dateTime" - | "timezone-from-dateTime" - | "year-from-date" - | "month-from-date" - | "day-from-date" - | "timezone-from-date" - | "hours-from-time" - | "minutes-from-time" - | "seconds-from-time" - | "timezone-from-time" - | "adjust-dateTime-to-timezone" - | "adjust-date-to-timezone" - | "adjust-time-to-timezone" - | "QName" - | "local-name-from-QName" - | "namespace-uri-from-QName" - | "namespace-uri-for-prefix" - | "in-scope-prefixes" - | "resolve-QName" - | "name" - | "local-name" - | "namespace-uri" - | "lang" - | "root" - | "index-of" - | "remove" - | "empty" - | "exists" - | "distinct-values" - | "insert-before" - | "reverse" - | "subsequence" - | "unordered" - | "zero-or-one" - | "one-or-more" - | "exactly-one" - | "deep-equal" - | "count" - | "avg" - | "max" - | "min" - | "sum" - | "id" - | "idref" - | "doc" - | "doc-available" - | "collection" - | "position" - | "last" - | "current-dateTime" - | "current-date" - | "current-time" - | "implicit-timezone" - | "default-collation" - | "static-base-uri" - -AxisName = "ancestor" - | "ancestor-or-self" - | "attribute" - | "child" - | "descendant" - | "descendant-or-self" - | "following" - | "following-sibling" - | "namespace" - | "parent" - | "preceding" - | "preceding-sibling" - | "self" - -Number = {Digits} | {Digits} "." {Digits} - -S = [\u20] | [\u9] | [\uD] | [\uA] - -%state STRING_DOUBLE, STRING_SINGLE - -%% - - { - {VariableReference} { return token(TokenType.IDENTIFIER); } - {Number} { return token(TokenType.NUMBER); } - {AxisName} { return token(TokenType.TYPE); } - "(" { return token(TokenType.OPERATOR, PARAN); } - ")" { return token(TokenType.OPERATOR, -PARAN); } - "{" { return token(TokenType.OPERATOR, CURLY); } - "}" { return token(TokenType.OPERATOR, -CURLY); } - "[" { return token(TokenType.OPERATOR, BRACKET); } - "]" { return token(TokenType.OPERATOR, -BRACKET); } - "." | ".." | "@" | "," | "::" { return token(TokenType.OPERATOR); } - {Operator} { return token(TokenType.OPERATOR); } - {NodeType} { return token(TokenType.KEYWORD); } - {XPathFunction} { return token(TokenType.KEYWORD2); } - {FunctionName} { return token(TokenType.IDENTIFIER); } - {NameTest} { return token(TokenType.IDENTIFIER); } - - /* string literal */ - \" { - yybegin(STRING_DOUBLE); - tokenStart = yychar; - tokenLength = 1; - } - - /* string literal */ - \' { - yybegin(STRING_SINGLE); - tokenStart = yychar; - tokenLength = 1; - } - ":" | {S} | "\"" {} - . | {LineTerminator} { /* skip */ } -} - - { - \" { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - [^\"] { tokenLength += yylength(); } -} - - { - \' { - yybegin(YYINITIAL); - // length also includes the trailing quote - return token(TokenType.STRING, tokenStart, tokenLength + 1); - } - - [^\'] { tokenLength += yylength(); } -} +/* + * Copyright 2008 Ayman Al-Sairafi ayman.alsairafi@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License + * at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This flex file originally donated to the project by HeyChinaski + * + */ + +package jsyntaxpane.lexers; + +import jsyntaxpane.Token; +import jsyntaxpane.TokenType; + +%% + +%public +%class XPathLexer +%extends DefaultJFlexLexer +%final +%unicode +%char +%type Token + + +%{ + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public XPathLexer() { + super(); + } + + @Override + public int yychar() { + return yychar; + } + + private static final byte PARAN = 1; + private static final byte BRACKET = 2; + private static final byte CURLY = 3; + +%} + +Digits = [0-9]+ +Letter = {BaseChar} | {Ideographic} +BaseChar = [\u0041-\u005A] | [\u0061-\u007A] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] | [\u0100-\u0131] | [\u0134-\u013E] | [\u0141-\u0148] | [\u014A-\u017E] | [\u0180-\u01C3] | [\u01CD-\u01F0] | [\u01F4-\u01F5] | [\u01FA-\u0217] | [\u0250-\u02A8] | [\u02BB-\u02C1] | \u0386 | [\u0388-\u038A] | \u038C | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D6] | \u03DA | \u03DC | \u03DE | \u03E0 | [\u03E2-\u03F3] | [\u0401-\u040C] | [\u040E-\u044F] | [\u0451-\u045C] | [\u045E-\u0481] | [\u0490-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04EB] | [\u04EE-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | \u0559 | [\u0561-\u0586] | [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0641-\u064A] | [\u0671-\u06B7] | [\u06BA-\u06BE] | [\u06C0-\u06CE] | [\u06D0-\u06D3] | \u06D5 | [\u06E5-\u06E6] | [\u0905-\u0939] | \u093D | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | \u09B2 | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | \u0A5E | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | \u0A8D | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | \u0ABD | \u0AE0 | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | \u0B3D | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | \u0B9C | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | \u0CDE | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0E01-\u0E2E] | \u0E30 | [\u0E32-\u0E33] | [\u0E40-\u0E45] | [\u0E81-\u0E82] | \u0E84 | [\u0E87-\u0E88] | \u0E8A | \u0E8D | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | \u0EA5 | \u0EA7 | [\u0EAA-\u0EAB] | [\u0EAD-\u0EAE] | \u0EB0 | [\u0EB2-\u0EB3] | \u0EBD | [\u0EC0-\u0EC4] | [\u0F40-\u0F47] | [\u0F49-\u0F69] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | \u1100 | [\u1102-\u1103] | [\u1105-\u1107] | \u1109 | [\u110B-\u110C] | [\u110E-\u1112] | \u113C | \u113E | \u1140 | \u114C | \u114E | \u1150 | [\u1154-\u1155] | \u1159 | [\u115F-\u1161] | \u1163 | \u1165 | \u1167 | \u1169 | [\u116D-\u116E] | [\u1172-\u1173] | \u1175 | \u119E | \u11A8 | \u11AB | [\u11AE-\u11AF] | [\u11B7-\u11B8] | \u11BA | [\u11BC-\u11C2] | \u11EB | \u11F0 | \u11F9 | [\u1E00-\u1E9B] | [\u1EA0-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | \u1F59 | \u1F5B | \u1F5D | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | \u1FBE | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | \u2126 | [\u212A-\u212B] | \u212E | [\u2180-\u2182] | [\u3041-\u3094] | [\u30A1-\u30FA] | [\u3105-\u312C] | [\uAC00-\uD7A3] +Ideographic = [\u4E00-\u9FA5] | \u3007 | [\u3021-\u3029] +NCNameStartChar = {Letter} | "_" +NameStartCharMinusColon = [A-Z] | "_" | [a-z] | [\uC0-\uD6] | [\uD8-\uF6] | [\uF8-\u2FF] | [\u370-\u37D] | [\u37F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] +NCNameChar = {NameStartCharMinusColon} | "-" | "." | [0-9] | \uB7 | [\u0300-\u036F] | [\u203F-\u2040] +NCName = {NCNameStartChar} {NCNameChar}* +LocalPart = {NCName} +UnprefixedName = {LocalPart} +Prefix = {NCName} +PrefixedName = {Prefix} ":" {LocalPart} +QName = {PrefixedName} | {UnprefixedName} +NameTest = "*" | {NCName} ":" "*" | {QName} +VariableReference = "$" {QName} +LineTerminator = \r|\n|\r\n + +NodeType = "comment" + | "text" + | "processing-instruction" + | "node" + +OperatorName = "and" | "or" | "mod" | "div" + +Operator = {OperatorName} | "*" | "/" | "//" | "|" | "+" | "-" | "=" | "!=" | "<" | "<=" | ">" | ">=" + +FunctionName = {QName} + +XPathFunction = "default" + | "node-name" + | "nilled" + | "data" + | "base-uri" + | "document-uri" + | "error" + | "trace" + | "number" + | "abs" + | "ceiling" + | "floor" + | "round" + | "round-half-to-even" + | "string" + | "codepoints-to-string" + | "string-to-codepoints" + | "codepoint-equal" + | "compare" + | "concat" + | "string-join" + | "substring" + | "string-length" + | "normalize-space" + | "normalize-unicode" + | "upper-case" + | "lower-case" + | "translate" + | "escape-uri" + | "contains" + | "starts-with" + | "ends-with" + | "substring-before" + | "substring-after" + | "matches" + | "replace" + | "tokenize" + | "resolve-uri" + | "boolean" + | "not" + | "true" + | "false" + | "dateTime" + | "years-from-duration" + | "months-from-duration" + | "days-from-duration" + | "hours-from-duration" + | "minutes-from-duration" + | "seconds-from-duration" + | "year-from-dateTime" + | "month-from-dateTime" + | "day-from-dateTime" + | "hours-from-dateTime" + | "minutes-from-dateTime" + | "seconds-from-dateTime" + | "timezone-from-dateTime" + | "year-from-date" + | "month-from-date" + | "day-from-date" + | "timezone-from-date" + | "hours-from-time" + | "minutes-from-time" + | "seconds-from-time" + | "timezone-from-time" + | "adjust-dateTime-to-timezone" + | "adjust-date-to-timezone" + | "adjust-time-to-timezone" + | "QName" + | "local-name-from-QName" + | "namespace-uri-from-QName" + | "namespace-uri-for-prefix" + | "in-scope-prefixes" + | "resolve-QName" + | "name" + | "local-name" + | "namespace-uri" + | "lang" + | "root" + | "index-of" + | "remove" + | "empty" + | "exists" + | "distinct-values" + | "insert-before" + | "reverse" + | "subsequence" + | "unordered" + | "zero-or-one" + | "one-or-more" + | "exactly-one" + | "deep-equal" + | "count" + | "avg" + | "max" + | "min" + | "sum" + | "id" + | "idref" + | "doc" + | "doc-available" + | "collection" + | "position" + | "last" + | "current-dateTime" + | "current-date" + | "current-time" + | "implicit-timezone" + | "default-collation" + | "static-base-uri" + +AxisName = "ancestor" + | "ancestor-or-self" + | "attribute" + | "child" + | "descendant" + | "descendant-or-self" + | "following" + | "following-sibling" + | "namespace" + | "parent" + | "preceding" + | "preceding-sibling" + | "self" + +Number = {Digits} | {Digits} "." {Digits} + +S = [\u20] | [\u9] | [\uD] | [\uA] + +%state STRING_DOUBLE, STRING_SINGLE + +%% + + { + {VariableReference} { return token(TokenType.IDENTIFIER); } + {Number} { return token(TokenType.NUMBER); } + {AxisName} { return token(TokenType.TYPE); } + "(" { return token(TokenType.OPERATOR, PARAN); } + ")" { return token(TokenType.OPERATOR, -PARAN); } + "{" { return token(TokenType.OPERATOR, CURLY); } + "}" { return token(TokenType.OPERATOR, -CURLY); } + "[" { return token(TokenType.OPERATOR, BRACKET); } + "]" { return token(TokenType.OPERATOR, -BRACKET); } + "." | ".." | "@" | "," | "::" { return token(TokenType.OPERATOR); } + {Operator} { return token(TokenType.OPERATOR); } + {NodeType} { return token(TokenType.KEYWORD); } + {XPathFunction} { return token(TokenType.KEYWORD2); } + {FunctionName} { return token(TokenType.IDENTIFIER); } + {NameTest} { return token(TokenType.IDENTIFIER); } + + /* string literal */ + \" { + yybegin(STRING_DOUBLE); + tokenStart = yychar; + tokenLength = 1; + } + + /* string literal */ + \' { + yybegin(STRING_SINGLE); + tokenStart = yychar; + tokenLength = 1; + } + ":" | {S} | "\"" {} + . | {LineTerminator} { /* skip */ } +} + + { + \" { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + [^\"] { tokenLength += yylength(); } +} + + { + \' { + yybegin(YYINITIAL); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); + } + + [^\'] { tokenLength += yylength(); } +} diff --git a/src/com/jpexs/browsers/cache/CacheEntry.java b/src/com/jpexs/browsers/cache/CacheEntry.java index d8fd12c75..e8c19e4df 100644 --- a/src/com/jpexs/browsers/cache/CacheEntry.java +++ b/src/com/jpexs/browsers/cache/CacheEntry.java @@ -1,111 +1,111 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache; - -import com.jpexs.helpers.LimitedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.zip.GZIPInputStream; -import java.util.zip.InflaterInputStream; - -/** - * - * @author JPEXS - */ -public abstract class CacheEntry { - - public abstract String getRequestURL(); - - public abstract Map getResponseHeaders(); - - public abstract String getStatusLine(); - - public abstract String getRequestMethod(); - - public abstract InputStream getResponseRawDataStream(); - - public InputStream getResponseDataStream() { - String contentLengthStr = getHeader("Content-Length"); - int contentLength = -1; - if (contentLengthStr != null) { - try { - contentLength = Integer.parseInt(contentLengthStr); - } catch (NumberFormatException nex) { - } - } - final InputStream rawIs = getResponseRawDataStream(); - InputStream is = rawIs; - if (contentLength > -1) { - is = new LimitedInputStream(is, contentLength); - } - - String encoding = getHeader("Content-Encoding"); - if (encoding != null) { - switch (encoding) { - case "gzip": - try { - is = new GZIPInputStream(is); - } catch (IOException ex) { - is = null; - //ignore - } - break; - case "deflate": - is = new InflaterInputStream(is); - break; - default: //unknown - return null; - } - } - if ("chunked".equals(getHeader("Transfer-Encoding"))) { - is = new ChunkedInputStream(is); - } - return is; - } - - @Override - public String toString() { - return getRequestURL(); - } - - public int getStatusCode() { - String st = getStatusLine(); - if (st == null) { - return 0; - } - String[] parts = st.split(" "); - try { - return Integer.parseInt(parts[1]); - } catch (NumberFormatException nfe) { - return 0; - } - } - - public String getHeader(String header) { - Map m = getResponseHeaders(); - if (m == null) { - return null; - } - for (String k : m.keySet()) { - if (k.toLowerCase().equals(header.toLowerCase())) { - return m.get(k); - } - } - return null; - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache; + +import com.jpexs.helpers.LimitedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.zip.GZIPInputStream; +import java.util.zip.InflaterInputStream; + +/** + * + * @author JPEXS + */ +public abstract class CacheEntry { + + public abstract String getRequestURL(); + + public abstract Map getResponseHeaders(); + + public abstract String getStatusLine(); + + public abstract String getRequestMethod(); + + public abstract InputStream getResponseRawDataStream(); + + public InputStream getResponseDataStream() { + String contentLengthStr = getHeader("Content-Length"); + int contentLength = -1; + if (contentLengthStr != null) { + try { + contentLength = Integer.parseInt(contentLengthStr); + } catch (NumberFormatException nex) { + } + } + final InputStream rawIs = getResponseRawDataStream(); + InputStream is = rawIs; + if (contentLength > -1) { + is = new LimitedInputStream(is, contentLength); + } + + String encoding = getHeader("Content-Encoding"); + if (encoding != null) { + switch (encoding) { + case "gzip": + try { + is = new GZIPInputStream(is); + } catch (IOException ex) { + is = null; + //ignore + } + break; + case "deflate": + is = new InflaterInputStream(is); + break; + default: //unknown + return null; + } + } + if ("chunked".equals(getHeader("Transfer-Encoding"))) { + is = new ChunkedInputStream(is); + } + return is; + } + + @Override + public String toString() { + return getRequestURL(); + } + + public int getStatusCode() { + String st = getStatusLine(); + if (st == null) { + return 0; + } + String[] parts = st.split(" "); + try { + return Integer.parseInt(parts[1]); + } catch (NumberFormatException nfe) { + return 0; + } + } + + public String getHeader(String header) { + Map m = getResponseHeaders(); + if (m == null) { + return null; + } + for (String k : m.keySet()) { + if (k.toLowerCase().equals(header.toLowerCase())) { + return m.get(k); + } + } + return null; + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/BlockFileHeader.java b/src/com/jpexs/browsers/cache/chrome/BlockFileHeader.java index 744fa64e3..28c719ce7 100644 --- a/src/com/jpexs/browsers/cache/chrome/BlockFileHeader.java +++ b/src/com/jpexs/browsers/cache/chrome/BlockFileHeader.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import java.io.IOException; -import java.io.InputStream; - -/** - * - * @author JPEXS - */ -public class BlockFileHeader { - - protected static final int kBlockHeaderSize = 8192; // Two pages: almost 64k entries - - private static final int kMaxBlocks = (kBlockHeaderSize - 80) * 8; - - private final long magic; // c3 ca 04 c1 - - private final long version; // 00 00 02 00 - - private final int this_file; - - private final int next_file; - - private final int entry_size; - - private final int num_entries; - - private final int max_entries; - - private int[] empty = new int[4]; - - private int[] hints = new int[4]; - - private final int updating; - - private int[] user = new int[5]; - - private final long allocation_map[]; - - public BlockFileHeader(InputStream is) throws IOException { - this.allocation_map = new long[kMaxBlocks / 32]; - IndexInputStream iis = new IndexInputStream(is); - magic = iis.readUInt32(); - version = iis.readUInt32(); - this_file = iis.readInt16(); - next_file = iis.readInt16(); - entry_size = iis.readInt32(); - num_entries = iis.readInt32(); - max_entries = iis.readInt32(); - empty = new int[4]; - for (int i = 0; i < 4; i++) { - empty[i] = iis.readInt32(); - } - hints = new int[4]; - for (int i = 0; i < 4; i++) { - hints[i] = iis.readInt32(); - } - updating = iis.readInt32(); - user = new int[5]; - for (int i = 0; i < 5; i++) { - user[i] = iis.readInt32(); - } - for (int i = 0; i < allocation_map.length; i++) { - allocation_map[i] = iis.readUInt32(); - } - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import java.io.IOException; +import java.io.InputStream; + +/** + * + * @author JPEXS + */ +public class BlockFileHeader { + + protected static final int kBlockHeaderSize = 8192; // Two pages: almost 64k entries + + private static final int kMaxBlocks = (kBlockHeaderSize - 80) * 8; + + private final long magic; // c3 ca 04 c1 + + private final long version; // 00 00 02 00 + + private final int this_file; + + private final int next_file; + + private final int entry_size; + + private final int num_entries; + + private final int max_entries; + + private int[] empty = new int[4]; + + private int[] hints = new int[4]; + + private final int updating; + + private int[] user = new int[5]; + + private final long allocation_map[]; + + public BlockFileHeader(InputStream is) throws IOException { + this.allocation_map = new long[kMaxBlocks / 32]; + IndexInputStream iis = new IndexInputStream(is); + magic = iis.readUInt32(); + version = iis.readUInt32(); + this_file = iis.readInt16(); + next_file = iis.readInt16(); + entry_size = iis.readInt32(); + num_entries = iis.readInt32(); + max_entries = iis.readInt32(); + empty = new int[4]; + for (int i = 0; i < 4; i++) { + empty[i] = iis.readInt32(); + } + hints = new int[4]; + for (int i = 0; i < 4; i++) { + hints[i] = iis.readInt32(); + } + updating = iis.readInt32(); + user = new int[5]; + for (int i = 0; i < 5; i++) { + user[i] = iis.readInt32(); + } + for (int i = 0; i < allocation_map.length; i++) { + allocation_map[i] = iis.readUInt32(); + } + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/CacheAddr.java b/src/com/jpexs/browsers/cache/chrome/CacheAddr.java index 0291b2a3a..8178eb7ee 100644 --- a/src/com/jpexs/browsers/cache/chrome/CacheAddr.java +++ b/src/com/jpexs/browsers/cache/chrome/CacheAddr.java @@ -1,151 +1,151 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import com.jpexs.browsers.cache.RafInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public class CacheAddr { - - private static final int EXTERNAL = 0; - - private static final int RANKINGS = 1; - - private static final int BLOCK_256 = 2; - - private static final int BLOCK_1K = 3; - - private static final int BLOCK_4K = 4; - - private static final int BLOCK_FILES = 5; - - private static final int BLOCK_ENTRIES = 6; - - private static final int BLOCK_EVICTED = 7; - - private static final String[] blockNames = new String[]{"EXTERNAL", "RANKINGS", "BLOCK_256", "BLOCK_1K", "BLOCK_4K", "BLOCK_FILES", "BLOCK_ENTRIES", "BLOCK_EVICTED"}; - - private static final int[] blockSizes = new int[]{0, 36, 256, 1024, 4096, 8, 104, 48}; - - private static final long kInitializedMask = 0x80000000L; - - private static final long kFileTypeMask = 0x70000000L; - - private static final int kFileTypeOffset = 28; - - private static final long kReservedBitsMask = 0x0c000000L; - - private static final long kNumBlocksMask = 0x03000000L; - - private static final int kNumBlocksOffset = 24; - - private static final long kFileSelectorMask = 0x00ff0000L; - - private static final int FileSelectorOffset = 16; - - private static final long kStartBlockMask = 0x0000FFFFL; - - private static final long kFileNameMask = 0x0FFFFFFFL; - - private final boolean initialized; - - private final int fileType; - - private int numBlocks; - - private int fileSelector; - - private int startBlock; - - private int fileName; - - private final long val; - - private final File rootPath; - - private final Map dataFiles; - - private final File externalFilesDir; - - public CacheAddr(InputStream is, File rootPath, Map dataFiles, File externalFilesDir) throws IOException { - this.dataFiles = dataFiles; - this.rootPath = rootPath; - this.externalFilesDir = externalFilesDir; - IndexInputStream iis = new IndexInputStream(is); - val = iis.readUInt32(); - initialized = (val & kInitializedMask) == kInitializedMask; - fileType = (int) ((val & kFileTypeMask) >> kFileTypeOffset); - if (fileType == EXTERNAL) { - fileName = (int) (val & kFileNameMask); - } else { - numBlocks = (int) ((val & kNumBlocksMask) >> kNumBlocksOffset); - fileSelector = (int) ((val & kFileSelectorMask) >> FileSelectorOffset); - startBlock = (int) (val & kStartBlockMask); - } - } - - @Override - public String toString() { - - String ft = blockNames[fileType]; - if (fileType == EXTERNAL) { - return ft + ":" + fileName; - } - if (!initialized) { - return "uninitialized"; - } - return ft + ": numBlocks " + numBlocks + " fileSelector " + fileSelector + " startBlock " + startBlock; - } - - public InputStream getInputStream() throws IOException { - if (!initialized) { - return null; - } - switch (fileType) { - case EXTERNAL: - String fileNameStr = Long.toHexString(fileName); - while (fileNameStr.length() < 6) { - fileNameStr = "0" + fileNameStr; - } - fileNameStr = "f_" + fileNameStr; - return new RafInputStream(new RandomAccessFile(new File(externalFilesDir, fileNameStr), "r")); - case BLOCK_1K: - case BLOCK_256: - case BLOCK_4K: - - RandomAccessFile raf; - - if (dataFiles.containsKey(fileSelector)) { - raf = dataFiles.get(fileSelector); - } else { - raf = new RandomAccessFile(rootPath + "\\data_" + fileSelector, "r"); - dataFiles.put(fileSelector, raf); - } - raf.seek(BlockFileHeader.kBlockHeaderSize + startBlock * blockSizes[fileType]); - return new RafInputStream(raf); - } - return null; - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import com.jpexs.browsers.cache.RafInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class CacheAddr { + + private static final int EXTERNAL = 0; + + private static final int RANKINGS = 1; + + private static final int BLOCK_256 = 2; + + private static final int BLOCK_1K = 3; + + private static final int BLOCK_4K = 4; + + private static final int BLOCK_FILES = 5; + + private static final int BLOCK_ENTRIES = 6; + + private static final int BLOCK_EVICTED = 7; + + private static final String[] blockNames = new String[]{"EXTERNAL", "RANKINGS", "BLOCK_256", "BLOCK_1K", "BLOCK_4K", "BLOCK_FILES", "BLOCK_ENTRIES", "BLOCK_EVICTED"}; + + private static final int[] blockSizes = new int[]{0, 36, 256, 1024, 4096, 8, 104, 48}; + + private static final long kInitializedMask = 0x80000000L; + + private static final long kFileTypeMask = 0x70000000L; + + private static final int kFileTypeOffset = 28; + + private static final long kReservedBitsMask = 0x0c000000L; + + private static final long kNumBlocksMask = 0x03000000L; + + private static final int kNumBlocksOffset = 24; + + private static final long kFileSelectorMask = 0x00ff0000L; + + private static final int FileSelectorOffset = 16; + + private static final long kStartBlockMask = 0x0000FFFFL; + + private static final long kFileNameMask = 0x0FFFFFFFL; + + private final boolean initialized; + + private final int fileType; + + private int numBlocks; + + private int fileSelector; + + private int startBlock; + + private int fileName; + + private final long val; + + private final File rootPath; + + private final Map dataFiles; + + private final File externalFilesDir; + + public CacheAddr(InputStream is, File rootPath, Map dataFiles, File externalFilesDir) throws IOException { + this.dataFiles = dataFiles; + this.rootPath = rootPath; + this.externalFilesDir = externalFilesDir; + IndexInputStream iis = new IndexInputStream(is); + val = iis.readUInt32(); + initialized = (val & kInitializedMask) == kInitializedMask; + fileType = (int) ((val & kFileTypeMask) >> kFileTypeOffset); + if (fileType == EXTERNAL) { + fileName = (int) (val & kFileNameMask); + } else { + numBlocks = (int) ((val & kNumBlocksMask) >> kNumBlocksOffset); + fileSelector = (int) ((val & kFileSelectorMask) >> FileSelectorOffset); + startBlock = (int) (val & kStartBlockMask); + } + } + + @Override + public String toString() { + + String ft = blockNames[fileType]; + if (fileType == EXTERNAL) { + return ft + ":" + fileName; + } + if (!initialized) { + return "uninitialized"; + } + return ft + ": numBlocks " + numBlocks + " fileSelector " + fileSelector + " startBlock " + startBlock; + } + + public InputStream getInputStream() throws IOException { + if (!initialized) { + return null; + } + switch (fileType) { + case EXTERNAL: + String fileNameStr = Long.toHexString(fileName); + while (fileNameStr.length() < 6) { + fileNameStr = "0" + fileNameStr; + } + fileNameStr = "f_" + fileNameStr; + return new RafInputStream(new RandomAccessFile(new File(externalFilesDir, fileNameStr), "r")); + case BLOCK_1K: + case BLOCK_256: + case BLOCK_4K: + + RandomAccessFile raf; + + if (dataFiles.containsKey(fileSelector)) { + raf = dataFiles.get(fileSelector); + } else { + raf = new RandomAccessFile(rootPath + "\\data_" + fileSelector, "r"); + dataFiles.put(fileSelector, raf); + } + raf.seek(BlockFileHeader.kBlockHeaderSize + startBlock * blockSizes[fileType]); + return new RafInputStream(raf); + } + return null; + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/EntryStore.java b/src/com/jpexs/browsers/cache/chrome/EntryStore.java index a62073b07..d08c60ada 100644 --- a/src/com/jpexs/browsers/cache/chrome/EntryStore.java +++ b/src/com/jpexs/browsers/cache/chrome/EntryStore.java @@ -1,174 +1,174 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import com.jpexs.browsers.cache.CacheEntry; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class EntryStore extends CacheEntry { - - public static final int ENTRY_NORMAL = 0; - - public static final int ENTRY_EVICTED = 1; // The entry was recently evicted from the cache. - - public static final int ENTRY_DOOMED = 2; // The entry was doomed - - public static final int PARENT_ENTRY = 1; // This entry has children (sparse) entries. - - public static final int CHILD_ENTRY = 1 << 1; - - public long hash; // Full hash of the key. - - public CacheAddr next; // Next entry with the same hash or bucket. - - public CacheAddr rankings_node; // Rankings node for this entry. - - public int reuse_count; // How often is this entry used. - - public int refetch_count; // How often is this fetched from the net. - - public int state; // Current state. - - public long creation_time; - - public int key_len; - - public CacheAddr long_key; // Optional address of a long key. - - public int[] data_size = new int[4]; // We can store up to 4 data streams for each - - public CacheAddr[] data_addr = new CacheAddr[4]; // entry. - - public long flags; // Any combination of EntryFlags. - - public int[] pad = new int[4]; - - public long self_hash; // The hash of EntryStore up to this point. - - public byte[] key = new byte[256 - 24 * 4]; // null terminated - - public EntryStore(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { - IndexInputStream iis = new IndexInputStream(is); - hash = iis.readUInt32(); - next = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - rankings_node = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - reuse_count = iis.readInt32(); - refetch_count = iis.readInt32(); - state = iis.readInt32(); - creation_time = iis.readUInt64(); - key_len = iis.readInt32(); - long_key = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - data_size = new int[4]; - for (int i = 0; i < 4; i++) { - data_size[i] = iis.readInt32(); - } - data_addr = new CacheAddr[4]; - for (int i = 0; i < 4; i++) { - data_addr[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - } - flags = iis.readUInt32(); - pad = new int[4]; - for (int i = 0; i < 4; i++) { - pad[i] = iis.readInt32(); - } - self_hash = iis.readUInt32(); - key = new byte[256 - 24 * 4]; - if (iis.read(key) != key.length) { - throw new IOException(); - } - } - - public HttpResponseInfo getResponseInfo() { - try { - InputStream is = data_addr[0].getInputStream(); - if (is == null) { - return null; - } - return new HttpResponseInfo(is); - } catch (IOException ex) { - Logger.getLogger(EntryStore.class.getName()).log(Level.SEVERE, null, ex); - return null; - } - } - - public int getResponseDataSize() { - return data_size[1]; - } - - @Override - public InputStream getResponseRawDataStream() { - try { - return data_addr[1].getInputStream(); - } catch (IOException ex) { - Logger.getLogger(EntryStore.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } - - public String getKey() { - if (key_len < 0) { - return null; - } - return new String(key, 0, key_len > key.length ? key.length : key_len); - } - - @Override - public String getRequestURL() { - return getKey(); - } - - @Override - public Map getResponseHeaders() { - HttpResponseInfo ri = getResponseInfo(); - if (ri == null) { - return new HashMap<>(); - } - List headers = ri.headers; - Map ret = new HashMap<>(); - for (int h = 1; h < headers.size(); h++) { - String hs = headers.get(h); - if (hs.contains(":")) { - String[] hp = hs.split(":"); - ret.put(hp[0].trim(), hp[1].trim()); - } - } - return ret; - } - - @Override - public String getStatusLine() { - HttpResponseInfo ri = getResponseInfo(); - return ri.headers.get(0); - } - - @Override - public String getRequestMethod() { - return "GET"; - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import com.jpexs.browsers.cache.CacheEntry; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class EntryStore extends CacheEntry { + + public static final int ENTRY_NORMAL = 0; + + public static final int ENTRY_EVICTED = 1; // The entry was recently evicted from the cache. + + public static final int ENTRY_DOOMED = 2; // The entry was doomed + + public static final int PARENT_ENTRY = 1; // This entry has children (sparse) entries. + + public static final int CHILD_ENTRY = 1 << 1; + + public long hash; // Full hash of the key. + + public CacheAddr next; // Next entry with the same hash or bucket. + + public CacheAddr rankings_node; // Rankings node for this entry. + + public int reuse_count; // How often is this entry used. + + public int refetch_count; // How often is this fetched from the net. + + public int state; // Current state. + + public long creation_time; + + public int key_len; + + public CacheAddr long_key; // Optional address of a long key. + + public int[] data_size = new int[4]; // We can store up to 4 data streams for each + + public CacheAddr[] data_addr = new CacheAddr[4]; // entry. + + public long flags; // Any combination of EntryFlags. + + public int[] pad = new int[4]; + + public long self_hash; // The hash of EntryStore up to this point. + + public byte[] key = new byte[256 - 24 * 4]; // null terminated + + public EntryStore(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { + IndexInputStream iis = new IndexInputStream(is); + hash = iis.readUInt32(); + next = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + rankings_node = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + reuse_count = iis.readInt32(); + refetch_count = iis.readInt32(); + state = iis.readInt32(); + creation_time = iis.readUInt64(); + key_len = iis.readInt32(); + long_key = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + data_size = new int[4]; + for (int i = 0; i < 4; i++) { + data_size[i] = iis.readInt32(); + } + data_addr = new CacheAddr[4]; + for (int i = 0; i < 4; i++) { + data_addr[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + } + flags = iis.readUInt32(); + pad = new int[4]; + for (int i = 0; i < 4; i++) { + pad[i] = iis.readInt32(); + } + self_hash = iis.readUInt32(); + key = new byte[256 - 24 * 4]; + if (iis.read(key) != key.length) { + throw new IOException(); + } + } + + public HttpResponseInfo getResponseInfo() { + try { + InputStream is = data_addr[0].getInputStream(); + if (is == null) { + return null; + } + return new HttpResponseInfo(is); + } catch (IOException ex) { + Logger.getLogger(EntryStore.class.getName()).log(Level.SEVERE, null, ex); + return null; + } + } + + public int getResponseDataSize() { + return data_size[1]; + } + + @Override + public InputStream getResponseRawDataStream() { + try { + return data_addr[1].getInputStream(); + } catch (IOException ex) { + Logger.getLogger(EntryStore.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + + public String getKey() { + if (key_len < 0) { + return null; + } + return new String(key, 0, key_len > key.length ? key.length : key_len); + } + + @Override + public String getRequestURL() { + return getKey(); + } + + @Override + public Map getResponseHeaders() { + HttpResponseInfo ri = getResponseInfo(); + if (ri == null) { + return new HashMap<>(); + } + List headers = ri.headers; + Map ret = new HashMap<>(); + for (int h = 1; h < headers.size(); h++) { + String hs = headers.get(h); + if (hs.contains(":")) { + String[] hp = hs.split(":"); + ret.put(hp[0].trim(), hp[1].trim()); + } + } + return ret; + } + + @Override + public String getStatusLine() { + HttpResponseInfo ri = getResponseInfo(); + return ri.headers.get(0); + } + + @Override + public String getRequestMethod() { + return "GET"; + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/HttpResponseInfo.java b/src/com/jpexs/browsers/cache/chrome/HttpResponseInfo.java index c3970cbc0..e5b43dde6 100644 --- a/src/com/jpexs/browsers/cache/chrome/HttpResponseInfo.java +++ b/src/com/jpexs/browsers/cache/chrome/HttpResponseInfo.java @@ -1,127 +1,127 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author JPEXS - */ -public class HttpResponseInfo { - - public long flags; - - public int version; - - public long request_time; - - public long response_time; - - public long payload_size; - - public List headers; - - // The version of the response info used when persisting response info. - public static final int RESPONSE_INFO_VERSION = 3; - - // The minimum version supported for deserializing response info. - public static final int RESPONSE_INFO_MINIMUM_VERSION = 1; - - // We reserve up to 8 bits for the version number. - public static final int RESPONSE_INFO_VERSION_MASK = 0xFF; - - // This bit is set if the response info has a cert at the end. - // Version 1 serialized only the end-entity certificate, while subsequent - // versions include the available certificate chain. - public static final int RESPONSE_INFO_HAS_CERT = 1 << 8; - - // This bit is set if the response info has a security-bits field (security - // strength, in bits, of the SSL connection) at the end. - public static final int RESPONSE_INFO_HAS_SECURITY_BITS = 1 << 9; - - // This bit is set if the response info has a cert status at the end. - public static final int RESPONSE_INFO_HAS_CERT_STATUS = 1 << 10; - - // This bit is set if the response info has vary header data. - public static final int RESPONSE_INFO_HAS_VARY_DATA = 1 << 11; - - // This bit is set if the request was cancelled before completion. - public static final int RESPONSE_INFO_TRUNCATED = 1 << 12; - - // This bit is set if the response was received via SPDY. - public static final int RESPONSE_INFO_WAS_SPDY = 1 << 13; - - // This bit is set if the request has NPN negotiated. - public static final int RESPONSE_INFO_WAS_NPN = 1 << 14; - - // This bit is set if the request was fetched via an explicit proxy. - public static final int RESPONSE_INFO_WAS_PROXY = 1 << 15; - - // This bit is set if the response info has an SSL connection status field. - // This contains the ciphersuite used to fetch the resource as well as the - // protocol version, compression method and whether SSLv3 fallback was used. - public static final int RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16; - - // This bit is set if the response info has protocol version. - public static final int RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17; - - // This bit is set if the response info has connection info. - public static final int RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18; - - // This bit is set if the request has http authentication. - public static final int RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19; - - public String getHeaderValue(String header) { - for (String h : headers) { - if (h.contains(":")) { - String[] keyval = h.split(":"); - String key = keyval[0].trim().toLowerCase(); - String val = keyval[1].trim(); - if (header.toLowerCase().equals(key)) { - return val; - } - } - } - return null; - } - - public HttpResponseInfo(InputStream is) throws IOException { - IndexInputStream iis = new IndexInputStream(is); - payload_size = iis.readUInt32(); - flags = iis.readInt(); - version = (int) (flags & RESPONSE_INFO_VERSION_MASK); - if (version < RESPONSE_INFO_MINIMUM_VERSION || version > RESPONSE_INFO_VERSION) { - throw new RuntimeException("unexpected response info version: " + version); - } - request_time = iis.readInt64(); - response_time = iis.readInt64(); - String headersStr = iis.readString(); - headers = new ArrayList<>(); - int nulpos; - while ((nulpos = headersStr.indexOf(0)) > 0) { - String h = headersStr.substring(0, nulpos); - headersStr = headersStr.substring(nulpos + 1); - headers.add(h); - } - - //TODO: Read SSL info - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class HttpResponseInfo { + + public long flags; + + public int version; + + public long request_time; + + public long response_time; + + public long payload_size; + + public List headers; + + // The version of the response info used when persisting response info. + public static final int RESPONSE_INFO_VERSION = 3; + + // The minimum version supported for deserializing response info. + public static final int RESPONSE_INFO_MINIMUM_VERSION = 1; + + // We reserve up to 8 bits for the version number. + public static final int RESPONSE_INFO_VERSION_MASK = 0xFF; + + // This bit is set if the response info has a cert at the end. + // Version 1 serialized only the end-entity certificate, while subsequent + // versions include the available certificate chain. + public static final int RESPONSE_INFO_HAS_CERT = 1 << 8; + + // This bit is set if the response info has a security-bits field (security + // strength, in bits, of the SSL connection) at the end. + public static final int RESPONSE_INFO_HAS_SECURITY_BITS = 1 << 9; + + // This bit is set if the response info has a cert status at the end. + public static final int RESPONSE_INFO_HAS_CERT_STATUS = 1 << 10; + + // This bit is set if the response info has vary header data. + public static final int RESPONSE_INFO_HAS_VARY_DATA = 1 << 11; + + // This bit is set if the request was cancelled before completion. + public static final int RESPONSE_INFO_TRUNCATED = 1 << 12; + + // This bit is set if the response was received via SPDY. + public static final int RESPONSE_INFO_WAS_SPDY = 1 << 13; + + // This bit is set if the request has NPN negotiated. + public static final int RESPONSE_INFO_WAS_NPN = 1 << 14; + + // This bit is set if the request was fetched via an explicit proxy. + public static final int RESPONSE_INFO_WAS_PROXY = 1 << 15; + + // This bit is set if the response info has an SSL connection status field. + // This contains the ciphersuite used to fetch the resource as well as the + // protocol version, compression method and whether SSLv3 fallback was used. + public static final int RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS = 1 << 16; + + // This bit is set if the response info has protocol version. + public static final int RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL = 1 << 17; + + // This bit is set if the response info has connection info. + public static final int RESPONSE_INFO_HAS_CONNECTION_INFO = 1 << 18; + + // This bit is set if the request has http authentication. + public static final int RESPONSE_INFO_USE_HTTP_AUTHENTICATION = 1 << 19; + + public String getHeaderValue(String header) { + for (String h : headers) { + if (h.contains(":")) { + String[] keyval = h.split(":"); + String key = keyval[0].trim().toLowerCase(); + String val = keyval[1].trim(); + if (header.toLowerCase().equals(key)) { + return val; + } + } + } + return null; + } + + public HttpResponseInfo(InputStream is) throws IOException { + IndexInputStream iis = new IndexInputStream(is); + payload_size = iis.readUInt32(); + flags = iis.readInt(); + version = (int) (flags & RESPONSE_INFO_VERSION_MASK); + if (version < RESPONSE_INFO_MINIMUM_VERSION || version > RESPONSE_INFO_VERSION) { + throw new RuntimeException("unexpected response info version: " + version); + } + request_time = iis.readInt64(); + response_time = iis.readInt64(); + String headersStr = iis.readString(); + headers = new ArrayList<>(); + int nulpos; + while ((nulpos = headersStr.indexOf(0)) > 0) { + String h = headersStr.substring(0, nulpos); + headersStr = headersStr.substring(nulpos + 1); + headers.add(h); + } + + //TODO: Read SSL info + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/IndexHeader.java b/src/com/jpexs/browsers/cache/chrome/IndexHeader.java index 645201501..d2ea84376 100644 --- a/src/com/jpexs/browsers/cache/chrome/IndexHeader.java +++ b/src/com/jpexs/browsers/cache/chrome/IndexHeader.java @@ -1,76 +1,76 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public class IndexHeader { - - long magic; //c3 ca 03 c1 - - long version; //01 00 02 00 - - int num_entries; - - int num_bytes; - - int last_file; - - int this_id; - - CacheAddr stats; - - int table_len; - - int crash; - - int experiment; - - long create_time; - - int[] pad = new int[52]; - - LruData lru; - - public IndexHeader(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { - IndexInputStream iis = new IndexInputStream(is); - magic = iis.readUInt32(); - version = iis.readUInt32(); - num_entries = iis.readInt32(); - num_bytes = iis.readInt32(); - last_file = iis.readInt32(); - this_id = iis.readInt32(); - stats = new CacheAddr(iis, rootDir, dataFiles, externalFilesDir); - table_len = iis.readInt32(); - crash = iis.readInt32(); - experiment = iis.readInt32(); - create_time = iis.readUInt64(); - pad = new int[52]; - for (int i = 0; i < 52; i++) { - pad[i] = iis.readInt32(); - } - lru = new LruData(is, rootDir, dataFiles, externalFilesDir); - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class IndexHeader { + + long magic; //c3 ca 03 c1 + + long version; //01 00 02 00 + + int num_entries; + + int num_bytes; + + int last_file; + + int this_id; + + CacheAddr stats; + + int table_len; + + int crash; + + int experiment; + + long create_time; + + int[] pad = new int[52]; + + LruData lru; + + public IndexHeader(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { + IndexInputStream iis = new IndexInputStream(is); + magic = iis.readUInt32(); + version = iis.readUInt32(); + num_entries = iis.readInt32(); + num_bytes = iis.readInt32(); + last_file = iis.readInt32(); + this_id = iis.readInt32(); + stats = new CacheAddr(iis, rootDir, dataFiles, externalFilesDir); + table_len = iis.readInt32(); + crash = iis.readInt32(); + experiment = iis.readInt32(); + create_time = iis.readUInt64(); + pad = new int[52]; + for (int i = 0; i < 52; i++) { + pad[i] = iis.readInt32(); + } + lru = new LruData(is, rootDir, dataFiles, externalFilesDir); + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/IndexInputStream.java b/src/com/jpexs/browsers/cache/chrome/IndexInputStream.java index a3b23b89b..e10be3cbc 100644 --- a/src/com/jpexs/browsers/cache/chrome/IndexInputStream.java +++ b/src/com/jpexs/browsers/cache/chrome/IndexInputStream.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import java.io.IOException; -import java.io.InputStream; - -/** - * - * @author JPEXS - */ -public class IndexInputStream extends InputStream { - - private final InputStream is; - - public long pos = 0; - - public long getPos() { - return pos; - } - - public IndexInputStream(InputStream is) { - this.is = is; - } - - @Override - public int read() throws IOException { - int r = is.read(); - //System.out.print("$"+Integer.toHexString(r)); - pos++; - return r; - } - - public long readUInt32() throws IOException { - long r = (((long) read()) + ((long) (read() << 8)) + ((long) (read() << 16)) + ((long) (read() << 24))) & 0xffffffffL; - //System.out.println(""); - return r; - } - - public long readUInt64() throws IOException { - return readUInt32() + (readUInt32() << 32); - } - - public long readInt64() throws IOException { - return readUInt64(); //FIXME - } - - public int readInt32() throws IOException { - return (int) readUInt32(); - } - - public int readInt16() throws IOException { - return (short) ((int) read() + (int) (read() << 8)); - } - - public long readInt() throws IOException { - return readInt32(); - } - - public String readString() throws IOException { - int len = (int) readInt(); - byte[] data = new byte[len]; - if (read(data) != len) { - throw new IOException(); - } - - return new String(data); - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import java.io.IOException; +import java.io.InputStream; + +/** + * + * @author JPEXS + */ +public class IndexInputStream extends InputStream { + + private final InputStream is; + + public long pos = 0; + + public long getPos() { + return pos; + } + + public IndexInputStream(InputStream is) { + this.is = is; + } + + @Override + public int read() throws IOException { + int r = is.read(); + //System.out.print("$"+Integer.toHexString(r)); + pos++; + return r; + } + + public long readUInt32() throws IOException { + long r = (((long) read()) + ((long) (read() << 8)) + ((long) (read() << 16)) + ((long) (read() << 24))) & 0xffffffffL; + //System.out.println(""); + return r; + } + + public long readUInt64() throws IOException { + return readUInt32() + (readUInt32() << 32); + } + + public long readInt64() throws IOException { + return readUInt64(); //FIXME + } + + public int readInt32() throws IOException { + return (int) readUInt32(); + } + + public int readInt16() throws IOException { + return (short) ((int) read() + (int) (read() << 8)); + } + + public long readInt() throws IOException { + return readInt32(); + } + + public String readString() throws IOException { + int len = (int) readInt(); + byte[] data = new byte[len]; + if (read(data) != len) { + throw new IOException(); + } + + return new String(data); + } +} diff --git a/src/com/jpexs/browsers/cache/chrome/LruData.java b/src/com/jpexs/browsers/cache/chrome/LruData.java index 5d496c4a1..529cc8d5e 100644 --- a/src/com/jpexs/browsers/cache/chrome/LruData.java +++ b/src/com/jpexs/browsers/cache/chrome/LruData.java @@ -1,79 +1,79 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.chrome; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public class LruData { - - int[] pad1 = new int[2]; - - int filled; - - int[] sizes = new int[5]; - - CacheAddr[] heads = new CacheAddr[5]; - - CacheAddr[] tails = new CacheAddr[5]; - - CacheAddr transaction; - - int operation; - - int operation_list; - - int[] pad2 = new int[7]; - - public LruData(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { - IndexInputStream iis = new IndexInputStream(is); - pad1 = new int[2]; - pad1[0] = iis.readInt32(); - pad1[1] = iis.readInt32(); - filled = iis.readInt32(); - sizes = new int[5]; - for (int i = 0; i < 5; i++) { - sizes[i] = iis.readInt32(); - } - sizes = new int[5]; - for (int i = 0; i < 5; i++) { - sizes[i] = iis.readInt32(); - } - heads = new CacheAddr[5]; - for (int i = 0; i < 5; i++) { - heads[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - } - tails = new CacheAddr[5]; - for (int i = 0; i < 5; i++) { - tails[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - } - transaction = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); - operation = iis.readInt32(); - operation_list = iis.readInt32(); - pad2 = new int[7]; - for (int i = 0; i < 7; i++) { - pad2[i] = iis.readInt32(); - } - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.chrome; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class LruData { + + int[] pad1 = new int[2]; + + int filled; + + int[] sizes = new int[5]; + + CacheAddr[] heads = new CacheAddr[5]; + + CacheAddr[] tails = new CacheAddr[5]; + + CacheAddr transaction; + + int operation; + + int operation_list; + + int[] pad2 = new int[7]; + + public LruData(InputStream is, File rootDir, Map dataFiles, File externalFilesDir) throws IOException { + IndexInputStream iis = new IndexInputStream(is); + pad1 = new int[2]; + pad1[0] = iis.readInt32(); + pad1[1] = iis.readInt32(); + filled = iis.readInt32(); + sizes = new int[5]; + for (int i = 0; i < 5; i++) { + sizes[i] = iis.readInt32(); + } + sizes = new int[5]; + for (int i = 0; i < 5; i++) { + sizes[i] = iis.readInt32(); + } + heads = new CacheAddr[5]; + for (int i = 0; i < 5; i++) { + heads[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + } + tails = new CacheAddr[5]; + for (int i = 0; i < 5; i++) { + tails[i] = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + } + transaction = new CacheAddr(is, rootDir, dataFiles, externalFilesDir); + operation = iis.readInt32(); + operation_list = iis.readInt32(); + pad2 = new int[7]; + for (int i = 0; i < 7; i++) { + pad2[i] = iis.readInt32(); + } + } +} diff --git a/src/com/jpexs/browsers/cache/firefox/FirefoxCache.java b/src/com/jpexs/browsers/cache/firefox/FirefoxCache.java index 2f1f47c2d..3fe5c5567 100644 --- a/src/com/jpexs/browsers/cache/firefox/FirefoxCache.java +++ b/src/com/jpexs/browsers/cache/firefox/FirefoxCache.java @@ -1,167 +1,167 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.firefox; - -import com.jpexs.browsers.cache.CacheEntry; -import com.jpexs.browsers.cache.CacheImplementation; -import java.io.File; -import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class FirefoxCache implements CacheImplementation { - - private static volatile FirefoxCache instance; - - private FirefoxCache() { - } - - public static FirefoxCache getInstance() { - if (instance == null) { - synchronized (FirefoxCache.class) { - if (instance == null) { - instance = new FirefoxCache(); - } - } - } - return instance; - } - - private boolean loaded = false; - - private CacheMap map; - - @Override - public void refresh() { - File dir = getCacheDirectory(); - if (dir == null) { - return; - } - File cacheMapFile = new File(dir, "_CACHE_MAP_"); - try { - map = new CacheMap(cacheMapFile); - } catch (IOException ex) { - Logger.getLogger(FirefoxCache.class.getName()).log(Level.SEVERE, null, ex); - } - loaded = true; - } - - @Override - public List getEntries() { - if (!loaded) { - refresh(); - } - if (map == null) { - return null; - } - List ret = new ArrayList<>(); - - ret.addAll(map.mapBuckets); - return ret; - } - - private enum OSId { - - WINDOWS, OSX, UNIX - } - - private static OSId getOSId() { - PrivilegedAction doGetOSName = new PrivilegedAction() { - @Override - public String run() { - return System.getProperty("os.name"); - } - }; - OSId id = OSId.UNIX; - String osName = AccessController.doPrivileged(doGetOSName); - if (osName != null) { - if (osName.toLowerCase().startsWith("mac os x")) { - id = OSId.OSX; - } else if (osName.contains("Windows")) { - id = OSId.WINDOWS; - } - } - return id; - } - - public static File getProfileDirectory() { - File profilesDir = getProfilesDirectory(); - if (profilesDir == null) { - return null; - } - File[] profiles = profilesDir.listFiles(); - File profileDir = null; - for (File f : profiles) { - if (f.isDirectory()) { - if (f.getName().matches("[a-z0-9]+\\.default")) { - profileDir = f; - break; - } - } - } - return profileDir; - } - - public static File getCacheDirectory() { - File profileDir = getProfileDirectory(); - File cacheDir = null; - if (profileDir != null) { - cacheDir = new File(profileDir, "Cache"); - } - if (cacheDir == null) { - return null; - } - if (!cacheDir.exists()) { - return null; - } - return cacheDir; - } - - public static File getProfilesDirectory() { - String userHome = null; - File profilesDir = null; - try { - userHome = System.getProperty("user.home"); - } catch (SecurityException ignore) { - } - if (userHome != null) { - OSId osId = getOSId(); - if (osId == OSId.WINDOWS) { - profilesDir = new File(userHome + "\\AppData\\Local\\Mozilla\\Firefox\\Profiles"); - if (!profilesDir.exists()) { - profilesDir = new File(userHome + "\\Local Settings\\Application Data\\Mozilla\\Firefox\\Profiles"); - } - } else if (osId == OSId.OSX) { - profilesDir = new File(userHome + "/Library/Caches/Firefox/Profiles"); - } else { - profilesDir = new File(userHome + "/.mozilla/firefox"); - } - } - if ((profilesDir == null) || !profilesDir.exists()) { - return null; - } - return profilesDir; - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.firefox; + +import com.jpexs.browsers.cache.CacheEntry; +import com.jpexs.browsers.cache.CacheImplementation; +import java.io.File; +import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class FirefoxCache implements CacheImplementation { + + private static volatile FirefoxCache instance; + + private FirefoxCache() { + } + + public static FirefoxCache getInstance() { + if (instance == null) { + synchronized (FirefoxCache.class) { + if (instance == null) { + instance = new FirefoxCache(); + } + } + } + return instance; + } + + private boolean loaded = false; + + private CacheMap map; + + @Override + public void refresh() { + File dir = getCacheDirectory(); + if (dir == null) { + return; + } + File cacheMapFile = new File(dir, "_CACHE_MAP_"); + try { + map = new CacheMap(cacheMapFile); + } catch (IOException ex) { + Logger.getLogger(FirefoxCache.class.getName()).log(Level.SEVERE, null, ex); + } + loaded = true; + } + + @Override + public List getEntries() { + if (!loaded) { + refresh(); + } + if (map == null) { + return null; + } + List ret = new ArrayList<>(); + + ret.addAll(map.mapBuckets); + return ret; + } + + private enum OSId { + + WINDOWS, OSX, UNIX + } + + private static OSId getOSId() { + PrivilegedAction doGetOSName = new PrivilegedAction() { + @Override + public String run() { + return System.getProperty("os.name"); + } + }; + OSId id = OSId.UNIX; + String osName = AccessController.doPrivileged(doGetOSName); + if (osName != null) { + if (osName.toLowerCase().startsWith("mac os x")) { + id = OSId.OSX; + } else if (osName.contains("Windows")) { + id = OSId.WINDOWS; + } + } + return id; + } + + public static File getProfileDirectory() { + File profilesDir = getProfilesDirectory(); + if (profilesDir == null) { + return null; + } + File[] profiles = profilesDir.listFiles(); + File profileDir = null; + for (File f : profiles) { + if (f.isDirectory()) { + if (f.getName().matches("[a-z0-9]+\\.default")) { + profileDir = f; + break; + } + } + } + return profileDir; + } + + public static File getCacheDirectory() { + File profileDir = getProfileDirectory(); + File cacheDir = null; + if (profileDir != null) { + cacheDir = new File(profileDir, "Cache"); + } + if (cacheDir == null) { + return null; + } + if (!cacheDir.exists()) { + return null; + } + return cacheDir; + } + + public static File getProfilesDirectory() { + String userHome = null; + File profilesDir = null; + try { + userHome = System.getProperty("user.home"); + } catch (SecurityException ignore) { + } + if (userHome != null) { + OSId osId = getOSId(); + if (osId == OSId.WINDOWS) { + profilesDir = new File(userHome + "\\AppData\\Local\\Mozilla\\Firefox\\Profiles"); + if (!profilesDir.exists()) { + profilesDir = new File(userHome + "\\Local Settings\\Application Data\\Mozilla\\Firefox\\Profiles"); + } + } else if (osId == OSId.OSX) { + profilesDir = new File(userHome + "/Library/Caches/Firefox/Profiles"); + } else { + profilesDir = new File(userHome + "/.mozilla/firefox"); + } + } + if ((profilesDir == null) || !profilesDir.exists()) { + return null; + } + return profilesDir; + } +} diff --git a/src/com/jpexs/browsers/cache/firefox/MapBucket.java b/src/com/jpexs/browsers/cache/firefox/MapBucket.java index 0dc29bb68..156023669 100644 --- a/src/com/jpexs/browsers/cache/firefox/MapBucket.java +++ b/src/com/jpexs/browsers/cache/firefox/MapBucket.java @@ -1,132 +1,132 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.firefox; - -import com.jpexs.browsers.cache.CacheEntry; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.RandomAccessFile; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class MapBucket extends CacheEntry { - - public long hash; - - public long enviction; - - public Location dataLocation; - - public Location metadataLocation; - - private MetaData metadata; - - public MapBucket(InputStream is, File rootDir, Map dataFiles) throws IOException { - CacheInputStream cis = new CacheInputStream(is); - hash = cis.readInt32(); - enviction = cis.readInt32(); - dataLocation = new Location(cis.readInt32(), false, hash, rootDir, dataFiles); - metadataLocation = new Location(cis.readInt32(), true, hash, rootDir, dataFiles); - } - - public InputStream getMetaDataStream() throws IOException { - return metadataLocation.getInputStream(); - } - - public MetaData getMetaData() { - if (metadata == null) { - try { - metadata = new MetaData(getMetaDataStream()); - } catch (IncompatibleVersionException ie) { - } catch (IOException ex) { - Logger.getLogger(MapBucket.class.getName()).log(Level.SEVERE, null, ex); - } - } - return metadata; - } - - @Override - public String getRequestURL() { - MetaData m = getMetaData(); - if (m == null) { - return null; - } - String req = m.request; - if (req == null) { - return null; - } - if (req.startsWith("HTTP:")) { - req = req.substring("HTTP:".length()); - } - return req; - } - - @Override - public Map getResponseHeaders() { - MetaData m = getMetaData(); - if (m == null) { - return null; - } - String responseHead = m.response.get("response-head"); - if (responseHead == null) { - return null; - } - String[] headers = responseHead.split("\r\n"); - Map ret = new HashMap<>(); - for (int h = 1; h < headers.length; h++) { - String hs = headers[h]; - if (hs.contains(":")) { - String[] hp = hs.split(":"); - ret.put(hp[0].trim(), hp[1].trim()); - } - } - return ret; - } - - @Override - public String getStatusLine() { - MetaData m = getMetaData(); - if (m == null) { - return null; - } - String responseHead = m.response.get("response-head"); - String[] headers = responseHead.split("\r\n"); - return headers[0]; - } - - @Override - public String getRequestMethod() { - return "GET"; //No POST caching in Firefox - } - - @Override - public InputStream getResponseRawDataStream() { - try { - return dataLocation.getInputStream(); - } catch (IOException ex) { - Logger.getLogger(MapBucket.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.firefox; + +import com.jpexs.browsers.cache.CacheEntry; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class MapBucket extends CacheEntry { + + public long hash; + + public long enviction; + + public Location dataLocation; + + public Location metadataLocation; + + private MetaData metadata; + + public MapBucket(InputStream is, File rootDir, Map dataFiles) throws IOException { + CacheInputStream cis = new CacheInputStream(is); + hash = cis.readInt32(); + enviction = cis.readInt32(); + dataLocation = new Location(cis.readInt32(), false, hash, rootDir, dataFiles); + metadataLocation = new Location(cis.readInt32(), true, hash, rootDir, dataFiles); + } + + public InputStream getMetaDataStream() throws IOException { + return metadataLocation.getInputStream(); + } + + public MetaData getMetaData() { + if (metadata == null) { + try { + metadata = new MetaData(getMetaDataStream()); + } catch (IncompatibleVersionException ie) { + } catch (IOException ex) { + Logger.getLogger(MapBucket.class.getName()).log(Level.SEVERE, null, ex); + } + } + return metadata; + } + + @Override + public String getRequestURL() { + MetaData m = getMetaData(); + if (m == null) { + return null; + } + String req = m.request; + if (req == null) { + return null; + } + if (req.startsWith("HTTP:")) { + req = req.substring("HTTP:".length()); + } + return req; + } + + @Override + public Map getResponseHeaders() { + MetaData m = getMetaData(); + if (m == null) { + return null; + } + String responseHead = m.response.get("response-head"); + if (responseHead == null) { + return null; + } + String[] headers = responseHead.split("\r\n"); + Map ret = new HashMap<>(); + for (int h = 1; h < headers.length; h++) { + String hs = headers[h]; + if (hs.contains(":")) { + String[] hp = hs.split(":"); + ret.put(hp[0].trim(), hp[1].trim()); + } + } + return ret; + } + + @Override + public String getStatusLine() { + MetaData m = getMetaData(); + if (m == null) { + return null; + } + String responseHead = m.response.get("response-head"); + String[] headers = responseHead.split("\r\n"); + return headers[0]; + } + + @Override + public String getRequestMethod() { + return "GET"; //No POST caching in Firefox + } + + @Override + public InputStream getResponseRawDataStream() { + try { + return dataLocation.getInputStream(); + } catch (IOException ex) { + Logger.getLogger(MapBucket.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } +} diff --git a/src/com/jpexs/browsers/cache/firefox/MetaData.java b/src/com/jpexs/browsers/cache/firefox/MetaData.java index 32f9235f1..78bdd1376 100644 --- a/src/com/jpexs/browsers/cache/firefox/MetaData.java +++ b/src/com/jpexs/browsers/cache/firefox/MetaData.java @@ -1,93 +1,93 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.browsers.cache.firefox; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author JPEXS - */ -public class MetaData { - - public int majorVersion; - - public int minorVersion; - - public long location; - - public long fetchCount; - - public long firstFetchTime; - - public long lastFetchTime; - - public long expireTime; - - public long dataSize; - - public long requestSize; - - public long infoSize; - - public String request; - - public Map response; - - public MetaData(InputStream is) throws IOException, IncompatibleVersionException { - CacheInputStream cis = new CacheInputStream(is); - majorVersion = cis.readInt16(); - if (majorVersion != 1) { - throw new IncompatibleVersionException(majorVersion); - } - minorVersion = cis.readInt16(); - location = cis.readInt32(); - fetchCount = cis.readInt32(); - firstFetchTime = cis.readInt32(); - lastFetchTime = cis.readInt32(); - expireTime = cis.readInt32(); - dataSize = cis.readInt32(); - requestSize = cis.readInt32(); - infoSize = cis.readInt32(); - byte[] req = new byte[(int) requestSize]; - if (cis.read(req) != req.length) { - throw new IOException(); - } - - request = new String(req, 0, (int) requestSize - 1/*Ends with char 0*/); - byte[] res = new byte[(int) infoSize]; - cis.read(res); - String responseStr = new String(res); - int nulpos; - boolean inKey = true; - String key = null; - response = new HashMap<>(); - while ((nulpos = responseStr.indexOf(0)) > 0) { - String v = responseStr.substring(0, nulpos); - responseStr = responseStr.substring(nulpos + 1); - if (inKey) { - key = v; - } else { - response.put(key, v); - } - inKey = !inKey; - } - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.browsers.cache.firefox; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class MetaData { + + public int majorVersion; + + public int minorVersion; + + public long location; + + public long fetchCount; + + public long firstFetchTime; + + public long lastFetchTime; + + public long expireTime; + + public long dataSize; + + public long requestSize; + + public long infoSize; + + public String request; + + public Map response; + + public MetaData(InputStream is) throws IOException, IncompatibleVersionException { + CacheInputStream cis = new CacheInputStream(is); + majorVersion = cis.readInt16(); + if (majorVersion != 1) { + throw new IncompatibleVersionException(majorVersion); + } + minorVersion = cis.readInt16(); + location = cis.readInt32(); + fetchCount = cis.readInt32(); + firstFetchTime = cis.readInt32(); + lastFetchTime = cis.readInt32(); + expireTime = cis.readInt32(); + dataSize = cis.readInt32(); + requestSize = cis.readInt32(); + infoSize = cis.readInt32(); + byte[] req = new byte[(int) requestSize]; + if (cis.read(req) != req.length) { + throw new IOException(); + } + + request = new String(req, 0, (int) requestSize - 1/*Ends with char 0*/); + byte[] res = new byte[(int) infoSize]; + cis.read(res); + String responseStr = new String(res); + int nulpos; + boolean inKey = true; + String key = null; + response = new HashMap<>(); + while ((nulpos = responseStr.indexOf(0)) > 0) { + String v = responseStr.substring(0, nulpos); + responseStr = responseStr.substring(nulpos + 1); + if (inKey) { + key = v; + } else { + response.put(key, v); + } + inKey = !inKey; + } + } +} diff --git a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java index 32a61e6a2..42ec4cc6e 100644 --- a/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java +++ b/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java @@ -1,235 +1,235 @@ -/* - * Copyright (C) 2010-2016 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.console; - -import com.jpexs.helpers.utf8.Utf8Helper; -import com.sun.jna.Platform; -import com.sun.jna.WString; -import com.sun.jna.platform.win32.Advapi32Util; -import com.sun.jna.platform.win32.Kernel32; -import com.sun.jna.platform.win32.SHELLEXECUTEINFO; -import com.sun.jna.platform.win32.Shell32; -import com.sun.jna.platform.win32.Win32Exception; -import com.sun.jna.platform.win32.WinReg; -import com.sun.jna.platform.win32.WinUser; -import java.io.File; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class ContextMenuTools { - - public static String getAppDir() { - String path = Utf8Helper.urlDecode(ContextMenuTools.class.getProtectionDomain().getCodeSource().getLocation().getPath()); - String appDir = new File(path).getParentFile().getAbsolutePath(); - if (!appDir.endsWith("\\")) { - appDir += "\\"; - } - return appDir; - } - - public static boolean isAddedToContextMenu() { - if (!Platform.isWindows()) { - return false; - } - final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE; - final String REG_CLASSES_PATH = "Software\\Classes\\"; - try { - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf")) { - return false; - } - String clsName = Advapi32Util.registryGetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf", ""); - if (clsName == null) { - return false; - } - return Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\ffdec"); - } catch (Win32Exception ex) { - return false; - } - } - - public static boolean addToContextMenu(boolean add, boolean fromCommandLine) { - if (add == isAddedToContextMenu()) { - return true; - } - - String exeName = "ffdec.exe"; - - if (add) { - return addToContextMenu(add, fromCommandLine, exeName); - } else { - // remove both 32 and 64 bit references - return addToContextMenu(add, fromCommandLine, exeName) - && addToContextMenu(add, fromCommandLine, "ffdec64.exe"); //remove 64 exe from previous versions - } - } - - private static boolean addToContextMenu(boolean add, boolean fromCommandLine, String exeName) { - final String[] extensions = new String[]{"swf", "gfx"}; - - final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE; - final String REG_CLASSES_PATH = "Software\\Classes\\"; - - String appDir = getAppDir(); - String verb = "ffdec"; - String verbName = "Open with FFDec"; - boolean exists; - try { - - exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); - if ((!exists) && add) { //add - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell"); - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open"); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open", "", verbName); - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command"); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command", "", "\"" + appDir + exeName + "\" \"%1\""); - - } - - for (String ext : extensions) { - - // 1) Add to context menu of SWF - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext)) { - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, "", "ShockwaveFlash.ShockwaveFlash"); - } - - if (Advapi32Util.registryValueExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, "")) { - String clsName = Advapi32Util.registryGetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, ""); - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName)) { - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName, "", "Flash Movie"); - } - - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell")) { - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell"); - } - - exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); - - if ((!exists) && add) { //add - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb, "", verbName); - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command"); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command", "", "\"" + appDir + exeName + "\" \"%1\""); - } - if (exists && (!add)) { //remove - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); - } - } - - exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); - - if (exists && (!add)) { //remove - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); - } - //2) Add to OpenWith list - if (Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList")) { - String mruList = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList"); - if (mruList != null) { - exists = false; - char appChar = 0; - for (int i = 0; i < mruList.length(); i++) { - String app = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + mruList.charAt(i)); - if (app.equals(exeName)) { - appChar = mruList.charAt(i); - exists = true; - break; - } - } - if ((!exists) && add) { //add - for (int c = 'a'; c <= 'z'; c++) { - if (mruList.indexOf(c) == -1) { - mruList += (char) c; - Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + (char) c, exeName); - Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList", mruList); - break; - } - } - } - if (exists && (!add)) { //remove - mruList = mruList.replace("" + appChar, ""); - Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList", mruList); - registryDeleteValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + appChar); - } - } - } - - //On some systems, file must be associated in SystemFileAssociations too - if (Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations")) { - exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); - if ((!exists) && add) { //add - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "")) { - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + ""); - } - if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell")) { - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell"); - } - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb, "", verbName); - Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command"); - Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command", "", "\"" + appDir + exeName + "\" \"%1\""); - } - if (exists && (!add)) { //remove - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command"); - registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); - } - } - } - return true; - } catch (Exception ex) { - if (!fromCommandLine) { - //Updating registry failed, try elevating rights - SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO(); - sei.fMask = 0x00000040; - sei.lpVerb = new WString("runas"); - sei.lpFile = new WString(appDir + exeName); - sei.lpParameters = new WString(add ? "-addtocontextmenu" : "-removefromcontextmenu"); - sei.nShow = WinUser.SW_NORMAL; - Shell32.INSTANCE.ShellExecuteEx(sei); - //Wait till exit - Kernel32.INSTANCE.WaitForSingleObject(sei.hProcess, 1000 * 60 * 60 * 24 /*1 day max*/); - Kernel32.INSTANCE.CloseHandle(sei.hProcess); - } else { - Logger.getLogger(ContextMenuTools.class.getName()).log(Level.SEVERE, null, ex); - } - } - return false; - } - - private static void registryDeleteKey(WinReg.HKEY hKey, String keyName) { - boolean exists = Advapi32Util.registryKeyExists(hKey, keyName); - if (exists) { - Advapi32Util.registryDeleteKey(hKey, keyName); - } - } - - private static void registryDeleteValue(WinReg.HKEY root, String keyPath, String valueName) { - boolean exists = Advapi32Util.registryValueExists(root, keyPath, valueName); - if (exists) { - Advapi32Util.registryDeleteValue(root, keyPath, valueName); - } - } -} +/* + * Copyright (C) 2010-2016 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.console; + +import com.jpexs.helpers.utf8.Utf8Helper; +import com.sun.jna.Platform; +import com.sun.jna.WString; +import com.sun.jna.platform.win32.Advapi32Util; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.SHELLEXECUTEINFO; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.Win32Exception; +import com.sun.jna.platform.win32.WinReg; +import com.sun.jna.platform.win32.WinUser; +import java.io.File; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class ContextMenuTools { + + public static String getAppDir() { + String path = Utf8Helper.urlDecode(ContextMenuTools.class.getProtectionDomain().getCodeSource().getLocation().getPath()); + String appDir = new File(path).getParentFile().getAbsolutePath(); + if (!appDir.endsWith("\\")) { + appDir += "\\"; + } + return appDir; + } + + public static boolean isAddedToContextMenu() { + if (!Platform.isWindows()) { + return false; + } + final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE; + final String REG_CLASSES_PATH = "Software\\Classes\\"; + try { + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf")) { + return false; + } + String clsName = Advapi32Util.registryGetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + ".swf", ""); + if (clsName == null) { + return false; + } + return Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\ffdec"); + } catch (Win32Exception ex) { + return false; + } + } + + public static boolean addToContextMenu(boolean add, boolean fromCommandLine) { + if (add == isAddedToContextMenu()) { + return true; + } + + String exeName = "ffdec.exe"; + + if (add) { + return addToContextMenu(add, fromCommandLine, exeName); + } else { + // remove both 32 and 64 bit references + return addToContextMenu(add, fromCommandLine, exeName) + && addToContextMenu(add, fromCommandLine, "ffdec64.exe"); //remove 64 exe from previous versions + } + } + + private static boolean addToContextMenu(boolean add, boolean fromCommandLine, String exeName) { + final String[] extensions = new String[]{"swf", "gfx"}; + + final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE; + final String REG_CLASSES_PATH = "Software\\Classes\\"; + + String appDir = getAppDir(); + String verb = "ffdec"; + String verbName = "Open with FFDec"; + boolean exists; + try { + + exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); + if ((!exists) && add) { //add + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell"); + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open"); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open", "", verbName); + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command"); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command", "", "\"" + appDir + exeName + "\" \"%1\""); + + } + + for (String ext : extensions) { + + // 1) Add to context menu of SWF + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext)) { + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, "", "ShockwaveFlash.ShockwaveFlash"); + } + + if (Advapi32Util.registryValueExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, "")) { + String clsName = Advapi32Util.registryGetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "." + ext, ""); + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName)) { + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName, "", "Flash Movie"); + } + + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell")) { + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell"); + } + + exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); + + if ((!exists) && add) { //add + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb, "", verbName); + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command"); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command", "", "\"" + appDir + exeName + "\" \"%1\""); + } + if (exists && (!add)) { //remove + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb + "\\command"); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + clsName + "\\shell\\" + verb); + } + } + + exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); + + if (exists && (!add)) { //remove + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open\\command"); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell\\open"); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName + "\\shell"); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "Applications\\" + exeName); + } + //2) Add to OpenWith list + if (Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList")) { + String mruList = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList"); + if (mruList != null) { + exists = false; + char appChar = 0; + for (int i = 0; i < mruList.length(); i++) { + String app = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + mruList.charAt(i)); + if (app.equals(exeName)) { + appChar = mruList.charAt(i); + exists = true; + break; + } + } + if ((!exists) && add) { //add + for (int c = 'a'; c <= 'z'; c++) { + if (mruList.indexOf(c) == -1) { + mruList += (char) c; + Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + (char) c, exeName); + Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList", mruList); + break; + } + } + } + if (exists && (!add)) { //remove + mruList = mruList.replace("" + appChar, ""); + Advapi32Util.registrySetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "MRUList", mruList); + registryDeleteValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\." + ext + "\\OpenWithList", "" + appChar); + } + } + } + + //On some systems, file must be associated in SystemFileAssociations too + if (Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations")) { + exists = Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); + if ((!exists) && add) { //add + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "")) { + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + ""); + } + if (!Advapi32Util.registryKeyExists(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell")) { + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell"); + } + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb, "", verbName); + Advapi32Util.registryCreateKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command"); + Advapi32Util.registrySetStringValue(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command", "", "\"" + appDir + exeName + "\" \"%1\""); + } + if (exists && (!add)) { //remove + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb + "\\Command"); + registryDeleteKey(REG_CLASSES_HKEY, REG_CLASSES_PATH + "SystemFileAssociations\\." + ext + "\\Shell\\" + verb); + } + } + } + return true; + } catch (Exception ex) { + if (!fromCommandLine) { + //Updating registry failed, try elevating rights + SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO(); + sei.fMask = 0x00000040; + sei.lpVerb = new WString("runas"); + sei.lpFile = new WString(appDir + exeName); + sei.lpParameters = new WString(add ? "-addtocontextmenu" : "-removefromcontextmenu"); + sei.nShow = WinUser.SW_NORMAL; + Shell32.INSTANCE.ShellExecuteEx(sei); + //Wait till exit + Kernel32.INSTANCE.WaitForSingleObject(sei.hProcess, 1000 * 60 * 60 * 24 /*1 day max*/); + Kernel32.INSTANCE.CloseHandle(sei.hProcess); + } else { + Logger.getLogger(ContextMenuTools.class.getName()).log(Level.SEVERE, null, ex); + } + } + return false; + } + + private static void registryDeleteKey(WinReg.HKEY hKey, String keyName) { + boolean exists = Advapi32Util.registryKeyExists(hKey, keyName); + if (exists) { + Advapi32Util.registryDeleteKey(hKey, keyName); + } + } + + private static void registryDeleteValue(WinReg.HKEY root, String keyPath, String valueName) { + boolean exists = Advapi32Util.registryValueExists(root, keyPath, valueName); + if (exists) { + Advapi32Util.registryDeleteValue(root, keyPath, valueName); + } + } +}