From 4cd678242fbe5f90c15296c89a31a350e9f5fd85 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 17 Jan 2022 17:29:50 -0500 Subject: [PATCH] initial commit --- .gitignore | 15 ++ LICENSE | 202 ++++++++++++++++++ README.md | 23 ++ pom.xml | 135 ++++++++++++ .../languages/Prism4jGrammarLocator.java | 59 +++++ .../prism4j/languages/Prism_6502asm.java | 58 +++++ .../blarg/prism4j/languages/Prism_basic.java | 56 +++++ .../ca/blarg/prism4j/languages/Prism_c.java | 54 +++++ .../blarg/prism4j/languages/Prism_clike.java | 54 +++++ .../ca/blarg/prism4j/languages/Prism_cpp.java | 41 ++++ .../blarg/prism4j/languages/Prism_csharp.java | 95 ++++++++ .../blarg/prism4j/languages/Prism_java.java | 53 +++++ .../prism4j/languages/Prism_javascript.java | 106 +++++++++ .../blarg/prism4j/languages/Prism_json.java | 28 +++ .../prism4j/languages/Prism_makefile.java | 46 ++++ .../blarg/prism4j/languages/Prism_pascal.java | 77 +++++++ .../blarg/prism4j/languages/Prism_qbasic.java | 55 +++++ .../ca/blarg/prism4j/languages/Prism_sql.java | 43 ++++ .../prism4j/languages/Prism_visualbasic.java | 79 +++++++ .../blarg/prism4j/languages/Prism_x86asm.java | 83 +++++++ .../blarg/prism4j/languages/Prism_yaml.java | 65 ++++++ 21 files changed, 1427 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism4jGrammarLocator.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_basic.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_c.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_clike.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_java.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_json.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_sql.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_visualbasic.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java create mode 100644 src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abad983 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.DS_Store +out/ +log/ +target/ +build/ +.settings/ +.project +.classpath +.idea +*.iml +*.eml +*.ipr +*.iws +*.class +*.jar diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e06d208 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..20986cf --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Prism4j Pre-packaged Language Grammars + +This is a library that I threw together quickly to make it easier to quickly get a bunch of [Prism4j](https://github.com/noties/Prism4j) +languages up and running in my own personal projects which use Prism4j. This is to replace the somewhat weird "bundler" +thing that Prism4j has. + +Plus, I've manually ported over some language definitions from [prism-js](https://prismjs.com/) to meet my own needs. + +## Maven + +```xml + + ca.blarg + prism4j-languages + 1.0.0 + +``` + +## Usage + +Either use the `GrammarLocator` provided by this library (`ca.blarg.prism4j.languages.Prism4jGrammarLocator`) during +construction of your `Prism4j` object, or create a new one and add all the languages you want from this library found +under the `ca.blarg.prism4j.languages` package. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..2feabcf --- /dev/null +++ b/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + ca.blarg + prism4j-languages + 1.0.0-SNAPSHOT + + Prism4j Pre-packaged Languages + An assortment of pre-packaged language grammars for use with Prism4j. + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + git@github.com:gered/prism4j-languages.git + scm:git:${project.scm.url} + scm:git:${project.scm.url} + HEAD + + + + + Gered King + gered@blarg.ca + + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + UTF-8 + UTF-8 + 8 + 8 + + + + + io.noties + prism4j + 2.0.0 + provided + + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + false + release + true + v@{project.version} + deploy + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.3.1 + + + attach-javadocs + + jar + + + + + + -Xdoclint:none + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism4jGrammarLocator.java b/src/main/java/ca/blarg/prism4j/languages/Prism4jGrammarLocator.java new file mode 100644 index 0000000..e8543f5 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism4jGrammarLocator.java @@ -0,0 +1,59 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarLocator; +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashSet; +import java.util.Set; + +public class Prism4jGrammarLocator implements GrammarLocator { + + @Nullable + @Override + public Prism4j.Grammar grammar(@NotNull Prism4j prism4j, @NotNull String language) { + switch (language) { + case "6502asm": return Prism_6502asm.create(prism4j); + case "basic": return Prism_basic.create(prism4j); + case "c": return Prism_c.create(prism4j); + case "clike": return Prism_clike.create(prism4j); + case "cpp": return Prism_cpp.create(prism4j); + case "csharp": return Prism_csharp.create(prism4j); + case "java": return Prism_java.create(prism4j); + case "javscript": return Prism_javascript.create(prism4j); + case "json": return Prism_json.create(prism4j); + case "makefile": return Prism_makefile.create(prism4j); + case "pascal": return Prism_pascal.create(prism4j); + case "qbasic": return Prism_qbasic.create(prism4j); + case "sql": return Prism_sql.create(prism4j); + case "visualbasic": return Prism_visualbasic.create(prism4j); + case "x86asm": return Prism_x86asm.create(prism4j); + case "yaml": return Prism_yaml.create(prism4j); + default: return null; + } + } + + @NotNull + @Override + public Set languages() { + Set languages = new HashSet<>(); + languages.add("6502asm"); + languages.add("basic"); + languages.add("c"); + languages.add("clike"); + languages.add("cpp"); + languages.add("csharp"); + languages.add("java"); + languages.add("javascript"); + languages.add("json"); + languages.add("makefile"); + languages.add("pascal"); + languages.add("qbasic"); + languages.add("sql"); + languages.add("visualbasic"); + languages.add("x86asm"); + languages.add("yaml"); + return languages; + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java b/src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java new file mode 100644 index 0000000..a750875 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java @@ -0,0 +1,58 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +public class Prism_6502asm { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("6502asm", + token( + "comment", + pattern(compile(";.*", Pattern.CASE_INSENSITIVE)) + ), + token( + "directive", + pattern(compile("\\.\\w+(?= )"), false, false, "keyword") + ), + token( + "string", + pattern(compile("([\"'`])(?:\\\\.|(?!\\1)[^\\\\\\r\\n])*\\1")) + ), + token( + "opcode", + pattern( + compile("\\b(?:adc|and|asl|bcc|bcs|beq|bit|bmi|bne|bpl|brk|bvc|bvs|clc|cld|cli|clv|cmp|cpx|cpy|dec|dex|dey|eor|inc|inx|iny|jmp|jsr|lda|ldx|ldy|lsr|nop|ora|pha|php|pla|plp|rol|ror|rti|rts|sbc|sec|sed|sei|sta|stx|sty|tax|tay|tsx|txa|txs|tya)\\b", Pattern.CASE_INSENSITIVE), + false, + false, + "property" + ) + ), + token( + "hexnumber", + pattern(compile("#?\\$[\\da-f]{2,4}\\b", Pattern.CASE_INSENSITIVE), false, false, "string") + ), + token( + "binarynumber", + pattern(compile("#?%[01]+\\b"), false, false, "string") + ), + token( + "decimalnumber", + pattern(compile("#?\\b\\d+\\b"), false, false, "string") + ), + token( + "register", + pattern(compile("\\b[xya]\\b", Pattern.CASE_INSENSITIVE), false, false, "variable") + ) + ); + } + + private Prism_6502asm() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_basic.java b/src/main/java/ca/blarg/prism4j/languages/Prism_basic.java new file mode 100644 index 0000000..f3a2859 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_basic.java @@ -0,0 +1,56 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +@SuppressWarnings("unused") +public class Prism_basic { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar( + "basic", + token( + "comment", + pattern( + compile("(?:!|REM\\b).+", Pattern.CASE_INSENSITIVE), + false, + false, + null, + grammar("inside", token("keyword", pattern(compile("^REM", Pattern.CASE_INSENSITIVE))))) + ), + token( + "string", + pattern(compile("\"(?:\"\"|[!#$%&'()*,\\/:;<=>?^_ +\\-.A-Z\\d])*\"", Pattern.CASE_INSENSITIVE)) + ), + token( + "number", + pattern(compile("(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:E[+-]?\\d+)?", Pattern.CASE_INSENSITIVE)) + ), + token( + "keyword", + pattern(compile("\\b(?:AS|BEEP|BLOAD|BSAVE|CALL(?: ABSOLUTE)?|CASE|CHAIN|CHDIR|CLEAR|CLOSE|CLS|COM|COMMON|CONST|DATA|DECLARE|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DIM|DO|DOUBLE|ELSE|ELSEIF|END|ENVIRON|ERASE|ERROR|EXIT|FIELD|FILES|FOR|FUNCTION|GET|GOSUB|GOTO|IF|INPUT|INTEGER|IOCTL|KEY|KILL|LINE INPUT|LOCATE|LOCK|LONG|LOOP|LSET|MKDIR|NAME|NEXT|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPEN|OPTION BASE|OUT|POKE|PUT|READ|REDIM|REM|RESTORE|RESUME|RETURN|RMDIR|RSET|RUN|SHARED|SINGLE|SELECT CASE|SHELL|SLEEP|STATIC|STEP|STOP|STRING|SUB|SWAP|SYSTEM|THEN|TIMER|TO|TROFF|TRON|TYPE|UNLOCK|UNTIL|USING|VIEW PRINT|WAIT|WEND|WHILE|WRITE)(?:\\$|\\b)", Pattern.CASE_INSENSITIVE)) + ), + token( + "function", + pattern(compile("\\b(?:ABS|ACCESS|ACOS|ANGLE|AREA|ARITHMETIC|ARRAY|ASIN|ASK|AT|ATN|BASE|BEGIN|BREAK|CAUSE|CEIL|CHR|CLIP|COLLATE|COLOR|CON|COS|COSH|COT|CSC|DATE|DATUM|DEBUG|DECIMAL|DEF|DEG|DEGREES|DELETE|DET|DEVICE|DISPLAY|DOT|ELAPSED|EPS|ERASABLE|EXLINE|EXP|EXTERNAL|EXTYPE|FILETYPE|FIXED|FP|GO|GRAPH|HANDLER|IDN|IMAGE|IN|INT|INTERNAL|IP|IS|KEYED|LBOUND|LCASE|LEFT|LEN|LENGTH|LET|LINE|LINES|LOG|LOG10|LOG2|LTRIM|MARGIN|MAT|MAX|MAXNUM|MID|MIN|MISSING|MOD|NATIVE|NUL|NUMERIC|OF|OPTION|ORD|ORGANIZATION|OUTIN|OUTPUT|PI|POINT|POINTER|POINTS|POS|PRINT|PROGRAM|PROMPT|RAD|RADIANS|RANDOMIZE|RECORD|RECSIZE|RECTYPE|RELATIVE|REMAINDER|REPEAT|REST|RETRY|REWRITE|RIGHT|RND|ROUND|RTRIM|SAME|SEC|SELECT|SEQUENTIAL|SET|SETTER|SGN|SIN|SINH|SIZE|SKIP|SQR|STANDARD|STATUS|STR|STREAM|STYLE|TAB|TAN|TANH|TEMPLATE|TEXT|THERE|TIME|TIMEOUT|TRACE|TRANSFORM|TRUNCATE|UBOUND|UCASE|USE|VAL|VARIABLE|VIEWPORT|WHEN|WINDOW|WITH|ZER|ZONEWIDTH)(?:\\$|\\b)", Pattern.CASE_INSENSITIVE)) + ), + token( + "operator", + pattern(compile("<[=>]?|>=?|[+\\-*\\/^=&]|\\b(?:AND|EQV|IMP|NOT|OR|XOR)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "punctuation", + pattern(compile("[,;:()]", Pattern.CASE_INSENSITIVE)) + ) + ); + } + + private Prism_basic() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_c.java b/src/main/java/ca/blarg/prism4j/languages/Prism_c.java new file mode 100644 index 0000000..34474aa --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_c.java @@ -0,0 +1,54 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarUtils; +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Extend; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.*; + +@Extend("clike") +public class Prism_c { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + + final Grammar c = GrammarUtils.extend( + GrammarUtils.require(prism4j, "clike"), + "c", + new GrammarUtils.TokenFilter() { + @Override + public boolean test(@NotNull Token token) { + final String name = token.name(); + return !"class-name".equals(name) && !"boolean".equals(name); + } + }, + token("keyword", pattern(compile("\\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\\b"))), + token("operator", pattern(compile("-[>-]?|\\+\\+?|!=?|<>?=?|==?|&&?|\\|\\|?|[~^%?*\\/]"))), + token("number", pattern(compile("(?:\\b0x[\\da-f]+|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:e[+-]?\\d+)?)[ful]*", CASE_INSENSITIVE))) + ); + + GrammarUtils.insertBeforeToken(c, "string", + token("macro", pattern( + compile("(^\\s*)#\\s*[a-z]+(?:[^\\r\\n\\\\]|\\\\(?:\\r\\n|[\\s\\S]))*", CASE_INSENSITIVE | MULTILINE), + true, + false, + "property", + grammar("inside", + token("string", pattern(compile("(#\\s*include\\s*)(?:<.+?>|(\"|')(?:\\\\?.)+?\\2)"), true)), + token("directive", pattern( + compile("(#\\s*)\\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\\b"), + true, + false, + "keyword" + )) + ) + )), + token("constant", pattern(compile("\\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\\b"))) + ); + + return c; + } +} + diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_clike.java b/src/main/java/ca/blarg/prism4j/languages/Prism_clike.java new file mode 100644 index 0000000..44ea239 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_clike.java @@ -0,0 +1,54 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +@SuppressWarnings("unused") +public abstract class Prism_clike { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar( + "clike", + token( + "comment", + pattern(compile("(^|[^\\\\])\\/\\*[\\s\\S]*?(?:\\*\\/|$)"), true), + pattern(compile("(^|[^\\\\:])\\/\\/.*"), true, true) + ), + token( + "string", + pattern(compile("([\"'])(?:\\\\(?:\\r\\n|[\\s\\S])|(?!\\1)[^\\\\\\r\\n])*\\1"), false, true) + ), + token( + "class-name", + pattern( + compile("((?:\\b(?:class|interface|extends|implements|trait|instanceof|new)\\s+)|(?:catch\\s+\\())[\\w.\\\\]+"), + true, + false, + null, + grammar("inside", token("punctuation", pattern(compile("[.\\\\]")))) + ) + ), + token( + "keyword", + pattern(compile("\\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\\b")) + ), + token("boolean", pattern(compile("\\b(?:true|false)\\b"))), + token("function", pattern(compile("[a-z0-9_]+(?=\\()", Pattern.CASE_INSENSITIVE))), + token( + "number", + pattern(compile("\\b0x[\\da-f]+\\b|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:e[+-]?\\d+)?", Pattern.CASE_INSENSITIVE)) + ), + token("operator", pattern(compile("--?|\\+\\+?|!=?=?|<=?|>=?|==?=?|&&?|\\|\\|?|\\?|\\*|\\/|~|\\^|%"))), + token("punctuation", pattern(compile("[{}\\[\\];(),.:]"))) + ); + } + + private Prism_clike() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java b/src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java new file mode 100644 index 0000000..ac0d7a7 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java @@ -0,0 +1,41 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarUtils; +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Extend; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.pattern; +import static io.noties.prism4j.Prism4j.token; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.compile; + +@Extend("c") +public class Prism_cpp { + + @NotNull + public static Prism4j.Grammar create(@NotNull Prism4j prism4j) { + + final Prism4j.Grammar cpp = GrammarUtils.extend( + GrammarUtils.require(prism4j, "c"), + "cpp", + token("keyword", pattern(compile("\\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\\b"))), + token("operator", pattern(compile("--?|\\+\\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\\^|~|%|&{1,2}|\\|\\|?|\\?|\\*|\\/|\\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\\b"))) + ); + + // in prism-js cpp is extending c, but c has not booleans... (like classes) + GrammarUtils.insertBeforeToken(cpp, "function", + token("boolean", pattern(compile("\\b(?:true|false)\\b"))) + ); + + GrammarUtils.insertBeforeToken(cpp, "keyword", + token("class-name", pattern(compile("(class\\s+)\\w+", CASE_INSENSITIVE), true)) + ); + + GrammarUtils.insertBeforeToken(cpp, "string", + token("raw-string", pattern(compile("R\"([^()\\\\ ]{0,16})\\([\\s\\S]*?\\)\\1\""), false, true, "string")) + ); + + return cpp; + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java b/src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java new file mode 100644 index 0000000..2268cf8 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java @@ -0,0 +1,95 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarUtils; +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Aliases; +import io.noties.prism4j.annotations.Extend; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.*; + +@Aliases("dotnet") +@Extend("clike") +public class Prism_csharp { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + + final Grammar classNameInsidePunctuation = grammar("inside", + token("punctuation", pattern(compile("\\."))) + ); + + final Grammar csharp = GrammarUtils.extend( + GrammarUtils.require(prism4j, "clike"), + "csharp", + token("keyword", pattern(compile("\\b(?:abstract|add|alias|as|ascending|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|do|double|dynamic|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|from|get|global|goto|group|if|implicit|in|int|interface|internal|into|is|join|let|lock|long|namespace|new|null|object|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|remove|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|value|var|virtual|void|volatile|where|while|yield)\\b"))), + token("string", + pattern(compile("@(\"|')(?:\\1\\1|\\\\[\\s\\S]|(?!\\1)[^\\\\])*\\1"), false, true), + pattern(compile("(\"|')(?:\\\\.|(?!\\1)[^\\\\\\r\\n])*?\\1"), false, true) + ), + token("class-name", + pattern( + compile("\\b[A-Z]\\w*(?:\\.\\w+)*\\b(?=\\s+\\w+)"), + false, + false, + null, + classNameInsidePunctuation + ), + pattern( + compile("(\\[)[A-Z]\\w*(?:\\.\\w+)*\\b"), + true, + false, + null, + classNameInsidePunctuation + ), + pattern( + compile("(\\b(?:class|interface)\\s+[A-Z]\\w*(?:\\.\\w+)*\\s*:\\s*)[A-Z]\\w*(?:\\.\\w+)*\\b"), + true, + false, + null, + classNameInsidePunctuation + ), + pattern( + compile("((?:\\b(?:class|interface|new)\\s+)|(?:catch\\s+\\())[A-Z]\\w*(?:\\.\\w+)*\\b"), + true, + false, + null, + classNameInsidePunctuation + ) + ), + token("number", pattern(compile("\\b0x[\\da-f]+\\b|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)f?", CASE_INSENSITIVE))) + ); + + GrammarUtils.insertBeforeToken(csharp, "class-name", + token("generic-method", pattern( + compile("\\w+\\s*<[^>\\r\\n]+?>\\s*(?=\\()"), + false, + false, + null, + grammar("inside", + token("function", pattern(compile("^\\w+"))), + token("class-name", pattern(compile("\\b[A-Z]\\w*(?:\\.\\w+)*\\b"), false, false, null, classNameInsidePunctuation)), + GrammarUtils.findToken(csharp, "keyword"), + token("punctuation", pattern(compile("[<>(),.:]"))) + ) + )), + token("preprocessor", pattern( + compile("(^\\s*)#.*", MULTILINE), + true, + false, + "property", + grammar("inside", + token("directive", pattern( + compile("(\\s*#)\\b(?:define|elif|else|endif|endregion|error|if|line|pragma|region|undef|warning)\\b"), + true, + false, + "keyword" + )) + ) + )) + ); + + return csharp; + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_java.java b/src/main/java/ca/blarg/prism4j/languages/Prism_java.java new file mode 100644 index 0000000..316006d --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_java.java @@ -0,0 +1,53 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarUtils; +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Extend; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.*; + +@Extend("clike") +public class Prism_java { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + + final Token keyword = token("keyword", pattern(compile("\\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\\b"))); + + final Grammar java = GrammarUtils.extend(GrammarUtils.require(prism4j, "clike"), "java", + keyword, + token("number", pattern(compile("\\b0b[01]+\\b|\\b0x[\\da-f]*\\.?[\\da-fp-]+\\b|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:e[+-]?\\d+)?[df]?", CASE_INSENSITIVE))), + token("operator", pattern( + compile("(^|[^.])(?:\\+[+=]?|-[-=]?|!=?|<>?>?=?|==?|&[&=]?|\\|[|=]?|\\*=?|\\/=?|%=?|\\^=?|[?:~])", MULTILINE), + true + )) + ); + + GrammarUtils.insertBeforeToken(java, "function", + token("annotation", pattern( + compile("(^|[^.])@\\w+"), + true, + false, + "punctuation" + )) + ); + + GrammarUtils.insertBeforeToken(java, "class-name", + token("generics", pattern( + compile("<\\s*\\w+(?:\\.\\w+)?(?:\\s*,\\s*\\w+(?:\\.\\w+)?)*>", CASE_INSENSITIVE), + false, + false, + "function", + grammar( + "inside", + keyword, + token("punctuation", pattern(compile("[<>(),.:]"))) + ) + )) + ); + + return java; + } +} \ No newline at end of file diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java b/src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java new file mode 100644 index 0000000..8f278cd --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java @@ -0,0 +1,106 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.GrammarUtils; +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Aliases; +import io.noties.prism4j.annotations.Extend; +import io.noties.prism4j.annotations.Modify; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.compile; + +@Aliases("js") +@Modify("markup") +@Extend("clike") +public class Prism_javascript { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + + final Grammar js = GrammarUtils.extend(GrammarUtils.require(prism4j, "clike"), "javascript", + token("keyword", pattern(compile("\\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b"))), + token("number", pattern(compile("\\b(?:0[xX][\\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\\b|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:[Ee][+-]?\\d+)?"))), + token("function", pattern(compile("[_$a-z\\xA0-\\uFFFF][$\\w\\xA0-\\uFFFF]*(?=\\s*\\()", CASE_INSENSITIVE))), + token("operator", pattern(compile("-[-=]?|\\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\\|[|=]?|\\*\\*?=?|\\/=?|~|\\^=?|%=?|\\?|\\.{3}"))) + ); + + GrammarUtils.insertBeforeToken(js, "keyword", + token("regex", pattern( + compile("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s])\\s*)\\/(\\[[^\\]\\r\\n]+]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[gimyu]{0,5}(?=\\s*($|[\\r\\n,.;})\\]]))"), + true, + true + )), + token( + "function-variable", + pattern( + compile("[_$a-z\\xA0-\\uFFFF][$\\w\\xA0-\\uFFFF]*(?=\\s*=\\s*(?:function\\b|(?:\\([^()]*\\)|[_$a-z\\xA0-\\uFFFF][$\\w\\xA0-\\uFFFF]*)\\s*=>))", CASE_INSENSITIVE), + false, + false, + "function" + ) + ), + token("constant", pattern(compile("\\b[A-Z][A-Z\\d_]*\\b"))) + ); + + final Token interpolation = token("interpolation"); + + GrammarUtils.insertBeforeToken(js, "string", + token( + "template-string", + pattern( + compile("`(?:\\\\[\\s\\S]|\\$\\{[^}]+\\}|[^\\\\`])*`"), + false, + true, + null, + grammar( + "inside", + interpolation, + token("string", pattern(compile("[\\s\\S]+"))) + ) + ) + ) + ); + + final Grammar insideInterpolation; + { + final List tokens = new ArrayList<>(js.tokens().size() + 1); + tokens.add(token( + "interpolation-punctuation", + pattern(compile("^\\$\\{|\\}$"), false, false, "punctuation") + )); + tokens.addAll(js.tokens()); + insideInterpolation = grammar("inside", tokens); + } + + interpolation.patterns().add(pattern( + compile("\\$\\{[^}]+\\}"), + false, + false, + null, + insideInterpolation + )); + + final Grammar markup = prism4j.grammar("markup"); + if (markup != null) { + GrammarUtils.insertBeforeToken(markup, "tag", + token( + "script", pattern( + compile("()[\\s\\S]*?(?=<\\/script>)", CASE_INSENSITIVE), + true, + true, + "language-javascript", + js + ) + ) + ); + } + + return js; + } +} + diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_json.java b/src/main/java/ca/blarg/prism4j/languages/Prism_json.java new file mode 100644 index 0000000..fbf794d --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_json.java @@ -0,0 +1,28 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import io.noties.prism4j.annotations.Aliases; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.compile; + +@Aliases("jsonp") +public class Prism_json { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar( + "json", + token("property", pattern(compile("\"(?:\\\\.|[^\\\\\"\\r\\n])*\"(?=\\s*:)", CASE_INSENSITIVE))), + token("string", pattern(compile("\"(?:\\\\.|[^\\\\\"\\r\\n])*\"(?!\\s*:)"), false, true)), + token("number", pattern(compile("\\b0x[\\dA-Fa-f]+\\b|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:[Ee][+-]?\\d+)?"))), + token("punctuation", pattern(compile("[{}\\[\\]);,]"))), + // not sure about this one... + token("operator", pattern(compile(":"))), + token("boolean", pattern(compile("\\b(?:true|false)\\b", CASE_INSENSITIVE))), + token("null", pattern(compile("\\bnull\\b", CASE_INSENSITIVE))) + ); + } +} \ No newline at end of file diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java b/src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java new file mode 100644 index 0000000..7ccf315 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java @@ -0,0 +1,46 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.MULTILINE; +import static java.util.regex.Pattern.compile; + +public class Prism_makefile { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("makefile", + token("comment", pattern( + compile("(^|[^\\\\])#(?:\\\\(?:\\r\\n|[\\s\\S])|[^\\\\\\r\\n])*"), + true + )), + token("string", pattern( + compile("([\"'])(?:\\\\(?:\\r\\n|[\\s\\S])|(?!\\1)[^\\\\\\r\\n])*\\1"), + false, + true + )), + token("builtin", pattern(compile("\\.[A-Z][^:#=\\s]+(?=\\s*:(?!=))"))), + token("symbol", pattern( + compile("^[^:=\\r\\n]+(?=\\s*:(?!=))", MULTILINE), + false, + false, + null, + grammar("inside", + token("variable", pattern(compile("\\$+(?:[^(){}:#=\\s]+|(?=[({]))"))) + ) + )), + token("variable", pattern(compile("\\$+(?:[^(){}:#=\\s]+|\\([@*%<^+?][DF]\\)|(?=[({]))"))), + token("keyword", + pattern(compile("-include\\b|\\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\\b")), + pattern( + compile("(\\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \\t])"), + true + ) + ), + token("operator", pattern(compile("(?:::|[?:+!])?=|[|@]"))), + token("punctuation", pattern(compile("[:;(){}]"))) + ); + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java b/src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java new file mode 100644 index 0000000..7b3521e --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java @@ -0,0 +1,77 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +public class Prism_pascal { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("pascal", + token( + "comment", + pattern(compile("\\(\\*[\\s\\S]+?\\*\\)")), + pattern(compile("\\{[\\s\\S]+?\\}")), + pattern(compile("\\/\\/.*")) + ), + token( + "string", + pattern( + compile("(?:'(?:''|[^'\\r\\n])*'(?!')|#[&$%]?[a-f\\d]+)+|\\^[a-z]", Pattern.CASE_INSENSITIVE), + false, + true + ) + ), + token( + "keyword", + // turbo pascal + pattern( + compile("(^|[^&])\\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\\b", Pattern.CASE_INSENSITIVE), + true + ), + // free pascal + pattern( + compile("(^|[^&])\\b(?:dispose|exit|false|new|true)\\b", Pattern.CASE_INSENSITIVE), + true + ), + // object pascal + pattern( + compile("(^|[^&])\\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\\b", Pattern.CASE_INSENSITIVE), + true + ), + // modifiers + pattern( + compile("(^|[^&])\\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\\b", Pattern.CASE_INSENSITIVE), + true + ) + ), + token( + "number", + // hexadecimal, octal and binary + pattern(compile("(?:[&%]\\d+|\\$[a-f\\d]+)", Pattern.CASE_INSENSITIVE)), + // decimal + pattern(compile("\\b\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?", Pattern.CASE_INSENSITIVE)) + ), + token( + "operator", + pattern(compile("\\.\\.|\\*\\*|:=|<[<=>]?|>[>=]?|[+\\-*\\/]=?|[@^=]", Pattern.CASE_INSENSITIVE)), + pattern( + compile("(^|[^&])\\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\\b", Pattern.CASE_INSENSITIVE), + true + ) + ), + token( + "punctuation", + pattern(compile("\\(\\.|\\.\\)|[()\\[\\]:;,.]")) + ) + ); + } + + private Prism_pascal() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java b/src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java new file mode 100644 index 0000000..e5251e8 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java @@ -0,0 +1,55 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +public class Prism_qbasic { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar( + "qbasic", + token( + "comment", + pattern( + compile("(?:['‘’]|REM\\b)(?:[^\\r\\n_]|_(?:\\r\\n?|\\n)?)*", Pattern.CASE_INSENSITIVE), + false, + false, + null, + grammar("inside", token("keyword", pattern(compile("^REM", Pattern.CASE_INSENSITIVE))))) + ), + token( + "string", + pattern(compile("\"(?:\"\"|[!#$%&'()*,\\/:;<=>?^_ +\\-.A-Z\\d])*\"", Pattern.CASE_INSENSITIVE)) + ), + token( + "number", + pattern(compile("(?:(?:\\b\\d+(?:\\.\\d+)?|\\.\\d+)(?:E[+-]?\\d+)?|&[HO][\\dA-F]+)(?:U?[ILS]|[FRD])?", Pattern.CASE_INSENSITIVE)) + ), + token( + "boolean", + pattern(compile("\\b(?:True|False)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "keyword", + pattern(compile("\\b(?:ABS|AND|ASC|ATN|BEEP|BLOAD|BSAVE|CALL(?: ABSOLUTE| INT86OLD| INT86XOLD| INTERRUPT| INTERRUPTX)?|CDBL|CHAIN|CHDIR|CHR\\$|CINT|CIRCLE|CLEAR|CLNG|CLOSE|CLS|COLOR|COM(?: ON| OFF| STOP)?|COMMAND\\$|COMMON|CONST|COS|CSNG|CSRLIN|CVD|CVDMBF|CVI|CVL|CVS|CVSMBF|DATA|DATE\\$|DECLARE|DEF(?: FN| SEG)?|DIM|DO|DOUBLE|DRAW|END|ENVIRON|ENVIRON\\$|EOF|EQV|ERASE|ERDEV|ERDEV\\$|ERL|ERR|ERROR|EXIT|EXP|FIELD|FILEATTR|FILES|FIX|FOR|FRE|FREEFILE|FUNCTION|GET|GOSUB|GOTO|HEX\\$|IF|IMP|INKEY\\$|INP|INPUT|INPUT\\$|INSTR|INT|INTEGER|IOCTL|IOCTL\\$|KEY(?: ON| OFF| STOP)?|KILL|LBOUND|LCASE\\$|LEFT\\$|LEN|LET|LINE|LOC|LOCATE|LOCK|LOF|LOG|LONG|LOOP|LPOS|LPRINT(?: USING)?|LSET|LTRIM\\$|MID\\$|MKD\\$|MKDIR|MKDMBF\\$|MKI\\$|MKL\\$|MKS\\$|MKSMBF\\$|MOD|NAME|NEXT|NOT|OCT\\$|ON(?: COM GOSUB| ERROR GOTO| PEN GOSUB| PLAY GOSUB| STRIG GOSUB| TIMER GOSUB| UEVENT GOSUB)?|OPEN(?: COM)?|OPTION BASE|OR|OUT|PAINT|PALETTE(?: USING)?|PCOPY|PEEK|PEN(?: ON| OFF| STOP)?|PLAY(?: ON| OFF| STOP)?|PMAP|POINT|POKE|POS|PRESET|PSET|PRINT(?: USING)?|PUT|RANDOMIZE|READ|REDIM|REM|RESET|RESTORE|RESUME|RETURN|RIGHT\\$|RMDIR|RND|RSET|RTRIM\\$|RUN|SADD|SCREEN|SEEK|SELECT CASE|SETMEM|SGN|SHARED|SHELL|SIN|SINGLE|SLEEP|SOUND|SPACE\\$|SPC|SQR|STATIC|STICK|STOP|STR\\$|STRIG(?: ON| OFF| STOP)?|STRING|STRING\\$|SUB|SWAP|SYSTEM|TAB|TAN|TIME\\$|TIMER(?: ON| OFF| STOP)?|TROFF|TRON|TYPE|UBOUND|UCASE\\$|UEVENT(?: ON| OFF| STOP)?|UNLOCK|VAL|VARPTR|VARPTR\\$|VARSEG|VIEW(?: PRINT)|WAIT|WHILE|WEND|WIDTH|WINDOW|WRITE|XOR)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "operator", + pattern(compile("<[=>]?|>=?|[+\\-*\\/^=&]", Pattern.CASE_INSENSITIVE)) + ), + token( + "punctuation", + pattern(compile("[,;:()]", Pattern.CASE_INSENSITIVE)) + ) + ); + } + + private Prism_qbasic() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_sql.java b/src/main/java/ca/blarg/prism4j/languages/Prism_sql.java new file mode 100644 index 0000000..79121bf --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_sql.java @@ -0,0 +1,43 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.CASE_INSENSITIVE; +import static java.util.regex.Pattern.compile; + +public class Prism_sql { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("sql", + token("comment", pattern( + compile("(^|[^\\\\])(?:\\/\\*[\\s\\S]*?\\*\\/|(?:--|\\/\\/|#).*)"), + true + )), + token("string", pattern( + compile("(^|[^@\\\\])(\"|')(?:\\\\[\\s\\S]|(?!\\2)[^\\\\])*\\2"), + true, + true + )), + token("variable", pattern(compile("@[\\w.$]+|@([\"'`])(?:\\\\[\\s\\S]|(?!\\1)[^\\\\])+\\1"))), + token("function", pattern( + compile("\\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\\s*\\()", CASE_INSENSITIVE) + )), + token("keyword", pattern( + compile("\\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\\b", CASE_INSENSITIVE) + )), + token("boolean", pattern( + compile("\\b(?:TRUE|FALSE|NULL)\\b", CASE_INSENSITIVE) + )), + token("number", pattern( + compile("\\b0x[\\da-f]+\\b|\\b\\d+\\.?\\d*|\\B\\.\\d+\\b", CASE_INSENSITIVE) + )), + token("operator", pattern( + compile("[-+*\\/=%^~]|&&?|\\|\\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\\b", CASE_INSENSITIVE) + )), + token("punctuation", pattern(compile("[;\\[\\]()`,.]"))) + ); + } +} \ No newline at end of file diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_visualbasic.java b/src/main/java/ca/blarg/prism4j/languages/Prism_visualbasic.java new file mode 100644 index 0000000..c71b6ba --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_visualbasic.java @@ -0,0 +1,79 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +public class Prism_visualbasic { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("visualbasic", + token( + "comment", + pattern( + compile("(?:['‘’]|REM\\b)(?:[^\\r\\n_]|_(?:\\r\\n?|\\n)?)*", Pattern.CASE_INSENSITIVE), + false, + false, + null, + grammar("inside", token("keyword", pattern(compile("^REM", Pattern.CASE_INSENSITIVE))))) + ), + token( + "macro", + pattern( + compile("#(?:Const|Else|ElseIf|End|ExternalChecksum|ExternalSource|If|Region)(?:[^\\S\\r\\n]_[^\\S\\r\\n]*(?:\\r\\n?|\\n)|.)+", Pattern.CASE_INSENSITIVE), + false, + true + ) + ), + token( + "string", + pattern( + compile("\\$?[\"“”](?:[\"“”]{2}|[^\"“”])*[\"“”]C?"), + false, + true + ) + ), + token( + "date", + pattern( + compile("#[^\\S\\r\\n]*(?:\\d+([/-])\\d+\\1\\d+(?:[^\\S\\r\\n]+(?:\\d+[^\\S\\r\\n]*(?:AM|PM)|\\d+:\\d+(?::\\d+)?(?:[^\\S\\r\\n]*(?:AM|PM))?))?|\\d+[^\\S\\r\\n]*(?:AM|PM)|\\d+:\\d+(?::\\d+)?(?:[^\\S\\r\\n]*(?:AM|PM))?)[^\\S\\r\\n]*#", Pattern.CASE_INSENSITIVE), + false, + false, + "builtin" + ) + ), + token( + "number", + pattern(compile("(?:(?:\\b\\d+(?:\\.\\d+)?|\\.\\d+)(?:E[+-]?\\d+)?|&[HO][\\dA-F]+)(?:U?[ILS]|[FRD])?", Pattern.CASE_INSENSITIVE)) + ), + token( + "boolean", + pattern(compile("\\b(?:True|False|Nothing)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "keyword", + pattern(compile("\\b(?:AddHandler|AddressOf|Alias|And(?:Also)?|As|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|C(?:Bool|Byte|Char|Date|Dbl|Dec|Int|Lng|Obj|SByte|Short|Sng|Str|Type|UInt|ULng|UShort)|Char|Class|Const|Continue|Currency|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else(?:If)?|End(?:If)?|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get(?:Type|XMLNamespace)?|Global|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|IsNot|Let|Lib|Like|Long|Loop|Me|Mod|Module|Must(?:Inherit|Override)|My(?:Base|Class)|Namespace|Narrowing|New|Next|Not(?:Inheritable|Overridable)?|Object|Of|On|Operator|Option(?:al)?|Or(?:Else)?|Out|Overloads|Overridable|Overrides|ParamArray|Partial|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|SByte|Select|Set|Shadows|Shared|short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TryCast|Type|TypeOf|U(?:Integer|Long|Short)|Using|Variant|Wend|When|While|Widening|With(?:Events)?|WriteOnly|Until|Xor)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "operator", + pattern(compile("[+\\-*/\\\\^<=>&#@$%!]")), + pattern( + compile("([^\\S\\r\\n])_(?=[^\\S\\r\\n]*[\\r\\n])"), + true + ) + ), + token( + "punctuation", + pattern(compile("[{}().,:?]")) + ) + ); + } + + private Prism_visualbasic() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java b/src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java new file mode 100644 index 0000000..1e33aa0 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java @@ -0,0 +1,83 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import java.util.regex.Pattern; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.compile; + +public class Prism_x86asm { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("x86asm", + token( + "comment", + pattern(compile(";.*$", Pattern.MULTILINE)) + ), + token( + "string", + pattern(compile("([\"'`])(?:\\\\.|(?!\\1)[^\\\\\\r\\n])*\\1")) + ), + token( + "label", + pattern( + compile("(^\\s*)[A-Za-z._?$][\\w.?$@~#]*:", Pattern.MULTILINE), + true, + false, + "function" + ) + ), + token( + "opcode", + pattern( + compile("\\b(?:lock|rep|repe|repz|repne|repnz|xaquire|xrelease|bnd|nobnd|aaa|aad|aam|aas|adc|add|and|arpl|bb0_reset|bb1_reset|bound|bsf|bsr|bswap|bt|btc|btr|bts|call|cbw|cdq|cdqe|clc|cld|cli|clts|cmc|cmp|cmpsb|cmpsd|cmpsq|cmpsw|cmpxchg|cmpxchg486|cmpxchg8b|cmpxchg16b|cpuid|cpu_read|cpu_write|cqo|cwd|cwde|daa|das|dec|div|dmint|emms|enter|equ|f2xm1|fabs|fadd|faddp|fbld|fbstp|fchs|fclex|fcmovb|fcmovbe|fcmove|fcmovnb|fcmovnbe|fcmovne|fcmovnu|fcmovu|fcom|fcomi|fcomip|fcomp|fcompp|fcos|fdecstp|fdisi|fdiv|fdivp|fdivr|fdivrp|femms|feni|ffree|ffreep|fiadd|ficom|ficomp|fidiv|fidivr|fild|fimul|fincstp|finit|fist|fistp|fisttp|fisub|fisubr|fld|fld1|fldcw|fldenv|fldl2e|fldl2t|fldlg2|fldln2|fldpi|fldz|fmul|fmulp|fnclex|fndisi|fneni|fninit|fnop|fnsave|fnstcw|fnstenv|fnstsw|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fscale|fsetpm|fsin|fsincos|fsqrt|fst|fstcw|fstenv|fstp|fstsw|fsub|fsubp|fsubr|fsubrp|ftst|fucom|fucomi|fucomip|fucomp|fucompp|fxam|fxch|fxtract|fyl2x|fyl2xp1|hlt|ibts|icebp|idiv|imul|in|inc|incbin|insb|insd|insw|int|int01|int1|int03|int3|into|invd|invpcid|invlpg|invlpga|iret|iretd|iretq|iretw|jcxz|jecxz|jrcxz|jmp|jmpe|lahf|lar|lds|lea|leave|les|lfence|lfs|lgdt|lgs|lidt|lldt|lmsw|loadall|loadall286|lodsb|lodsd|lodsq|lodsw|loop|loope|loopne|loopnz|loopz|lsl|lss|ltr|mfence|monitor|mov|movd|movq|movsb|movsd|movsq|movsw|movsx|movsxd|movzx|mul|mwait|neg|nop|not|or|out|outsb|outsd|outsw|packssdw|packsswb|packuswb|paddb|paddd|paddsb|paddsiw|paddsw|paddusb|paddusw|paddw|pand|pandn|pause|paveb|pavgusb|pcmpeqb|pcmpeqd|pcmpeqw|pcmpgtb|pcmpgtd|pcmpgtw|pdistib|pf2id|pfacc|pfadd|pfcmpeq|pfcmpge|pfcmpgt|pfmax|pfmin|pfmul|pfrcp|pfrcpit1|pfrcpit2|pfrsqit1|pfrsqrt|pfsub|pfsubr|pi2fd|pmachriw|pmaddwd|pmagw|pmulhriw|pmulhrwa|pmulhrwc|pmulhw|pmullw|pmvgezb|pmvlzb|pmvnzb|pmvzb|pop|popa|popad|popaw|popf|popfd|popfq|popfw|por|prefetch|prefetchw|pslld|psllq|psllw|psrad|psraw|psrld|psrlq|psrlw|psubb|psubd|psubsb|psubsiw|psubsw|psubusb|psubusw|psubw|punpckhbw|punpckhdq|punpckhwd|punpcklbw|punpckldq|punpcklwd|push|pusha|pushad|pushaw|pushf|pushfd|pushfq|pushfw|pxor|rcl|rcr|rdshr|rdmsr|rdpmc|rdtsc|rdtscp|ret|retf|retn|rol|ror|rdm|rsdc|rsldt|rsm|rsts|sahf|sal|salc|sar|sbb|scasb|scasd|scasq|scasw|sfence|sgdt|shl|shld|shr|shrd|sidt|sldt|skinit|smi|smint|smintold|smsw|stc|std|sti|stosb|stosd|stosq|stosw|str|sub|svdc|svldt|svts|swapgs|syscall|sysenter|sysexit|sysret|test|ud0|ud1|ud2b|ud2|ud2a|umov|verr|verw|fwait|wbinvd|wrshr|wrmsr|xadd|xbts|xchg|xlatb|xlat|xor|cmove|cmovz|cmovne|cmovnz|cmova|cmovnbe|cmovae|cmovnb|cmovb|cmovnae|cmovbe|cmovna|cmovg|cmovnle|cmovge|cmovnl|cmovl|cmovnge|cmovle|cmovng|cmovc|cmovnc|cmovo|cmovno|cmovs|cmovns|cmovp|cmovpe|cmovnp|cmovpo|je|jz|jne|jnz|ja|jnbe|jae|jnb|jb|jnae|jbe|jna|jg|jnle|jge|jnl|jl|jnge|jle|jng|jc|jnc|jo|jno|js|jns|jpo|jnp|jpe|jp|sete|setz|setne|setnz|seta|setnbe|setae|setnb|setnc|setb|setnae|setcset|setbe|setna|setg|setnle|setge|setnl|setl|setnge|setle|setng|sets|setns|seto|setno|setpe|setp|setpo|setnp|addps|addss|andnps|andps|cmpeqps|cmpeqss|cmpleps|cmpless|cmpltps|cmpltss|cmpneqps|cmpneqss|cmpnleps|cmpnless|cmpnltps|cmpnltss|cmpordps|cmpordss|cmpunordps|cmpunordss|cmpps|cmpss|comiss|cvtpi2ps|cvtps2pi|cvtsi2ss|cvtss2si|cvttps2pi|cvttss2si|divps|divss|ldmxcsr|maxps|maxss|minps|minss|movaps|movhps|movlhps|movlps|movhlps|movmskps|movntps|movss|movups|mulps|mulss|orps|rcpps|rcpss|rsqrtps|rsqrtss|shufps|sqrtps|sqrtss|stmxcsr|subps|subss|ucomiss|unpckhps|unpcklps|xorps|fxrstor|fxrstor64|fxsave|fxsave64|xgetbv|xsetbv|xsave|xsave64|xsaveopt|xsaveopt64|xrstor|xrstor64|prefetchnta|prefetcht0|prefetcht1|prefetcht2|maskmovq|movntq|pavgb|pavgw|pextrw|pinsrw|pmaxsw|pmaxub|pminsw|pminub|pmovmskb|pmulhuw|psadbw|pshufw|pf2iw|pfnacc|pfpnacc|pi2fw|pswapd|maskmovdqu|clflush|movntdq|movnti|movntpd|movdqa|movdqu|movdq2q|movq2dq|paddq|pmuludq|pshufd|pshufhw|pshuflw|pslldq|psrldq|psubq|punpckhqdq|punpcklqdq|addpd|addsd|andnpd|andpd|cmpeqpd|cmpeqsd|cmplepd|cmplesd|cmpltpd|cmpltsd|cmpneqpd|cmpneqsd|cmpnlepd|cmpnlesd|cmpnltpd|cmpnltsd|cmpordpd|cmpordsd|cmpunordpd|cmpunordsd|cmppd|comisd|cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtps2dq|cvtps2pd|cvtsd2si|cvtsd2ss|cvtsi2sd|cvtss2sd|cvttpd2pi|cvttpd2dq|cvttps2dq|cvttsd2si|divpd|divsd|maxpd|maxsd|minpd|minsd|movapd|movhpd|movlpd|movmskpd|movupd|mulpd|mulsd|orpd|shufpd|sqrtpd|sqrtsd|subpd|subsd|ucomisd|unpckhpd|unpcklpd|xorpd|addsubpd|addsubps|haddpd|haddps|hsubpd|hsubps|lddqu|movddup|movshdup|movsldup|clgi|stgi|vmcall|vmclear|vmfunc|vmlaunch|vmload|vmmcall|vmptrld|vmptrst|vmread|vmresume|vmrun|vmsave|vmwrite|vmxoff|vmxon|invept|invvpid|pabsb|pabsw|pabsd|palignr|phaddw|phaddd|phaddsw|phsubw|phsubd|phsubsw|pmaddubsw|pmulhrsw|pshufb|psignb|psignw|psignd|extrq|insertq|movntsd|movntss|lzcnt|blendpd|blendps|blendvpd|blendvps|dppd|dpps|extractps|insertps|movntdqa|mpsadbw|packusdw|pblendvb|pblendw|pcmpeqq|pextrb|pextrd|pextrq|phminposuw|pinsrb|pinsrd|pinsrq|pmaxsb|pmaxsd|pmaxud|pmaxuw|pminsb|pminsd|pminud|pminuw|pmovsxbw|pmovsxbd|pmovsxbq|pmovsxwd|pmovsxwq|pmovsxdq|pmovzxbw|pmovzxbd|pmovzxbq|pmovzxwd|pmovzxwq|pmovzxdq|pmuldq|pmulld|ptest|roundpd|roundps|roundsd|roundss|crc32|pcmpestri|pcmpestrm|pcmpistri|pcmpistrm|pcmpgtq|popcnt|getsec|pfrcpv|pfrsqrtv|movbe|aesenc|aesenclast|aesdec|aesdeclast|aesimc|aeskeygenassist|vaesenc|vaesenclast|vaesdec|vaesdeclast|vaesimc|vaeskeygenassist|vaddpd|vaddps|vaddsd|vaddss|vaddsubpd|vaddsubps|vandpd|vandps|vandnpd|vandnps|vblendpd|vblendps|vblendvpd|vblendvps|vbroadcastss|vbroadcastsd|vbroadcastf128|vcmpeq_ospd|vcmpeqpd|vcmplt_ospd|vcmpltpd|vcmple_ospd|vcmplepd|vcmpunord_qpd|vcmpunordpd|vcmpneq_uqpd|vcmpneqpd|vcmpnlt_uspd|vcmpnltpd|vcmpnle_uspd|vcmpnlepd|vcmpord_qpd|vcmpordpd|vcmpeq_uqpd|vcmpnge_uspd|vcmpngepd|vcmpngt_uspd|vcmpngtpd|vcmpfalse_oqpd|vcmpfalsepd|vcmpneq_oqpd|vcmpge_ospd|vcmpgepd|vcmpgt_ospd|vcmpgtpd|vcmptrue_uqpd|vcmptruepd|vcmplt_oqpd|vcmple_oqpd|vcmpunord_spd|vcmpneq_uspd|vcmpnlt_uqpd|vcmpnle_uqpd|vcmpord_spd|vcmpeq_uspd|vcmpnge_uqpd|vcmpngt_uqpd|vcmpfalse_ospd|vcmpneq_ospd|vcmpge_oqpd|vcmpgt_oqpd|vcmptrue_uspd|vcmppd|vcmpeq_osps|vcmpeqps|vcmplt_osps|vcmpltps|vcmple_osps|vcmpleps|vcmpunord_qps|vcmpunordps|vcmpneq_uqps|vcmpneqps|vcmpnlt_usps|vcmpnltps|vcmpnle_usps|vcmpnleps|vcmpord_qps|vcmpordps|vcmpeq_uqps|vcmpnge_usps|vcmpngeps|vcmpngt_usps|vcmpngtps|vcmpfalse_oqps|vcmpfalseps|vcmpneq_oqps|vcmpge_osps|vcmpgeps|vcmpgt_osps|vcmpgtps|vcmptrue_uqps|vcmptrueps|vcmplt_oqps|vcmple_oqps|vcmpunord_sps|vcmpneq_usps|vcmpnlt_uqps|vcmpnle_uqps|vcmpord_sps|vcmpeq_usps|vcmpnge_uqps|vcmpngt_uqps|vcmpfalse_osps|vcmpneq_osps|vcmpge_oqps|vcmpgt_oqps|vcmptrue_usps|vcmpps|vcmpeq_ossd|vcmpeqsd|vcmplt_ossd|vcmpltsd|vcmple_ossd|vcmplesd|vcmpunord_qsd|vcmpunordsd|vcmpneq_uqsd|vcmpneqsd|vcmpnlt_ussd|vcmpnltsd|vcmpnle_ussd|vcmpnlesd|vcmpord_qsd|vcmpordsd|vcmpeq_uqsd|vcmpnge_ussd|vcmpngesd|vcmpngt_ussd|vcmpngtsd|vcmpfalse_oqsd|vcmpfalsesd|vcmpneq_oqsd|vcmpge_ossd|vcmpgesd|vcmpgt_ossd|vcmpgtsd|vcmptrue_uqsd|vcmptruesd|vcmplt_oqsd|vcmple_oqsd|vcmpunord_ssd|vcmpneq_ussd|vcmpnlt_uqsd|vcmpnle_uqsd|vcmpord_ssd|vcmpeq_ussd|vcmpnge_uqsd|vcmpngt_uqsd|vcmpfalse_ossd|vcmpneq_ossd|vcmpge_oqsd|vcmpgt_oqsd|vcmptrue_ussd|vcmpsd|vcmpeq_osss|vcmpeqss|vcmplt_osss|vcmpltss|vcmple_osss|vcmpless|vcmpunord_qss|vcmpunordss|vcmpneq_uqss|vcmpneqss|vcmpnlt_usss|vcmpnltss|vcmpnle_usss|vcmpnless|vcmpord_qss|vcmpordss|vcmpeq_uqss|vcmpnge_usss|vcmpngess|vcmpngt_usss|vcmpngtss|vcmpfalse_oqss|vcmpfalsess|vcmpneq_oqss|vcmpge_osss|vcmpgess|vcmpgt_osss|vcmpgtss|vcmptrue_uqss|vcmptruess|vcmplt_oqss|vcmple_oqss|vcmpunord_sss|vcmpneq_usss|vcmpnlt_uqss|vcmpnle_uqss|vcmpord_sss|vcmpeq_usss|vcmpnge_uqss|vcmpngt_uqss|vcmpfalse_osss|vcmpneq_osss|vcmpge_oqss|vcmpgt_oqss|vcmptrue_usss|vcmpss|vcomisd|vcomiss|vcvtdq2pd|vcvtdq2ps|vcvtpd2dq|vcvtpd2ps|vcvtps2dq|vcvtps2pd|vcvtsd2si|vcvtsd2ss|vcvtsi2sd|vcvtsi2ss|vcvtss2sd|vcvtss2si|vcvttpd2dq|vcvttps2dq|vcvttsd2si|vcvttss2si|vdivpd|vdivps|vdivsd|vdivss|vdppd|vdpps|vextractf128|vextractps|vhaddpd|vhaddps|vhsubpd|vhsubps|vinsertf128|vinsertps|vlddqu|vldqqu|vldmxcsr|vmaskmovdqu|vmaskmovps|vmaskmovpd|vmaxpd|vmaxps|vmaxsd|vmaxss|vminpd|vminps|vminsd|vminss|vmovapd|vmovaps|vmovd|vmovq|vmovddup|vmovdqa|vmovqqa|vmovdqu|vmovqqu|vmovhlps|vmovhpd|vmovhps|vmovlhps|vmovlpd|vmovlps|vmovmskpd|vmovmskps|vmovntdq|vmovntqq|vmovntdqa|vmovntpd|vmovntps|vmovsd|vmovshdup|vmovsldup|vmovss|vmovupd|vmovups|vmpsadbw|vmulpd|vmulps|vmulsd|vmulss|vorpd|vorps|vpabsb|vpabsw|vpabsd|vpacksswb|vpackssdw|vpackuswb|vpackusdw|vpaddb|vpaddw|vpaddd|vpaddq|vpaddsb|vpaddsw|vpaddusb|vpaddusw|vpalignr|vpand|vpandn|vpavgb|vpavgw|vpblendvb|vpblendw|vpcmpestri|vpcmpestrm|vpcmpistri|vpcmpistrm|vpcmpeqb|vpcmpeqw|vpcmpeqd|vpcmpeqq|vpcmpgtb|vpcmpgtw|vpcmpgtd|vpcmpgtq|vpermilpd|vpermilps|vperm2f128|vpextrb|vpextrw|vpextrd|vpextrq|vphaddw|vphaddd|vphaddsw|vphminposuw|vphsubw|vphsubd|vphsubsw|vpinsrb|vpinsrw|vpinsrd|vpinsrq|vpmaddwd|vpmaddubsw|vpmaxsb|vpmaxsw|vpmaxsd|vpmaxub|vpmaxuw|vpmaxud|vpminsb|vpminsw|vpminsd|vpminub|vpminuw|vpminud|vpmovmskb|vpmovsxbw|vpmovsxbd|vpmovsxbq|vpmovsxwd|vpmovsxwq|vpmovsxdq|vpmovzxbw|vpmovzxbd|vpmovzxbq|vpmovzxwd|vpmovzxwq|vpmovzxdq|vpmulhuw|vpmulhrsw|vpmulhw|vpmullw|vpmulld|vpmuludq|vpmuldq|vpor|vpsadbw|vpshufb|vpshufd|vpshufhw|vpshuflw|vpsignb|vpsignw|vpsignd|vpslldq|vpsrldq|vpsllw|vpslld|vpsllq|vpsraw|vpsrad|vpsrlw|vpsrld|vpsrlq|vptest|vpsubb|vpsubw|vpsubd|vpsubq|vpsubsb|vpsubsw|vpsubusb|vpsubusw|vpunpckhbw|vpunpckhwd|vpunpckhdq|vpunpckhqdq|vpunpcklbw|vpunpcklwd|vpunpckldq|vpunpcklqdq|vpxor|vrcpps|vrcpss|vrsqrtps|vrsqrtss|vroundpd|vroundps|vroundsd|vroundss|vshufpd|vshufps|vsqrtpd|vsqrtps|vsqrtsd|vsqrtss|vstmxcsr|vsubpd|vsubps|vsubsd|vsubss|vtestps|vtestpd|vucomisd|vucomiss|vunpckhpd|vunpckhps|vunpcklpd|vunpcklps|vxorpd|vxorps|vzeroall|vzeroupper|pclmullqlqdq|pclmulhqlqdq|pclmullqhqdq|pclmulhqhqdq|pclmulqdq|vpclmullqlqdq|vpclmulhqlqdq|vpclmullqhqdq|vpclmulhqhqdq|vpclmulqdq|vfmadd132ps|vfmadd132pd|vfmadd312ps|vfmadd312pd|vfmadd213ps|vfmadd213pd|vfmadd123ps|vfmadd123pd|vfmadd231ps|vfmadd231pd|vfmadd321ps|vfmadd321pd|vfmaddsub132ps|vfmaddsub132pd|vfmaddsub312ps|vfmaddsub312pd|vfmaddsub213ps|vfmaddsub213pd|vfmaddsub123ps|vfmaddsub123pd|vfmaddsub231ps|vfmaddsub231pd|vfmaddsub321ps|vfmaddsub321pd|vfmsub132ps|vfmsub132pd|vfmsub312ps|vfmsub312pd|vfmsub213ps|vfmsub213pd|vfmsub123ps|vfmsub123pd|vfmsub231ps|vfmsub231pd|vfmsub321ps|vfmsub321pd|vfmsubadd132ps|vfmsubadd132pd|vfmsubadd312ps|vfmsubadd312pd|vfmsubadd213ps|vfmsubadd213pd|vfmsubadd123ps|vfmsubadd123pd|vfmsubadd231ps|vfmsubadd231pd|vfmsubadd321ps|vfmsubadd321pd|vfnmadd132ps|vfnmadd132pd|vfnmadd312ps|vfnmadd312pd|vfnmadd213ps|vfnmadd213pd|vfnmadd123ps|vfnmadd123pd|vfnmadd231ps|vfnmadd231pd|vfnmadd321ps|vfnmadd321pd|vfnmsub132ps|vfnmsub132pd|vfnmsub312ps|vfnmsub312pd|vfnmsub213ps|vfnmsub213pd|vfnmsub123ps|vfnmsub123pd|vfnmsub231ps|vfnmsub231pd|vfnmsub321ps|vfnmsub321pd|vfmadd132ss|vfmadd132sd|vfmadd312ss|vfmadd312sd|vfmadd213ss|vfmadd213sd|vfmadd123ss|vfmadd123sd|vfmadd231ss|vfmadd231sd|vfmadd321ss|vfmadd321sd|vfmsub132ss|vfmsub132sd|vfmsub312ss|vfmsub312sd|vfmsub213ss|vfmsub213sd|vfmsub123ss|vfmsub123sd|vfmsub231ss|vfmsub231sd|vfmsub321ss|vfmsub321sd|vfnmadd132ss|vfnmadd132sd|vfnmadd312ss|vfnmadd312sd|vfnmadd213ss|vfnmadd213sd|vfnmadd123ss|vfnmadd123sd|vfnmadd231ss|vfnmadd231sd|vfnmadd321ss|vfnmadd321sd|vfnmsub132ss|vfnmsub132sd|vfnmsub312ss|vfnmsub312sd|vfnmsub213ss|vfnmsub213sd|vfnmsub123ss|vfnmsub123sd|vfnmsub231ss|vfnmsub231sd|vfnmsub321ss|vfnmsub321sd|rdfsbase|rdgsbase|rdrand|wrfsbase|wrgsbase|vcvtph2ps|vcvtps2ph|adcx|adox|rdseed|clac|stac|xstore|xcryptecb|xcryptcbc|xcryptctr|xcryptcfb|xcryptofb|montmul|xsha1|xsha256|llwpcb|slwpcb|lwpval|lwpins|vfmaddpd|vfmaddps|vfmaddsd|vfmaddss|vfmaddsubpd|vfmaddsubps|vfmsubaddpd|vfmsubaddps|vfmsubpd|vfmsubps|vfmsubsd|vfmsubss|vfnmaddpd|vfnmaddps|vfnmaddsd|vfnmaddss|vfnmsubpd|vfnmsubps|vfnmsubsd|vfnmsubss|vfrczpd|vfrczps|vfrczsd|vfrczss|vpcmov|vpcomb|vpcomd|vpcomq|vpcomub|vpcomud|vpcomuq|vpcomuw|vpcomw|vphaddbd|vphaddbq|vphaddbw|vphadddq|vphaddubd|vphaddubq|vphaddubw|vphaddudq|vphadduwd|vphadduwq|vphaddwd|vphaddwq|vphsubbw|vphsubdq|vphsubwd|vpmacsdd|vpmacsdqh|vpmacsdql|vpmacssdd|vpmacssdqh|vpmacssdql|vpmacsswd|vpmacssww|vpmacswd|vpmacsww|vpmadcsswd|vpmadcswd|vpperm|vprotb|vprotd|vprotq|vprotw|vpshab|vpshad|vpshaq|vpshaw|vpshlb|vpshld|vpshlq|vpshlw|vbroadcasti128|vpblendd|vpbroadcastb|vpbroadcastw|vpbroadcastd|vpbroadcastq|vpermd|vpermpd|vpermps|vpermq|vperm2i128|vextracti128|vinserti128|vpmaskmovd|vpmaskmovq|vpsllvd|vpsllvq|vpsravd|vpsrlvd|vpsrlvq|vgatherdpd|vgatherqpd|vgatherdps|vgatherqps|vpgatherdd|vpgatherqd|vpgatherdq|vpgatherqq|xabort|xbegin|xend|xtest|andn|bextr|blci|blcic|blsi|blsic|blcfill|blsfill|blcmsk|blsmsk|blsr|blcs|bzhi|mulx|pdep|pext|rorx|sarx|shlx|shrx|tzcnt|tzmsk|t1mskc|valignd|valignq|vblendmpd|vblendmps|vbroadcastf32x4|vbroadcastf64x4|vbroadcasti32x4|vbroadcasti64x4|vcompresspd|vcompressps|vcvtpd2udq|vcvtps2udq|vcvtsd2usi|vcvtss2usi|vcvttpd2udq|vcvttps2udq|vcvttsd2usi|vcvttss2usi|vcvtudq2pd|vcvtudq2ps|vcvtusi2sd|vcvtusi2ss|vexpandpd|vexpandps|vextractf32x4|vextractf64x4|vextracti32x4|vextracti64x4|vfixupimmpd|vfixupimmps|vfixupimmsd|vfixupimmss|vgetexppd|vgetexpps|vgetexpsd|vgetexpss|vgetmantpd|vgetmantps|vgetmantsd|vgetmantss|vinsertf32x4|vinsertf64x4|vinserti32x4|vinserti64x4|vmovdqa32|vmovdqa64|vmovdqu32|vmovdqu64|vpabsq|vpandd|vpandnd|vpandnq|vpandq|vpblendmd|vpblendmq|vpcmpltd|vpcmpled|vpcmpneqd|vpcmpnltd|vpcmpnled|vpcmpd|vpcmpltq|vpcmpleq|vpcmpneqq|vpcmpnltq|vpcmpnleq|vpcmpq|vpcmpequd|vpcmpltud|vpcmpleud|vpcmpnequd|vpcmpnltud|vpcmpnleud|vpcmpud|vpcmpequq|vpcmpltuq|vpcmpleuq|vpcmpnequq|vpcmpnltuq|vpcmpnleuq|vpcmpuq|vpcompressd|vpcompressq|vpermi2d|vpermi2pd|vpermi2ps|vpermi2q|vpermt2d|vpermt2pd|vpermt2ps|vpermt2q|vpexpandd|vpexpandq|vpmaxsq|vpmaxuq|vpminsq|vpminuq|vpmovdb|vpmovdw|vpmovqb|vpmovqd|vpmovqw|vpmovsdb|vpmovsdw|vpmovsqb|vpmovsqd|vpmovsqw|vpmovusdb|vpmovusdw|vpmovusqb|vpmovusqd|vpmovusqw|vpord|vporq|vprold|vprolq|vprolvd|vprolvq|vprord|vprorq|vprorvd|vprorvq|vpscatterdd|vpscatterdq|vpscatterqd|vpscatterqq|vpsraq|vpsravq|vpternlogd|vpternlogq|vptestmd|vptestmq|vptestnmd|vptestnmq|vpxord|vpxorq|vrcp14pd|vrcp14ps|vrcp14sd|vrcp14ss|vrndscalepd|vrndscaleps|vrndscalesd|vrndscaless|vrsqrt14pd|vrsqrt14ps|vrsqrt14sd|vrsqrt14ss|vscalefpd|vscalefps|vscalefsd|vscalefss|vscatterdpd|vscatterdps|vscatterqpd|vscatterqps|vshuff32x4|vshuff64x2|vshufi32x4|vshufi64x2|kandnw|kandw|kmovw|knotw|kortestw|korw|kshiftlw|kshiftrw|kunpckbw|kxnorw|kxorw|vpbroadcastmb2q|vpbroadcastmw2d|vpconflictd|vpconflictq|vplzcntd|vplzcntq|vexp2pd|vexp2ps|vrcp28pd|vrcp28ps|vrcp28sd|vrcp28ss|vrsqrt28pd|vrsqrt28ps|vrsqrt28sd|vrsqrt28ss|vgatherpf0dpd|vgatherpf0dps|vgatherpf0qpd|vgatherpf0qps|vgatherpf1dpd|vgatherpf1dps|vgatherpf1qpd|vgatherpf1qps|vscatterpf0dpd|vscatterpf0dps|vscatterpf0qpd|vscatterpf0qps|vscatterpf1dpd|vscatterpf1dps|vscatterpf1qpd|vscatterpf1qps|prefetchwt1|bndmk|bndcl|bndcu|bndcn|bndmov|bndldx|bndstx|sha1rnds4|sha1nexte|sha1msg1|sha1msg2|sha256rnds2|sha256msg1|sha256msg2)\\b"), + false, + false, + "property" + ) + ), + + token( + "directive", + //tasm + pattern(compile("\\b(?:.186|.286|.286c|.286p|.287|.386|.386c|.386p|.387|.486|.486c|.486p|.487|.586|.8086|.8087|p186|p286|p286n|p286p|p287|p386|p386n|p386p|p387|p486|p486n|p487|p8086|p8087|pno87)\\b", Pattern.CASE_INSENSITIVE)), + pattern(compile("\\b(?:align|.alpha|arg|assume|%bin|call|catstr|.code|codeseg|comm|comment|%cond|.const|const|.cref|%cref|%crefall|%crefref|%crefuref|%ctls|.data|dataseg|db|dd|%depth|df|display|dosseg|dp|dq|dt|dw|else|elseif|emul|end|endif|endm|endp|ends|enum|equ|.err|err|.err1|.err2|.errb|.errdef|.errdif|.errdifi|.erre|.erridn|.erridni|errif|errif1|errif2|errifb|errifdef|errifdif|errifdifi|errife|errifidn|errifidni|errifnb|errifndef|.errnb|.errndef|.errnz|even|evendata|.exit|exitcode|exitm|extrn|.fardata|fardata|fastimul|flipflag|getfield|global|goto|group|ideal|if|if1|if2|ifb|ifdef|ifdif|ifdifi|ife|ifidn|ifidni|ifnb|ifndef|%incl|include|includelib|instr|irp|irpc|jmp|jumps|label|.lall|largestack|.lfcond|%linum|%list|.list|local|locals|macro|%macs|maskflag|masm|masm51|model|.model|multerrs|name|%newpage|%noconds|%nocref|%noctls|noemul|%noincl|nojumps|%nolist|nolocals|%nomacs|nomasm51|nomulterrs|nosmart|%nosyms|%notrunc|nowarn|org|%out|%pagesize|%pcnt|%poplctl|popstate|proc|procdesc|proctype|public|publicdll|purge|%pushlctl|pushstate|quirks|.radix|radix|record|rept|retcode|retf|retn|.sall|segment|.seq|setfield|setflag|.sfcond|sizestr|smallstack|smart|.stack|stack|.startup|startupcode|struc|substr|subttl|%subttl|%syms|table|%tabsize|tblinit|tblinst|tblptr|testflag|%text|.tfcond|title|%title|%trunc|typedef|udataseg|ufardata|union|uses|version|warn|while|.xall|.xcref|.xlist)\\b", Pattern.CASE_INSENSITIVE)), + + //nasm + pattern(compile("\\[?BITS (?:16|32|64)\\]?", Pattern.CASE_INSENSITIVE)), + pattern( + compile("(^\\s*)section\\s*[a-zA-Z.]+:?", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE), + true + ), + pattern(compile("(?:extern|global)[^;\\r\\n]*", Pattern.CASE_INSENSITIVE)), + pattern(compile("(?:CPU|FLOAT|DEFAULT).*$", Pattern.MULTILINE)) + ), + token( + "register", + pattern( + compile("\\b(?:st\\d|[xyz]mm\\d\\d?|[cdt]r\\d|r\\d\\d?[bwd]?|[er]?[abcd]x|[abcd][hl]|[er]?(?:bp|sp|si|di)|[cdefgs]s)\\b", Pattern.CASE_INSENSITIVE), + false, + false, + "variable" + ) + ), + token( + "number", + pattern(compile("(?:\\b|(?=\\$))(?:0[hx][\\da-f]*\\.?[\\da-f]+(?:p[+-]?\\d+)?|\\d[\\da-f]+[hx]|\\$\\d[\\da-f]*|0[oq][0-7]+|[0-7]+[oq]|0[by][01]+|[01]+[by]|0[dt]\\d+|\\d*\\.?\\d+(?:\\.?e[+-]?\\d+)?[dt]?)\\b", Pattern.CASE_INSENSITIVE)) + ), + token( + "operator", + pattern(compile("[\\[\\]*+\\-\\/%<>=&|$!]")), + + //tasm + pattern(compile("\\b(?:byte|codeptr|dataptr|dup|dword|eq|far|fword|ge|gt|high|large|le|length|low|lt|mask|mod|ne|near|offset|proc|ptr|pword|qword|seg|short|size|small|symtype|tbyte|this|type|width|word)\\b", Pattern.CASE_INSENSITIVE)) + ) + ); + } + + private Prism_x86asm() { + } +} diff --git a/src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java b/src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java new file mode 100644 index 0000000..40fd638 --- /dev/null +++ b/src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java @@ -0,0 +1,65 @@ +package ca.blarg.prism4j.languages; + +import io.noties.prism4j.Prism4j; +import org.jetbrains.annotations.NotNull; + +import static io.noties.prism4j.Prism4j.*; +import static java.util.regex.Pattern.*; + +public class Prism_yaml { + + @NotNull + public static Grammar create(@NotNull Prism4j prism4j) { + return grammar("yaml", + token("scalar", pattern( + compile("([\\-:]\\s*(?:![^\\s]+)?[ \\t]*[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)[^\\r\\n]+(?:\\2[^\\r\\n]+)*)"), + true, + false, + "string" + )), + token("comment", pattern(compile("#.*"))), + token("key", pattern( + compile("(\\s*(?:^|[:\\-,\\[{\\r\\n?])[ \\t]*(?:![^\\s]+)?[ \\t]*)[^\\r\\n{\\[\\]},#\\s]+?(?=\\s*:\\s)"), + true, + false, + "atrule" + )), + token("directive", pattern( + compile("(^[ \\t]*)%.+", MULTILINE), + true, + false, + "important" + )), + token("datetime", pattern( + compile("([:\\-,\\[{]\\s*(?:![^\\s]+)?[ \\t]*)(?:\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?)?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?)(?=[ \\t]*(?:$|,|]|\\}))", MULTILINE), + true, + false, + "number" + )), + token("boolean", pattern( + compile("([:\\-,\\[{]\\s*(?:![^\\s]+)?[ \\t]*)(?:true|false)[ \\t]*(?=$|,|]|\\})", MULTILINE | CASE_INSENSITIVE), + true, + false, + "important" + )), + token("null", pattern( + compile("([:\\-,\\[{]\\s*(?:![^\\s]+)?[ \\t]*)(?:null|~)[ \\t]*(?=$|,|]|\\})", MULTILINE | CASE_INSENSITIVE), + true, + false, + "important" + )), + token("string", pattern( + compile("([:\\-,\\[{]\\s*(?:![^\\s]+)?[ \\t]*)(\"|')(?:(?!\\2)[^\\\\\\r\\n]|\\\\.)*\\2(?=[ \\t]*(?:$|,|]|\\}))", MULTILINE), + true, + true + )), + token("number", pattern( + compile("([:\\-,\\[{]\\s*(?:![^\\s]+)?[ \\t]*)[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+\\.?\\d*|\\.?\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)[ \\t]*(?=$|,|]|\\})", MULTILINE | CASE_INSENSITIVE), + true + )), + token("tag", pattern(compile("![^\\s]+"))), + token("important", pattern(compile("[&*][\\w]+"))), + token("punctuation", pattern(compile("---|[:\\[\\]{}\\-,|>?]|\\.\\.\\."))) + ); + } +}