(extendedLangs);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangAppollo.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Onno Hommes.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-appollo.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for the AGC/AEA Assembly Language as described
29 | * at http://virtualagc.googlecode.com
30 | *
31 | * This file could be used by goodle code to allow syntax highlight for
32 | * Virtual AGC SVN repository or if you don't want to commonize
33 | * the header for the agc/aea html assembly listing.
34 | *
35 | * @author ohommes@alumni.cmu.edu
36 | */
37 | public class LangAppollo extends Lang {
38 |
39 | public LangAppollo() {
40 | List> _shortcutStylePatterns = new ArrayList>();
41 | List> _fallthroughStylePatterns = new ArrayList>();
42 |
43 | // A line comment that starts with ;
44 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#[^\r\n]*"), null, "#"}));
45 | // Whitespace
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
47 | // A double quoted, possibly multi-line, string.
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\\s"), null}));
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\\=?|BLOCK|BNKSUM|E?CADR|COUNT\\*?|2?DEC\\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\\s"), null}));
51 | // A single quote possibly followed by a word that optionally ends with
52 | // = ! or ?.
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\'(?:-*(?:\\w|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?)?")}));
54 | // Any word including labels that optionally ends with = ! or ?.
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^-*(?:[!-z_]|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?", Pattern.CASE_INSENSITIVE)}));
56 | // A printable non-space non-special character
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0()\\\"\\\\\\';]+")}));
58 |
59 | setShortcutStylePatterns(_shortcutStylePatterns);
60 | setFallthroughStylePatterns(_fallthroughStylePatterns);
61 | }
62 |
63 | public static List getFileExtensions() {
64 | return Arrays.asList(new String[]{"apollo", "agc", "aea"});
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangBasic.java:
--------------------------------------------------------------------------------
1 | // Contributed by peter dot kofler at code minus cop dot org
2 | package io.github.kbiakov.codeview.highlight.prettify.lang;
3 |
4 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Arrays;
8 | import java.util.List;
9 | import java.util.regex.Pattern;
10 |
11 | /**
12 | * This is similar to the lang-basic.js in JavaScript Prettify.
13 | *
14 | * To use, include prettify.js and this file in your HTML page.
15 | * Then put your code in an HTML tag like
16 | * (my BASIC code)
17 | *
18 | * @author peter dot kofler at code minus cop dot org
19 | */
20 | public class LangBasic extends Lang {
21 |
22 | public LangBasic() {
23 | List> _shortcutStylePatterns = new ArrayList>();
24 | List> _fallthroughStylePatterns = new ArrayList>();
25 |
26 | // "single-line-string"
27 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\"(?:[^\\\\\"\\r\\n]|\\\\.)*(?:\"|$))"), null, "\""}));
28 | // Whitespace
29 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\s+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
30 |
31 | // A line comment that starts with REM
32 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^REM[^\\r\\n]*"), null}));
33 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\\b"), null}));
34 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[A-Z][A-Z0-9]?(?:\\$|%)?", Pattern.CASE_INSENSITIVE), null}));
35 | // Literals .0, 0, 0.0 0E13
36 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+\\-]?\\d+)?", Pattern.CASE_INSENSITIVE), null, "0123456789"}));
37 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^.[^\\s\\w\\.$%\"]*"), null}));
38 |
39 | setShortcutStylePatterns(_shortcutStylePatterns);
40 | setFallthroughStylePatterns(_fallthroughStylePatterns);
41 | }
42 |
43 | public static List getFileExtensions() {
44 | return Arrays.asList(new String[]{"basic", "cbm"});
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangClj.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license Copyright (C) 2011 Google Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.kbiakov.codeview.highlight.prettify.lang;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
23 |
24 | /**
25 | * This is similar to the lang-clj.js in JavaScript Prettify.
26 | *
27 | * All comments are adapted from the JavaScript Prettify.
28 | *
29 | *
30 | * Registers a language handler for Clojure.
31 | *
32 | *
33 | * To use, include prettify.js and this file in your HTML page.
34 | * Then put your code in an HTML tag like
35 | *
(my lisp code)
36 | * The lang-cl class identifies the language as common lisp.
37 | * This file supports the following language extensions:
38 | * lang-clj - Clojure
39 | *
40 | *
41 | * I used lang-lisp.js as the basis for this adding the clojure specific
42 | * keywords and syntax.
43 | *
44 | * "Name" = 'Clojure'
45 | * "Author" = 'Rich Hickey'
46 | * "Version" = '1.2'
47 | * "About" = 'Clojure is a lisp for the jvm with concurrency primitives and a richer set of types.'
48 | *
49 | *
50 | * I used Clojure.org Reference as
51 | * the basis for the reserved word list.
52 | *
53 | *
54 | * @author jwall@google.com
55 | */
56 | public class LangClj extends Lang {
57 |
58 | public LangClj() {
59 | List> _shortcutStylePatterns = new ArrayList>();
60 | List> _fallthroughStylePatterns = new ArrayList>();
61 |
62 | // clojure has more paren types than minimal lisp.
63 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"opn", Pattern.compile("^[\\(\\{\\[]+"), null, "([{"}));
64 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"clo", Pattern.compile("^[\\)\\}\\]]+"), null, ")]}"}));
65 | // A line comment that starts with ;
66 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^;[^\r\n]*"), null, ";"}));
67 | // Whitespace
68 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
69 | // A double quoted, possibly multi-line, string.
70 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
71 | // clojure has a much larger set of keywords
72 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\\b"), null}));
73 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^:[0-9a-zA-Z\\-]+")}));
74 |
75 | setShortcutStylePatterns(_shortcutStylePatterns);
76 | setFallthroughStylePatterns(_fallthroughStylePatterns);
77 | }
78 |
79 | public static List getFileExtensions() {
80 | return Arrays.asList(new String[]{"clj"});
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangCss.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-css.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for CSS.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
34 | *
35 | *
36 | * http://www.w3.org/TR/CSS21/grammar.html Section G2 defines the lexical
37 | * grammar. This scheme does not recognize keywords containing escapes.
38 | *
39 | * @author mikesamuel@gmail.com
40 | */
41 | public class LangCss extends Lang {
42 |
43 | public LangCss() {
44 | List> _shortcutStylePatterns = new ArrayList>();
45 | List> _fallthroughStylePatterns = new ArrayList>();
46 |
47 | // The space production
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[ \t\r\n\f]+"), null, " \t\r\n\f"}));
49 | // Quoted strings. and
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\n\r\f\\\\\\\"]|\\\\(?:\r\n?|\n|\f)|\\\\[\\s\\S])*\\\""), null}));
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\'(?:[^\n\r\f\\\\\\']|\\\\(?:\r\n?|\n|\f)|\\\\[\\s\\S])*\\'"), null}));
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{"lang-css-str", Pattern.compile("^url\\(([^\\)\\\"\\']+)\\)", Pattern.CASE_INSENSITIVE)}));
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:url|rgb|\\!important|@import|@page|@media|@charset|inherit)(?=[^\\-\\w]|$)", Pattern.CASE_INSENSITIVE), null}));
54 | // A property name -- an identifier followed by a colon.
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{"lang-css-kw", Pattern.compile("^(-?(?:[_a-z]|(?:\\\\[0-9a-f]+ ?))(?:[_a-z0-9\\-]|\\\\(?:\\\\[0-9a-f]+ ?))*)\\s*:", Pattern.CASE_INSENSITIVE)}));
56 | // A C style block comment. The production.
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/\\*[^*]*\\*+(?:[^\\/*][^*]*\\*+)*\\/")}));
58 | // Escaping text spans
59 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^(?:)")}));
60 | // A number possibly containing a suffix.
61 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:\\d+|\\d*\\.\\d+)(?:%|[a-z]+)?", Pattern.CASE_INSENSITIVE)}));
62 | // A hex color
63 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^#(?:[0-9a-f]{3}){1,2}\\b", Pattern.CASE_INSENSITIVE)}));
64 | // An identifier
65 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^-?(?:[_a-z]|(?:\\\\[\\da-f]+ ?))(?:[_a-z\\d\\-]|\\\\(?:\\\\[\\da-f]+ ?))*", Pattern.CASE_INSENSITIVE)}));
66 | // A run of punctuation
67 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\s\\w\\'\\\"]+", Pattern.CASE_INSENSITIVE)}));
68 |
69 | setShortcutStylePatterns(_shortcutStylePatterns);
70 | setFallthroughStylePatterns(_fallthroughStylePatterns);
71 |
72 | setExtendedLangs(Arrays.asList(new Lang[]{new LangCssKeyword(), new LangCssString()}));
73 | }
74 |
75 | public static List getFileExtensions() {
76 | return Arrays.asList(new String[]{"css"});
77 | }
78 |
79 | protected static class LangCssKeyword extends Lang {
80 |
81 | public LangCssKeyword() {
82 | List> _shortcutStylePatterns = new ArrayList>();
83 | List> _fallthroughStylePatterns = new ArrayList>();
84 |
85 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^-?(?:[_a-z]|(?:\\\\[\\da-f]+ ?))(?:[_a-z\\d\\-]|\\\\(?:\\\\[\\da-f]+ ?))*", Pattern.CASE_INSENSITIVE)}));
86 |
87 | setShortcutStylePatterns(_shortcutStylePatterns);
88 | setFallthroughStylePatterns(_fallthroughStylePatterns);
89 | }
90 |
91 | public static List getFileExtensions() {
92 | return Arrays.asList(new String[]{"css-kw"});
93 | }
94 | }
95 |
96 | protected static class LangCssString extends Lang {
97 |
98 | public LangCssString() {
99 | List> _shortcutStylePatterns = new ArrayList>();
100 | List> _fallthroughStylePatterns = new ArrayList>();
101 |
102 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^[^\\)\\\"\\']+")}));
103 |
104 | setShortcutStylePatterns(_shortcutStylePatterns);
105 | setFallthroughStylePatterns(_fallthroughStylePatterns);
106 | }
107 |
108 | public static List getFileExtensions() {
109 | return Arrays.asList(new String[]{"css-str"});
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangDart.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license Copyright (C) 2013 Google Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.github.kbiakov.codeview.highlight.prettify.lang;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
23 |
24 | /**
25 | * This is similar to the lang-dart.js in JavaScript Prettify.
26 | *
27 | * All comments are adapted from the JavaScript Prettify.
28 | *
29 | *
30 | * Registers a language handler for Dart.
31 | *
32 | *
33 | * Loosely structured based on the DartLexer in Pygments: http://pygments.org/.
34 | *
35 | * To use, include prettify.js and this file in your HTML page.
36 | * Then put your code in an HTML tag like
37 | *
(Dart code)
38 | *
39 | * @author armstrong.timothy@gmail.com
40 | */
41 | public class LangDart extends Lang {
42 |
43 | public LangDart() {
44 | List> _shortcutStylePatterns = new ArrayList>();
45 | List> _fallthroughStylePatterns = new ArrayList>();
46 |
47 | // Whitespace.
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
49 |
50 | // Script tag.
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#!(?:.*)")}));
52 | // `import`, `library`, `part of`, `part`, `as`, `show`, and `hide`
53 | // keywords.
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\b(?:import|library|part of|part|as|show|hide)\\b", Pattern.CASE_INSENSITIVE)}));
55 | // Single-line comments.
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/\\/(?:.*)")}));
57 | // Multiline comments.
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/\\*[^*]*\\*+(?:[^\\/*][^*]*\\*+)*\\/")}));
59 | // `class` and `interface` keywords.
60 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\b(?:class|interface)\\b", Pattern.CASE_INSENSITIVE)}));
61 | // General keywords.
62 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\b(?:assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\\b", Pattern.CASE_INSENSITIVE)}));
63 | // Declaration keywords.
64 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\\b", Pattern.CASE_INSENSITIVE)}));
65 | // Keywords for types.
66 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^\\b(?:bool|double|Dynamic|int|num|Object|String|void)\\b", Pattern.CASE_INSENSITIVE)}));
67 | // Keywords for constants.
68 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("\\b(?:false|null|true)\\b", Pattern.CASE_INSENSITIVE)}));
69 | // Multiline strings, single- and double-quoted.
70 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^r?[\\']{3}[\\s|\\S]*?[^\\\\][\\']{3}")}));
71 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^r?[\\\"]{3}[\\s|\\S]*?[^\\\\][\\\"]{3}")}));
72 | // Normal and raw strings, single- and double-quoted.
73 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^r?\\'(\\'|(?:[^\\n\\r\\f])*?[^\\\\]\\')")}));
74 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^r?\\\"(\\\"|(?:[^\\n\\r\\f])*?[^\\\\]\\\")")}));
75 | // Identifiers.
76 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z_$][a-z0-9_]*", Pattern.CASE_INSENSITIVE)}));
77 | // Operators.
78 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[~!%^&*+=|?:<>/-]")}));
79 | // Hex numbers.
80 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\b0x[0-9a-f]+", Pattern.CASE_INSENSITIVE)}));
81 | // Decimal numbers.
82 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\b\\d+(?:\\.\\d*)?(?:e[+-]?\\d+)?", Pattern.CASE_INSENSITIVE)}));
83 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\b\\.\\d+(?:e[+-]?\\d+)?", Pattern.CASE_INSENSITIVE)}));
84 | // Punctuation.
85 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[(){}\\[\\],.;]")}));
86 |
87 | setShortcutStylePatterns(_shortcutStylePatterns);
88 | setFallthroughStylePatterns(_fallthroughStylePatterns);
89 | }
90 |
91 | public static List getFileExtensions() {
92 | return Arrays.asList(new String[]{"dart"});
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangErlang.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 Andrew Allen
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-erlang.js in JavaScript Prettify.
25 | *
26 | * All comments are adapted from the JavaScript Prettify.
27 | *
28 | *
29 | *
30 | * Derived from https://raw.github.com/erlang/otp/dev/lib/compiler/src/core_parse.yrl
31 | * Modified from Mike Samuel's Haskell plugin for google-code-prettify
32 | *
33 | * @author achew22@gmail.com
34 | */
35 | public class LangErlang extends Lang {
36 |
37 | public LangErlang() {
38 | List> _shortcutStylePatterns = new ArrayList>();
39 | List> _fallthroughStylePatterns = new ArrayList>();
40 |
41 | // Whitespace
42 | // whitechar -> newline | vertab | space | tab | uniWhite
43 | // newline -> return linefeed | return | linefeed | formfeed
44 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("\\t\\n\\x0B\\x0C\\r ]+"), null, "\t\n" + Character.toString((char) 0x0B) + Character.toString((char) 0x0C) + "\r "}));
45 | // Single line double-quoted strings.
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\\\n\\x0C\\r]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
47 |
48 | // Handle atoms
49 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[a-z][a-zA-Z0-9_]*")}));
50 | // Handle single quoted atoms
51 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\'(?:[^\\'\\\\\\n\\x0C\\r]|\\\\[^&])+\\'?"), null, "'"}));
52 |
53 | // Handle macros. Just to be extra clear on this one, it detects the ?
54 | // then uses the regexp to end it so be very careful about matching
55 | // all the terminal elements
56 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\?[^ \\t\\n({]+"), null, "?"}));
57 |
58 | // decimal -> digit{digit}
59 | // octal -> octit{octit}
60 | // hexadecimal -> hexit{hexit}
61 | // integer -> decimal
62 | // | 0o octal | 0O octal
63 | // | 0x hexadecimal | 0X hexadecimal
64 | // float -> decimal . decimal [exponent]
65 | // | decimal exponent
66 | // exponent -> (e | E) [+ | -] decimal
67 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:0o[0-7]+|0x[\\da-f]+|\\d+(?:\\.\\d+)?(?:e[+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE), null, "0123456789"}));
68 |
69 |
70 | // TODO: catch @declarations inside comments
71 |
72 | // Comments in erlang are started with % and go till a newline
73 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^%[^\\n\\r]*")}));
74 |
75 | // Catch macros
76 | //[PR['PR_TAG'], /?[^( \n)]+/],
77 |
78 | /**
79 | * %% Keywords (atoms are assumed to always be single-quoted).
80 | * 'module' 'attributes' 'do' 'let' 'in' 'letrec'
81 | * 'apply' 'call' 'primop'
82 | * 'case' 'of' 'end' 'when' 'fun' 'try' 'catch' 'receive' 'after'
83 | */
84 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\\b")}));
85 |
86 | /**
87 | * Catch definitions (usually defined at the top of the file)
88 | * Anything that starts -something
89 | */
90 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^-[a-z_]+")}));
91 |
92 | // Catch variables
93 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^[A-Z_][a-zA-Z0-9_]*")}));
94 |
95 | // matches the symbol production
96 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[.,;]")}));
97 |
98 | setShortcutStylePatterns(_shortcutStylePatterns);
99 | setFallthroughStylePatterns(_fallthroughStylePatterns);
100 | }
101 |
102 | public static List getFileExtensions() {
103 | return Arrays.asList(new String[]{"erlang", "erl"});
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangGo.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2010 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-go.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for the Go language..
29 | *
30 | * Based on the lexical grammar at
31 | * http://golang.org/doc/go_spec.html#Lexical_elements
32 | *
33 | * Go uses a minimal style for highlighting so the below does not distinguish
34 | * strings, keywords, literals, etc. by design.
35 | * From a discussion with the Go designers:
36 | *
37 | * On Thursday, July 22, 2010, Mike Samuel <...> wrote:
38 | * > On Thu, Jul 22, 2010, Rob 'Commander' Pike <...> wrote:
39 | * >> Personally, I would vote for the subdued style godoc presents at http://golang.org
40 | * >>
41 | * >> Not as fancy as some like, but a case can be made it's the official style.
42 | * >> If people want more colors, I wouldn't fight too hard, in the interest of
43 | * >> encouragement through familiarity, but even then I would ask to shy away
44 | * >> from technicolor starbursts.
45 | * >
46 | * > Like http://golang.org/pkg/go/scanner/ where comments are blue and all
47 | * > other content is black? I can do that.
48 | *
49 | *
50 | * @author mikesamuel@gmail.com
51 | */
52 | public class LangGo extends Lang {
53 |
54 | public LangGo() {
55 | List> _shortcutStylePatterns = new ArrayList>();
56 | List> _fallthroughStylePatterns = new ArrayList>();
57 |
58 | // Whitespace is made up of spaces, tabs and newline characters.
59 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
60 | // Not escaped as a string. See note on minimalism above.
61 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)|\\'(?:[^\\'\\\\]|\\\\[\\s\\S])+(?:\\'|$)|`[^`]*(?:`|$))"), null, "\"'"}));
62 | // Block comments are delimited by /* and */.
63 | // Single-line comments begin with // and extend to the end of a line.
64 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^(?:\\/\\/[^\\r\\n]*|\\/\\*[\\s\\S]*?\\*\\/)")}));
65 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:[^\\/\\\"\\'`]|\\/(?![\\/\\*]))+", Pattern.CASE_INSENSITIVE)}));
66 |
67 | setShortcutStylePatterns(_shortcutStylePatterns);
68 | setFallthroughStylePatterns(_fallthroughStylePatterns);
69 | }
70 |
71 | public static List getFileExtensions() {
72 | return Arrays.asList(new String[]{"go"});
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangHs.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-hs.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for Haskell.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
(my lisp code)
34 | * The lang-cl class identifies the language as common lisp.
35 | * This file supports the following language extensions:
36 | * lang-cl - Common Lisp
37 | * lang-el - Emacs Lisp
38 | * lang-lisp - Lisp
39 | * lang-scm - Scheme
40 | *
41 | *
42 | * I used http://www.informatik.uni-freiburg.de/~thiemann/haskell/haskell98-report-html/syntax-iso.html
43 | * as the basis, but ignore the way the ncomment production nests since this
44 | * makes the lexical grammar irregular. It might be possible to support
45 | * ncomments using the lookbehind filter.
46 | *
47 | *
48 | * @author mikesamuel@gmail.com
49 | */
50 | public class LangHs extends Lang {
51 |
52 | public LangHs() {
53 | List> _shortcutStylePatterns = new ArrayList>();
54 | List> _fallthroughStylePatterns = new ArrayList>();
55 |
56 | // Whitespace
57 | // whitechar -> newline | vertab | space | tab | uniWhite
58 | // newline -> return linefeed | return | linefeed | formfeed
59 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\x0B\\x0C\\r ]+"), null, "\t\n" + Character.toString((char) 0x0B) + Character.toString((char) 0x0C) + "\r "}));
60 | // Single line double and single-quoted strings.
61 | // char -> ' (graphic<' | \> | space | escape<\&>) '
62 | // string -> " {graphic<" | \> | space | escape | gap}"
63 | // escape -> \ ( charesc | ascii | decimal | o octal
64 | // | x hexadecimal )
65 | // charesc -> a | b | f | n | r | t | v | \ | " | ' | &
66 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\\\n\\x0C\\r]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
67 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\'(?:[^\\'\\\\\\n\\x0C\\r]|\\\\[^&])\\'?"), null, "'"}));
68 | // decimal -> digit{digit}
69 | // octal -> octit{octit}
70 | // hexadecimal -> hexit{hexit}
71 | // integer -> decimal
72 | // | 0o octal | 0O octal
73 | // | 0x hexadecimal | 0X hexadecimal
74 | // float -> decimal . decimal [exponent]
75 | // | decimal exponent
76 | // exponent -> (e | E) [+ | -] decimal
77 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:0o[0-7]+|0x[\\da-f]+|\\d+(?:\\.\\d+)?(?:e[+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE), null, "0123456789"}));
78 | // Haskell does not have a regular lexical grammar due to the nested
79 | // ncomment.
80 | // comment -> dashes [ any {any}] newline
81 | // ncomment -> opencom ANYseq {ncomment ANYseq}closecom
82 | // dashes -> '--' {'-'}
83 | // opencom -> '{-'
84 | // closecom -> '-}'
85 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^(?:(?:--+(?:[^\\r\\n\\x0C]*)?)|(?:\\{-(?:[^-]|-+[^-\\}])*-\\}))")}));
86 | // reservedid -> case | class | data | default | deriving | do
87 | // | else | if | import | in | infix | infixl | infixr
88 | // | instance | let | module | newtype | of | then
89 | // | type | where | _
90 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\\']|$)"), null}));
91 | // qvarid -> [ modid . ] varid
92 | // qconid -> [ modid . ] conid
93 | // varid -> (small {small | large | digit | ' })
94 | // conid -> large {small | large | digit | ' }
95 | // modid -> conid
96 | // small -> ascSmall | uniSmall | _
97 | // ascSmall -> a | b | ... | z
98 | // uniSmall -> any Unicode lowercase letter
99 | // large -> ascLarge | uniLarge
100 | // ascLarge -> A | B | ... | Z
101 | // uniLarge -> any uppercase or titlecase Unicode letter
102 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:[A-Z][\\w\\']*\\.)*[a-zA-Z][\\w\\']*")}));
103 | // matches the symbol production
104 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\t\\n\\x0B\\x0C\\r a-zA-Z0-9\\'\\\"]+")}));
105 |
106 | setShortcutStylePatterns(_shortcutStylePatterns);
107 | setFallthroughStylePatterns(_fallthroughStylePatterns);
108 | }
109 |
110 | public static List getFileExtensions() {
111 | return Arrays.asList(new String[]{"hs"});
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangLisp.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2008 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-lisp.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for Common Lisp and related languages.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
(my lisp code)
34 | * The lang-cl class identifies the language as common lisp.
35 | * This file supports the following language extensions:
36 | * lang-cl - Common Lisp
37 | * lang-el - Emacs Lisp
38 | * lang-lisp - Lisp
39 | * lang-scm - Scheme
40 | * lang-lsp - FAT 8.3 filename version of lang-lisp.
41 | *
42 | *
43 | * I used http://www.devincook.com/goldparser/doc/meta-language/grammar-LISP.htm
44 | * as the basis, but added line comments that start with ; and changed the atom
45 | * production to disallow unquoted semicolons.
46 | *
47 | * "Name" = 'LISP'
48 | * "Author" = 'John McCarthy'
49 | * "Version" = 'Minimal'
50 | * "About" = 'LISP is an abstract language that organizes ALL'
51 | * | 'data around "lists".'
52 | *
53 | * "Start Symbol" = [s-Expression]
54 | *
55 | * {Atom Char} = {Printable} - {Whitespace} - [()"\'']
56 | *
57 | * Atom = ( {Atom Char} | '\'{Printable} )+
58 | *
59 | * [s-Expression] ::= [Quote] Atom
60 | * | [Quote] '(' [Series] ')'
61 | * | [Quote] '(' [s-Expression] '.' [s-Expression] ')'
62 | *
63 | * [Series] ::= [s-Expression] [Series]
64 | * |
65 | *
66 | * [Quote] ::= '' !Quote = do not evaluate
67 | * |
68 | *
69 | *
70 | * I used Practical Common Lisp as
71 | * the basis for the reserved word list.
72 | *
73 | *
74 | * @author mikesamuel@gmail.com
75 | */
76 | public class LangLisp extends Lang {
77 |
78 | public LangLisp() {
79 | List> _shortcutStylePatterns = new ArrayList>();
80 | List> _fallthroughStylePatterns = new ArrayList>();
81 |
82 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"opn", Pattern.compile("^\\(+"), null, "("}));
83 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"clo", Pattern.compile("^\\)+"), null, ")"}));
84 | // A line comment that starts with ;
85 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^;[^\r\n]*"), null, ";"}));
86 | // Whitespace
87 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
88 | // A double quoted, possibly multi-line, string.
89 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
90 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\\b", Pattern.CASE_INSENSITIVE), null}));
91 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+\\-]?(?:[0#]x[0-9a-f]+|\\d+\\/\\d+|(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:[ed][+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE)}));
92 | // A single quote possibly followed by a word that optionally ends with
93 | // = ! or ?.
94 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\'(?:-*(?:\\w|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?)?")}));
95 | // A word that optionally ends with = ! or ?.
96 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^-*(?:[a-z_]|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?", Pattern.CASE_INSENSITIVE)}));
97 | // A printable non-space non-special character
98 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0()\\\"\\\\\\';]+")}));
99 |
100 | setShortcutStylePatterns(_shortcutStylePatterns);
101 | setFallthroughStylePatterns(_fallthroughStylePatterns);
102 | }
103 |
104 | public static List getFileExtensions() {
105 | return Arrays.asList(new String[]{"cl", "el", "lisp", "lsp", "scm", "ss", "rkt"});
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangLlvm.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2013 Nikhil Dabas
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-ml.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | * Registers a language handler for LLVM. From
28 | * https://gist.github.com/ndabas/2850418
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page. Then put your
32 | * code in an HTML tag like
(my LLVM code)
33 | *
34 | *
35 | * The regular expressions were adapted from:
36 | * https://github.com/hansstimer/llvm.tmbundle/blob/76fedd8f50fd6108b1780c51d79fbe3223de5f34/Syntaxes/LLVM.tmLanguage
37 | *
38 | * http://llvm.org/docs/LangRef.html#constants describes the language grammar.
39 | *
40 | * @author Nikhil Dabas
41 | */
42 | public class LangLlvm extends Lang {
43 |
44 | public LangLlvm() {
45 | List> _shortcutStylePatterns = new ArrayList>();
46 | List> _fallthroughStylePatterns = new ArrayList>();
47 |
48 | // Whitespace
49 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
50 | // A double quoted, possibly multi-line, string.
51 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^!?\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
52 | // comment.llvm
53 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^;[^\r\n]*"), null, ";"}));
54 | // variable.llvm
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\\d+)")}));
56 | // According to http://llvm.org/docs/LangRef.html#well-formedness
57 | // These reserved words cannot conflict with variable names, because none of them start with a prefix character ('%' or '@').
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^[A-Za-z_][0-9A-Za-z_]*"), null}));
59 | // constant.numeric.float.llvm
60 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\d+\\.\\d+")}));
61 | // constant.numeric.integer.llvm
62 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:\\d+|0[xX][a-fA-F0-9]+)")}));
63 | // punctuation
64 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[()\\[\\]{},=*<>:]|\\.\\.\\.$")}));
65 |
66 | setShortcutStylePatterns(_shortcutStylePatterns);
67 | setFallthroughStylePatterns(_fallthroughStylePatterns);
68 | }
69 |
70 | public static List getFileExtensions() {
71 | return Arrays.asList(new String[]{"llvm", "ll"});
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangLua.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2008 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-lua.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for Lua.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
(my Lua code)
34 | *
35 | *
36 | * I used http://www.lua.org/manual/5.1/manual.html#2.1
37 | * Because of the long-bracket concept used in strings and comments, Lua does
38 | * not have a regular lexical grammar, but luckily it fits within the space
39 | * of irregular grammars supported by javascript regular expressions.
40 | *
41 | * @author mikesamuel@gmail.com
42 | */
43 | public class LangLua extends Lang {
44 |
45 | public LangLua() {
46 | List> _shortcutStylePatterns = new ArrayList>();
47 | List> _fallthroughStylePatterns = new ArrayList>();
48 |
49 | // Whitespace
50 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
51 | // A double or single quoted, possibly multi-line, string.
52 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)|\\'(?:[^\\'\\\\]|\\\\[\\s\\S])*(?:\\'|$))"), null, "\"'"}));
53 | // A comment is either a line comment that starts with two dashes, or
54 | // two dashes preceding a long bracketed block.
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^--(?:\\[(=*)\\[[\\s\\S]*?(?:\\]\\1\\]|$)|[^\\r\\n]*)")}));
56 | // A long bracketed block not preceded by -- is a string.
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\[(=*)\\[[\\s\\S]*?(?:\\]\\1\\]|$)")}));
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\\b"), null}));
59 | // A number is a hex integer literal, a decimal real literal, or in
60 | // scientific notation.
61 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+-]?(?:0x[\\da-f]+|(?:(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:e[+\\-]?\\d+)?))", Pattern.CASE_INSENSITIVE)}));
62 | // An identifier
63 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z_]\\w*", Pattern.CASE_INSENSITIVE)}));
64 | // A run of punctuation
65 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0][^\\w\\n\\r \\xA0\\\"\\'\\-\\+=]*")}));
66 |
67 | setShortcutStylePatterns(_shortcutStylePatterns);
68 | setFallthroughStylePatterns(_fallthroughStylePatterns);
69 | }
70 |
71 | public static List getFileExtensions() {
72 | return Arrays.asList(new String[]{"lua"});
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangMd.java:
--------------------------------------------------------------------------------
1 | package io.github.kbiakov.codeview.highlight.prettify.lang;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.List;
6 | import java.util.regex.Pattern;
7 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
8 |
9 | /**
10 | * Registers a language handler for markdown.
11 | *
12 | * @author Kirill Biakov (kbiakov@gmail.com)
13 | */
14 | public class LangMd extends Lang {
15 |
16 | public LangMd() {
17 | List> _shortcutStylePatterns = new ArrayList>();
18 | List> _fallthroughStylePatterns = new ArrayList>();
19 |
20 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_DECLARATION, Pattern.compile("^#.*?[\\n\\r]")}));
21 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^```[\\s\\S]*?(?:```|$)")}));
22 |
23 | setShortcutStylePatterns(_shortcutStylePatterns);
24 | setFallthroughStylePatterns(_fallthroughStylePatterns);
25 | }
26 |
27 | public static List getFileExtensions() {
28 | return Arrays.asList(new String[]{"md", "markdown"});
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangMl.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2008 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-ml.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for OCaml, SML, F# and similar languages.
29 | *
30 | * Based on the lexical grammar at
31 | * http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc270597388
32 | *
33 | * @author mikesamuel@gmail.com
34 | */
35 | public class LangMl extends Lang {
36 |
37 | public LangMl() {
38 | List> _shortcutStylePatterns = new ArrayList>();
39 | List> _fallthroughStylePatterns = new ArrayList>();
40 |
41 | // Whitespace is made up of spaces, tabs and newline characters.
42 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
43 | // #if ident/#else/#endif directives delimit conditional compilation
44 | // sections
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#(?:if[\\t\\n\\r \\xA0]+(?:[a-z_$][\\w\\']*|``[^\\r\\n\\t`]*(?:``|$))|else|endif|light)", Pattern.CASE_INSENSITIVE), null, "#"}));
46 | // A double or single quoted, possibly multi-line, string.
47 | // F# allows escaped newlines in strings.
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)|\\'(?:[^\\'\\\\]|\\\\[\\s\\S])(?:\\'|$))"), null, "\"'"}));
49 | // Block comments are delimited by (* and *) and may be
50 | // nested. Single-line comments begin with // and extend to
51 | // the end of a line.
52 | // TODO: (*...*) comments can be nested. This does not handle that.
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^(?:\\/\\/[^\\r\\n]*|\\(\\*[\\s\\S]*?\\*\\))")}));
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\\b")}));
55 | // A number is a hex integer literal, a decimal real literal, or in
56 | // scientific notation.
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+\\-]?(?:0x[\\da-f]+|(?:(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:e[+\\-]?\\d+)?))", Pattern.CASE_INSENSITIVE)}));
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:[a-z_][\\w']*[!?#]?|``[^\\r\\n\\t`]*(?:``|$))", Pattern.CASE_INSENSITIVE)}));
59 | // A printable non-space non-special character
60 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\t\\n\\r \\xA0\\\"\\'\\w]+")}));
61 |
62 | setShortcutStylePatterns(_shortcutStylePatterns);
63 | setFallthroughStylePatterns(_fallthroughStylePatterns);
64 | }
65 |
66 | public static List getFileExtensions() {
67 | return Arrays.asList(new String[]{"fs", "ml"});
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangMumps.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2011 Kitware Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-mumps.js in JavaScript Prettify.
25 | *
26 | * All comments are adapted from the JavaScript Prettify.
27 | *
28 | *
29 | * To use, include prettify.js and this file in your HTML page.
30 | * Then put your code in an HTML tag like
31 | * (my SQL code)
32 | *
33 | * Commands, intrinsic functions and variables taken from ISO/IEC 11756:1999(E)
34 | *
35 | * @author chris.harris@kitware.com
36 | *
37 | * Known issues:
38 | *
39 | * - Currently can't distinguish between keywords and local or global variables having the same name
40 | * for exampe SET IF="IF?"
41 | * - m file are already used for MatLab hence using mumps.
42 | */
43 | public class LangMumps extends Lang {
44 |
45 | public LangMumps() {
46 | List> _shortcutStylePatterns = new ArrayList>();
47 | List> _fallthroughStylePatterns = new ArrayList>();
48 |
49 | final String commands = "B|BREAK|" +
50 | "C|CLOSE|" +
51 | "D|DO|" +
52 | "E|ELSE|" +
53 | "F|FOR|" +
54 | "G|GOTO|" +
55 | "H|HALT|" +
56 | "H|HANG|" +
57 | "I|IF|" +
58 | "J|JOB|" +
59 | "K|KILL|" +
60 | "L|LOCK|" +
61 | "M|MERGE|" +
62 | "N|NEW|" +
63 | "O|OPEN|" +
64 | "Q|QUIT|" +
65 | "R|READ|" +
66 | "S|SET|" +
67 | "TC|TCOMMIT|" +
68 | "TRE|TRESTART|" +
69 | "TRO|TROLLBACK|" +
70 | "TS|TSTART|" +
71 | "U|USE|" +
72 | "V|VIEW|" +
73 | "W|WRITE|" +
74 | "X|XECUTE";
75 |
76 | final String intrinsicVariables = "D|DEVICE|" +
77 | "EC|ECODE|" +
78 | "ES|ESTACK|" +
79 | "ET|ETRAP|" +
80 | "H|HOROLOG|" +
81 | "I|IO|" +
82 | "J|JOB|" +
83 | "K|KEY|" +
84 | "P|PRINCIPAL|" +
85 | "Q|QUIT|" +
86 | "ST|STACK|" +
87 | "S|STORAGE|" +
88 | "SY|SYSTEM|" +
89 | "T|TEST|" +
90 | "TL|TLEVEL|" +
91 | "TR|TRESTART|" +
92 | "X|" +
93 | "Y|" +
94 | "Z[A-Z]*|";
95 |
96 | final String intrinsicFunctions = "A|ASCII|" +
97 | "C|CHAR|" +
98 | "D|DATA|" +
99 | "E|EXTRACT|" +
100 | "F|FIND|" +
101 | "FN|FNUMBER|" +
102 | "G|GET|" +
103 | "J|JUSTIFY|" +
104 | "L|LENGTH|" +
105 | "NA|NAME|" +
106 | "O|ORDER|" +
107 | "P|PIECE|" +
108 | "QL|QLENGTH|" +
109 | "QS|QSUBSCRIPT|" +
110 | "Q|QUERY|" +
111 | "R|RANDOM|" +
112 | "RE|REVERSE|" +
113 | "S|SELECT|" +
114 | "ST|STACK|" +
115 | "T|TEXT|" +
116 | "TR|TRANSLATE|" +
117 | "V|VIEW|" +
118 | "Z[A-Z]*|";
119 |
120 | final String intrinsic = intrinsicVariables + intrinsicFunctions;
121 |
122 | // Whitespace
123 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\t\n\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
124 | // A double or single quoted, possibly multi-line, string.
125 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\"(?:[^\"]|\\\\.)*\")"), null, "\""}));
126 |
127 | // A line comment that starts with ;
128 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^;[^\\r\\n]*"), null, ";"}));
129 | // Add intrinsic variables and functions as declarations, there not really but it mean
130 | // they will hilighted differently from commands.
131 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_DECLARATION, Pattern.compile("^(?:\\$(?:" + intrinsic + "))\\b", Pattern.CASE_INSENSITIVE), null}));
132 | // Add commands as keywords
133 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:[^\\$]" + commands + ")\\b", Pattern.CASE_INSENSITIVE), null}));
134 | // A number is a decimal real literal or in scientific notation.
135 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+-]?(?:(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:E[+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE)}));
136 | // An identifier
137 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z][a-zA-Z0-9]*", Pattern.CASE_INSENSITIVE)}));
138 | // Exclude $ % and ^
139 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r\\xA0\\\"\\$;%\\^]|_")}));
140 |
141 | setShortcutStylePatterns(_shortcutStylePatterns);
142 | setFallthroughStylePatterns(_fallthroughStylePatterns);
143 | }
144 |
145 | public static List getFileExtensions() {
146 | return Arrays.asList(new String[]{"mumps"});
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangN.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2011 Zimin A.V.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-n.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for the Nemerle language.
29 | * http://nemerle.org
30 | * @author Zimin A.V.
31 | */
32 | public class LangN extends Lang {
33 |
34 | protected static String keywords = "abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|"
35 | + "fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|"
36 | + "null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|"
37 | + "syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|"
38 | + "assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|"
39 | + "otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield";
40 |
41 | public LangN() {
42 | List> _shortcutStylePatterns = new ArrayList>();
43 | List> _fallthroughStylePatterns = new ArrayList>();
44 |
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\\'(?:[^\\\\\\'\\r\\n]|\\\\.)*\\'|\\\"(?:[^\\\\\\\"\\r\\n]|\\\\.)*(?:\\\"|$))"), null, "\""}));
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\\b|[^\\r\\n]*)"), null, "#"}));
47 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\s+"), null, " \r\n\t" + Character.toString((char) 0xA0)}));
48 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^@\\\"(?:[^\\\"]|\\\"\\\")*(?:\\\"|$)"), null}));
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^<#(?:[^#>])*(?:#>|$)"), null}));
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^<(?:(?:(?:\\.\\.\\/)*|\\/?)(?:[\\w-]+(?:\\/[\\w-]+)+)?[\\w-]+\\.h|[a-z]\\w*)>"), null,}));
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/\\/[^\\r\\n]*"), null}));
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/\\*[\\s\\S]*?(?:\\*\\/|$)"), null}));
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:" + keywords + ")\\\\b"), null}));
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\\b"), null}));
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^@[a-z_$][a-z_$@0-9]*", Pattern.CASE_INSENSITIVE), null}));
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^@[A-Z]+[a-z][A-Za-z_$@0-9]*"), null}));
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^'?[A-Za-z_$][a-z_$@0-9]*", Pattern.CASE_INSENSITIVE), null}));
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:"
59 | // A hex number
60 | + "0x[a-f0-9]+"
61 | // or an octal or decimal number,
62 | + "|(?:\\\\d(?:_\\\\d+)*\\\\d*(?:\\\\.\\\\d*)?|\\\\.\\\\d\\\\+)"
63 | // possibly in scientific notation
64 | + "(?:e[+\\\\-]?\\\\d+)?"
65 | + ")"
66 | // with an optional modifier like UL for unsigned long
67 | + "[a-z]*", Pattern.CASE_INSENSITIVE), null, "0123456789"}));
68 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^.[^\\s\\w\\.$@\\'\\\"\\`\\/\\#]*"), null}));
69 |
70 | setShortcutStylePatterns(_shortcutStylePatterns);
71 | setFallthroughStylePatterns(_fallthroughStylePatterns);
72 | }
73 |
74 | public static List getFileExtensions() {
75 | return Arrays.asList(new String[]{"n", "nemerle"});
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangPascal.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Onno Hommes.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-appollo.js in JavaScript Prettify.
25 | *
26 | * All comments are adapted from the JavaScript Prettify.
27 | *
28 | *
29 | * Registers a language handler for the AGC/AEA Assembly Language as described
30 | * at http://virtualagc.googlecode.com
31 | *
32 | * This file could be used by goodle code to allow syntax highlight for
33 | * Virtual AGC SVN repository or if you don't want to commonize
34 | * the header for the agc/aea html assembly listing.
35 | *
36 | * @author ohommes@alumni.cmu.edu
37 | */
38 | public class LangPascal extends Lang {
39 |
40 | public LangPascal() {
41 | List> _shortcutStylePatterns = new ArrayList>();
42 | List> _fallthroughStylePatterns = new ArrayList>();
43 |
44 | // 'single-line-string'
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\\'(?:[^\\\\\\'\\r\\n]|\\\\.)*(?:\\'|$))"), null, "'"}));
46 | // Whitespace
47 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\s+"), null, " \r\n\t" + Character.toString((char) 0xA0)}));
48 |
49 | // A cStyleComments comment (* *) or {}
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\(\\*[\\s\\S]*?(?:\\*\\)|$)|^\\{[\\s\\S]*?(?:\\}|$)"), null}));
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\\b", Pattern.CASE_INSENSITIVE), null}));
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:true|false|self|nil)", Pattern.CASE_INSENSITIVE), null}));
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z][a-z0-9]*", Pattern.CASE_INSENSITIVE), null}));
54 | // Literals .0, 0, 0.0 0E13
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:\\$[a-f0-9]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE), null, "0123456789"}));
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^.[^\\s\\w\\.$@\\'\\/]*"), null}));
57 |
58 | setShortcutStylePatterns(_shortcutStylePatterns);
59 | setFallthroughStylePatterns(_fallthroughStylePatterns);
60 | }
61 |
62 | public static List getFileExtensions() {
63 | return Arrays.asList(new String[]{"pascal"});
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangProto.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2010 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | /**
17 | * It is included directly in the {@link io.github.kbiakov.codeview.highlight.prettify.parser.Prettify}.
18 | */
19 | public class LangProto {
20 | }
21 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangR.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2012 Jeffrey B. Arnold
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-r.js in JavaScript Prettify.
25 | *
26 | * To use, include prettify.js and this file in your HTML page.
27 | * Then put your code in an HTML tag like
28 | * code
29 | *
30 | * Language definition from
31 | * http://cran.r-project.org/doc/manuals/R-lang.html.
32 | * Many of the regexes are shared with the pygments SLexer,
33 | * http://pygments.org/.
34 | *
35 | * Original: https://raw.github.com/jrnold/prettify-lang-r-bugs/master/lang-r.js
36 | *
37 | * @author jeffrey.arnold@gmail.com
38 | */
39 | public class LangR extends Lang {
40 |
41 | public LangR() {
42 | List> _shortcutStylePatterns = new ArrayList>();
43 | List> _fallthroughStylePatterns = new ArrayList>();
44 |
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
47 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\'(?:[^\\'\\\\]|\\\\[\\s\\S])*(?:\\'|$)"), null, "'"}));
48 |
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#.*")}));
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])")}));
51 | // hex numbes
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?")}));
53 | // Decimal numbers
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+-]?([0-9]+(\\.[0-9]+)?|\\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?")}));
55 | // builtin symbols
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\\.\\.(?:\\.|[0-9]+))(?![A-Za-z0-9_.])")}));
57 | // assignment, operators, and parens, etc.
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^(?:<-|->>?|-|==|<=|>=|<|>|&&?|!=|\\|\\|?|\\*|\\+|\\^|\\/|!|%.*?%|=|~|\\$|@|:{1,3}|[\\[\\](){};,?])")}));
59 | // valid variable names
60 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:[A-Za-z]+[A-Za-z0-9_.]*|\\.[a-zA-Z_][0-9a-zA-Z\\._]*)(?![A-Za-z0-9_.])")}));
61 | // string backtick
62 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^`.+`")}));
63 |
64 | setShortcutStylePatterns(_shortcutStylePatterns);
65 | setFallthroughStylePatterns(_fallthroughStylePatterns);
66 | }
67 |
68 | public static List getFileExtensions() {
69 | return Arrays.asList(new String[]{"r", "s", "R", "S", "Splus"});
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangRd.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2012 Jeffrey Arnold
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-rd.js in JavaScript Prettify.
25 | *
26 | * Support for R documentation (Rd) files
27 | *
28 | * Minimal highlighting or Rd files, basically just highlighting
29 | * macros. It does not try to identify verbatim or R-like regions of
30 | * macros as that is too complicated for a lexer. Descriptions of the
31 | * Rd format can be found
32 | * http://cran.r-project.org/doc/manuals/R-exts.html and
33 | * http://developer.r-project.org/parseRd.pdf.
34 | *
35 | * @author Jeffrey Arnold
36 | */
37 | public class LangRd extends Lang {
38 |
39 | public LangRd() {
40 | List> _shortcutStylePatterns = new ArrayList>();
41 | List> _fallthroughStylePatterns = new ArrayList>();
42 |
43 | // whitespace
44 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
45 | // all comments begin with '%'
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^%[^\\r\\n]*"), null, "%"}));
47 |
48 | // special macros with no args
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\\\(?:cr|l?dots|R|tab)\\b")}));
50 | // macros
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\\\[a-zA-Z@]+")}));
52 | // highlighted as macros, since technically they are
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^#(?:ifn?def|endif)")}));
54 | // catch escaped brackets
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\\\[{}]")}));
56 | // punctuation
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[{}()\\[\\]]+")}));
58 |
59 | setShortcutStylePatterns(_shortcutStylePatterns);
60 | setFallthroughStylePatterns(_fallthroughStylePatterns);
61 | }
62 |
63 | public static List getFileExtensions() {
64 | return Arrays.asList(new String[]{"Rd", "rd"});
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangScala.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2010 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-scala.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for Scala.
29 | *
30 | * Derived from http://lampsvn.epfl.ch/svn-repos/scala/scala-documentation/trunk/src/reference/SyntaxSummary.tex
31 | *
32 | * @author mikesamuel@gmail.com
33 | */
34 | public class LangScala extends Lang {
35 |
36 | public LangScala() {
37 | List> _shortcutStylePatterns = new ArrayList>();
38 | List> _fallthroughStylePatterns = new ArrayList>();
39 |
40 | // Whitespace
41 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
42 | // A double or single quoted string
43 | // or a triple double-quoted multi-line string.
44 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\"(?:(?:\"\"(?:\"\"?(?!\")|[^\\\\\"]|\\\\.)*\"{0,3})|(?:[^\"\\r\\n\\\\]|\\\\.)*\"?))"), null, "\""}));
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^`(?:[^\\r\\n\\\\`]|\\\\.)*`?"), null, "`"}));
46 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[!#%&()*+,\\-:;<=>?@\\[\\\\\\]^{|}~]+"), null, "!#%&()*+,-:;<=>?@[\\\\]^{|}~"}));
47 | // A symbol literal is a single quote followed by an identifier with no
48 | // single quote following
49 | // A character literal has single quotes on either side
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^'(?:[^\\r\\n\\\\']|\\\\(?:'|[^\\r\\n']+))'")}));
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^'[a-zA-Z_$][\\w$]*(?!['$\\w])")}));
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\\b")}));
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:true|false|null|this)\\b")}));
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\\.[0-9]+)?(?:E[+\\-]?[0-9]+)?F?|L?))|\\\\.[0-9]+(?:E[+\\-]?[0-9]+)?F?)", Pattern.CASE_INSENSITIVE)}));
55 | // Treat upper camel case identifiers as types.
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^[$_]*[A-Z][_$A-Z0-9]*[a-z][\\w$]*")}));
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[$a-zA-Z_][\\w$]*")}));
58 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^\\/(?:\\/.*|\\*(?:\\/|\\**[^*/])*(?:\\*+\\/?)?)")}));
59 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^(?:\\.+|\\/)")}));
60 |
61 | setShortcutStylePatterns(_shortcutStylePatterns);
62 | setFallthroughStylePatterns(_fallthroughStylePatterns);
63 | }
64 |
65 | public static List getFileExtensions() {
66 | return Arrays.asList(new String[]{"scala"});
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangSql.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2008 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-sql.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for SQL.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
(my SQL code)
34 | *
35 | *
36 | * http://savage.net.au/SQL/sql-99.bnf.html is the basis for the grammar, and
37 | * http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx and
38 | * http://meta.stackoverflow.com/q/92352/137403 as the bases for the keyword
39 | * list.
40 | *
41 | * @author mikesamuel@gmail.com
42 | */
43 | public class LangSql extends Lang {
44 |
45 | public LangSql() {
46 | List> _shortcutStylePatterns = new ArrayList>();
47 | List> _fallthroughStylePatterns = new ArrayList>();
48 |
49 | // Whitespace
50 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
51 | // A double or single quoted, possibly multi-line, string.
52 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:\"(?:[^\\\"\\\\]|\\\\.)*\"|'(?:[^\\'\\\\]|\\\\.)*')"), null, "\"'"}));
53 | // A comment is either a line comment that starts with two dashes, or
54 | // two dashes preceding a long bracketed block.
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^(?:--[^\\r\\n]*|\\/\\*[\\s\\S]*?(?:\\*\\/|$))")}));
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONNECT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOLLOWING|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|MATCH|MERGE|NATIONAL|NOCHECK|NONCLUSTERED|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PERCENT|PLAN|PRECEDING|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|ROWS?|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNBOUNDED|UNION|UNIQUE|UPDATE|UPDATETEXT|USE|USER|USING|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WRITETEXT)(?=[^\\w-]|$)", Pattern.CASE_INSENSITIVE), null}));
57 | // A number is a hex integer literal, a decimal real literal, or in
58 | // scientific notation.
59 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+-]?(?:0x[\\da-f]+|(?:(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:e[+\\-]?\\d+)?))", Pattern.CASE_INSENSITIVE)}));
60 | // An identifier
61 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[a-z_][\\w-]*", Pattern.CASE_INSENSITIVE)}));
62 | // A run of punctuation
63 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0\\\"\\'][^\\w\\t\\n\\r \\xA0+\\-\\\"\\']*")}));
64 |
65 | setShortcutStylePatterns(_shortcutStylePatterns);
66 | setFallthroughStylePatterns(_fallthroughStylePatterns);
67 | }
68 |
69 | public static List getFileExtensions() {
70 | return Arrays.asList(new String[]{"sql"});
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangTcl.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2012 Pyrios.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import java.util.regex.Pattern;
22 |
23 | /**
24 | * This is similar to the lang-tcl.js in JavaScript Prettify.
25 | *
26 | * All comments are adapted from the JavaScript Prettify.
27 | *
28 | * To use, include prettify.js and this file in your HTML page.
29 | * Then put your code in an HTML tag like
30 | * proc foo {} {puts bar}
31 | *
32 | * I copy-pasted lang-lisp.js, so this is probably not 100% accurate.
33 | * I used http://wiki.tcl.tk/1019 for the keywords, but tried to only
34 | * include as keywords that had more impact on the program flow
35 | * rather than providing convenience. For example, I included 'if'
36 | * since that provides branching, but left off 'open' since that is more
37 | * like a proc. Add more if it makes sense.
38 | *
39 | * @author pyrios@gmail.com
40 | */
41 | public class LangTcl extends Lang {
42 |
43 | public LangTcl() {
44 | List> _shortcutStylePatterns = new ArrayList>();
45 | List> _fallthroughStylePatterns = new ArrayList>();
46 |
47 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"opn", Pattern.compile("^\\{+"), null, "{"}));
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{"clo", Pattern.compile("^\\}+"), null, "}"}));
49 | // A line comment that starts with ;
50 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#[^\\r\\n]*"), null, "#"}));
51 | // Whitespace
52 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
53 | // A double quoted, possibly multi-line, string.
54 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\\\"(?:[^\\\"\\\\]|\\\\[\\s\\S])*(?:\\\"|$)"), null, "\""}));
55 |
56 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\\b"), null}));
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^[+\\-]?(?:[0#]x[0-9a-f]+|\\d+\\/\\d+|(?:\\.\\d+|\\d+(?:\\.\\d*)?)(?:[ed][+\\-]?\\d+)?)", Pattern.CASE_INSENSITIVE)}));
58 | // A single quote possibly followed by a word that optionally ends with
59 | // = ! or ?.
60 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\'(?:-*(?:\\w|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?)?")}));
61 | // A word that optionally ends with = ! or ?.
62 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^-*(?:[a-z_]|\\\\[\\x21-\\x7e])(?:[\\w-]*|\\\\[\\x21-\\x7e])[=!?]?")}));
63 | // A printable non-space non-special character
64 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0()\\\"\\\\\\';]+")}));
65 |
66 | setShortcutStylePatterns(_shortcutStylePatterns);
67 | setFallthroughStylePatterns(_fallthroughStylePatterns);
68 | }
69 |
70 | public static List getFileExtensions() {
71 | return Arrays.asList(new String[]{"tcl"});
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangTex.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2011 Martin S.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-tex.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Support for tex highlighting as discussed on
29 | * meta.tex.stackexchange.com.
30 | *
31 | * @author Martin S.
32 | */
33 | public class LangTex extends Lang {
34 |
35 | public LangTex() {
36 | List> _shortcutStylePatterns = new ArrayList>();
37 | List> _fallthroughStylePatterns = new ArrayList>();
38 |
39 | // whitespace
40 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
41 | // all comments begin with '%'
42 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^%[^\\r\\n]*"), null, "%"}));
43 | //[PR['PR_DECLARATION'], /^\\([egx]?def|(new|renew|provide)(command|environment))\b/],
44 | // any command starting with a \ and contains
45 | // either only letters (a-z,A-Z), '@' (internal macros)
46 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\\\[a-zA-Z@]+")}));
47 | // or contains only one character
48 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\\\.")}));
49 | // Highlight dollar for math mode and ampersam for tabular
50 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^[$&]")}));
51 | // numeric measurement values with attached units
52 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("[+-]?(?:\\.\\d+|\\d+(?:\\.\\d*)?)(cm|em|ex|in|pc|pt|bp|mm)", Pattern.CASE_INSENSITIVE)}));
53 | // punctuation usually occurring within commands
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[{}()\\[\\]=]+")}));
55 |
56 | setShortcutStylePatterns(_shortcutStylePatterns);
57 | setFallthroughStylePatterns(_fallthroughStylePatterns);
58 | }
59 |
60 | public static List getFileExtensions() {
61 | return Arrays.asList(new String[]{"latex", "tex"});
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangVb.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-vb.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for various flavors of basic.
29 | *
30 | *
31 | * To use, include prettify.js and this file in your HTML page.
32 | * Then put your code in an HTML tag like
33 | *
34 | *
35 | *
36 | * http://msdn.microsoft.com/en-us/library/aa711638(VS.71).aspx defines the
37 | * visual basic grammar lexical grammar.
38 | *
39 | * @author mikesamuel@gmail.com
40 | */
41 | public class LangVb extends Lang {
42 |
43 | public LangVb() {
44 | List> _shortcutStylePatterns = new ArrayList>();
45 | List> _fallthroughStylePatterns = new ArrayList>();
46 |
47 | // Whitespace
48 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0\\u2028\\u2029]+"), null, "\t\n\r " + Character.toString((char) 0xA0) + "\u2028\u2029"}));
49 | // A double quoted string with quotes escaped by doubling them.
50 | // A single character can be suffixed with C.
51 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:[\\\"\\u201C\\u201D](?:[^\\\"\\u201C\\u201D]|[\\\"\\u201C\\u201D]{2})(?:[\\\"\\u201C\\u201D]c|$)|[\\\"\\u201C\\u201D](?:[^\\\"\\u201C\\u201D]|[\\\"\\u201C\\u201D]{2})*(?:[\\\"\\u201C\\u201D]|$))", Pattern.CASE_INSENSITIVE), null, "\"\u201C\u201D"}));
52 | // A comment starts with a single quote and runs until the end of the line.
53 | // VB6 apparently allows _ as an escape sequence for newlines though
54 | // this is not a documented feature of VB.net.
55 | // http://meta.stackoverflow.com/q/121497/137403
56 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^[\\'\\u2018\\u2019](?:_(?:\r\n?|[^\r]?)|[^\\r\\n_\\u2028\\u2029])*"), null, "'\u2018\u2019"}));
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\\b", Pattern.CASE_INSENSITIVE), null}));
58 | // A second comment form
59 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^REM\\b[^\\r\\n\\u2028\\u2029]*", Pattern.CASE_INSENSITIVE)}));
60 | // A boolean, numeric, or date literal.
61 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:True\\b|False\\b|Nothing\\b|\\d+(?:E[+\\-]?\\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\\d*\\.\\d+(?:E[+\\-]?\\d+)?[FRD]?|#\\s+(?:\\d+[\\-\\/]\\d+[\\-\\/]\\d+(?:\\s+\\d+:\\d+(?::\\d+)?(\\s*(?:AM|PM))?)?|\\d+:\\d+(?::\\d+)?(\\s*(?:AM|PM))?)\\s+#)", Pattern.CASE_INSENSITIVE)}));
62 | // An identifier. Keywords can be turned into identifers
63 | // with square brackets, and there may be optional type
64 | // characters after a normal identifier in square brackets.
65 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:(?:[a-z]|_\\w)\\w*(?:\\[[%&@!#]+\\])?|\\[(?:[a-z]|_\\w)\\w*\\])", Pattern.CASE_INSENSITIVE)}));
66 | // A run of punctuation
67 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\\"\\'\\[\\]\\xA0\\u2018\\u2019\\u201C\\u201D\\u2028\\u2029]+")}));
68 | // Square brackets
69 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^(?:\\[|\\])")}));
70 |
71 | setShortcutStylePatterns(_shortcutStylePatterns);
72 | setFallthroughStylePatterns(_fallthroughStylePatterns);
73 | }
74 |
75 | public static List getFileExtensions() {
76 | return Arrays.asList(new String[]{"vb", "vbs"});
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangVhdl.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2010 benoit@ryder.fr
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-vhdl.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for VHDL '93.
29 | *
30 | * Based on the lexical grammar and keywords at
31 | * http://www.iis.ee.ethz.ch/~zimmi/download/vhdl93_syntax.html
32 | *
33 | * @author benoit@ryder.fr
34 | */
35 | public class LangVhdl extends Lang {
36 |
37 | public LangVhdl() {
38 | List> _shortcutStylePatterns = new ArrayList>();
39 | List> _fallthroughStylePatterns = new ArrayList>();
40 |
41 | // Whitespace
42 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t\\n\\r \\xA0]+"), null, "\t\n\r " + Character.toString((char) 0xA0)}));
43 | // String, character or bit string
44 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^(?:[BOX]?\"(?:[^\\\"]|\"\")*\"|'.')", Pattern.CASE_INSENSITIVE)}));
45 | // Comment, from two dashes until end of line.
46 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^--[^\\r\\n]*")}));
47 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\\w-]|$)", Pattern.CASE_INSENSITIVE), null}));
48 | // Type, predefined or standard
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\\w-]|$)", Pattern.CASE_INSENSITIVE), null}));
50 | // Predefined attributes
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^\\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\\w-]|$)", Pattern.CASE_INSENSITIVE), null}));
52 | // Number, decimal or based literal
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^\\d+(?:_\\d+)*(?:#[\\w\\\\.]+#(?:[+\\-]?\\d+(?:_\\d+)*)?|(?:\\.\\d+(?:_\\d+)*)?(?:E[+\\-]?\\d+(?:_\\d+)*)?)", Pattern.CASE_INSENSITIVE)}));
54 | // Identifier, basic or extended
55 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:[a-z]\\w*|\\\\[^\\\\]*\\\\)", Pattern.CASE_INSENSITIVE)}));
56 | // Punctuation
57 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[^\\w\\t\\n\\r \\xA0\\\"\\'][^\\w\\t\\n\\r \\xA0\\-\\\"\\']*")}));
58 |
59 | setShortcutStylePatterns(_shortcutStylePatterns);
60 | setFallthroughStylePatterns(_fallthroughStylePatterns);
61 | }
62 |
63 | public static List getFileExtensions() {
64 | return Arrays.asList(new String[]{"vhdl", "vhd"});
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangWiki.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2009 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-wiki.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for Wiki pages.
29 | *
30 | * Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax
31 | *
32 | * @author mikesamuel@gmail.com
33 | */
34 | public class LangWiki extends Lang {
35 |
36 | public LangWiki() {
37 | List> _shortcutStylePatterns = new ArrayList>();
38 | List> _fallthroughStylePatterns = new ArrayList>();
39 |
40 | // Whitespace
41 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^[\\t \\xA0a-gi-z0-9]+"), null, "\t " + Character.toString((char) 0xA0) + "abcdefgijklmnopqrstuvwxyz0123456789"}));
42 | // Wiki formatting
43 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[=*~\\^\\[\\]]+"), null, "=*~^[]"}));
44 | // Meta-info like #summary, #labels, etc.
45 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{"lang-wiki.meta", Pattern.compile("(?:^^|\r\n?|\n)(#[a-z]+)\\b")}));
46 | // A WikiWord
47 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_LITERAL, Pattern.compile("^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\\b")}));
48 | // A preformatted block in an unknown language
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{"lang-", Pattern.compile("^\\{\\{\\{([\\s\\S]+?)\\}\\}\\}")}));
50 | // A block of source code in an unknown language
51 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{"lang-", Pattern.compile("^`([^\r\n`]+)`")}));
52 | // An inline URL.
53 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^https?:\\/\\/[^\\/?#\\s]*(?:\\/[^?#\\s]*)?(?:\\?[^#\\s]*)?(?:#\\S*)?", Pattern.CASE_INSENSITIVE)}));
54 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^(?:\r\n|[\\s\\S])[^#=*~^A-Zh\\{`\\[\r\n]*")}));
55 |
56 | setShortcutStylePatterns(_shortcutStylePatterns);
57 | setFallthroughStylePatterns(_fallthroughStylePatterns);
58 |
59 | setExtendedLangs(Arrays.asList(new Lang[]{new LangWikiMeta()}));
60 | }
61 |
62 | public static List getFileExtensions() {
63 | return Arrays.asList(new String[]{"wiki"});
64 | }
65 |
66 | protected static class LangWikiMeta extends Lang {
67 |
68 | public LangWikiMeta() {
69 | List> _shortcutStylePatterns = new ArrayList>();
70 | List> _fallthroughStylePatterns = new ArrayList>();
71 |
72 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^#[a-z]+", Pattern.CASE_INSENSITIVE), null, "#"}));
73 |
74 | setShortcutStylePatterns(_shortcutStylePatterns);
75 | setFallthroughStylePatterns(_fallthroughStylePatterns);
76 | }
77 |
78 | public static List getFileExtensions() {
79 | return Arrays.asList(new String[]{"wiki.meta"});
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/LangYaml.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2010 ribrdb @ code.google.com
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.lang;
15 |
16 | import java.util.ArrayList;
17 | import java.util.Arrays;
18 | import java.util.List;
19 | import java.util.regex.Pattern;
20 | import io.github.kbiakov.codeview.highlight.prettify.parser.Prettify;
21 |
22 | /**
23 | * This is similar to the lang-yaml.js in JavaScript Prettify.
24 | *
25 | * All comments are adapted from the JavaScript Prettify.
26 | *
27 | *
28 | * Registers a language handler for YAML.
29 | *
30 | * @author ribrdb
31 | */
32 | public class LangYaml extends Lang {
33 |
34 | public LangYaml() {
35 | List> _shortcutStylePatterns = new ArrayList>();
36 | List> _fallthroughStylePatterns = new ArrayList>();
37 |
38 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^[:|>?]+"), null, ":|>?"}));
39 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_DECLARATION, Pattern.compile("^%(?:YAML|TAG)[^#\\r\\n]+"), null, "%"}));
40 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^[&]\\S+"), null, "&"}));
41 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_TYPE, Pattern.compile("^!\\S*"), null, "!"}));
42 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^\"(?:[^\\\\\"]|\\\\.)*(?:\"|$)"), null, "\""}));
43 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_STRING, Pattern.compile("^'(?:[^']|'')*(?:'|$)"), null, "'"}));
44 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_COMMENT, Pattern.compile("^#[^\\r\\n]*"), null, "#"}));
45 | _shortcutStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\s+"), null, " \t\r\n"}));
46 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_DECLARATION, Pattern.compile("^(?:---|\\.\\.\\.)(?:[\\r\\n]|$)")}));
47 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PUNCTUATION, Pattern.compile("^-")}));
48 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_KEYWORD, Pattern.compile("^\\w+:[ \\r\\n]")}));
49 | _fallthroughStylePatterns.add(Arrays.asList(new Object[]{Prettify.PR_PLAIN, Pattern.compile("^\\w+")}));
50 |
51 | setShortcutStylePatterns(_shortcutStylePatterns);
52 | setFallthroughStylePatterns(_fallthroughStylePatterns);
53 | }
54 |
55 | public static List getFileExtensions() {
56 | return Arrays.asList(new String[]{"yaml", "yml"});
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/lang/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * All languages that comes with release.
3 | */
4 | package prettify.lang;
--------------------------------------------------------------------------------
/codeview/src/main/java/io/github/kbiakov/codeview/highlight/prettify/parser/Job.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2006 Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package io.github.kbiakov.codeview.highlight.prettify.parser;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * This is the job object that similar to those in JavaScript Prettify.
21 | *
22 | * @author Chan Wai Shing
23 | */
24 | public class Job {
25 |
26 | /**
27 | * The starting point of the source code.
28 | */
29 | protected int basePos;
30 | /**
31 | * The source code.
32 | */
33 | protected String sourceCode;
34 | /**
35 | * The parsed results. nth items are starting position position,
36 | * n+1th items are the three-letter style keyword, where n start
37 | * from 0.
38 | */
39 | protected List