initial commit
This commit is contained in:
commit
4cd678242f
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
.DS_Store
|
||||||
|
out/
|
||||||
|
log/
|
||||||
|
target/
|
||||||
|
build/
|
||||||
|
.settings/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
*.eml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
*.class
|
||||||
|
*.jar
|
202
LICENSE
Normal file
202
LICENSE
Normal file
|
@ -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.
|
||||||
|
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -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
|
||||||
|
<dependency>
|
||||||
|
<groupId>ca.blarg</groupId>
|
||||||
|
<artifactId>prism4j-languages</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
135
pom.xml
Normal file
135
pom.xml
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>ca.blarg</groupId>
|
||||||
|
<artifactId>prism4j-languages</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<name>Prism4j Pre-packaged Languages</name>
|
||||||
|
<description>An assortment of pre-packaged language grammars for use with Prism4j.</description>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>The Apache Software License, Version 2.0</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<url>git@github.com:gered/prism4j-languages.git</url>
|
||||||
|
<connection>scm:git:${project.scm.url}</connection>
|
||||||
|
<developerConnection>scm:git:${project.scm.url}</developerConnection>
|
||||||
|
<tag>HEAD</tag>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>Gered King</name>
|
||||||
|
<email>gered@blarg.ca</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
<repository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.noties</groupId>
|
||||||
|
<artifactId>prism4j</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-release-plugin</artifactId>
|
||||||
|
<version>2.5.3</version>
|
||||||
|
<configuration>
|
||||||
|
<useReleaseProfile>false</useReleaseProfile>
|
||||||
|
<releaseProfiles>release</releaseProfiles>
|
||||||
|
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||||
|
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||||
|
<goals>deploy</goals>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<additionalOptions>
|
||||||
|
<additionalOption>-Xdoclint:none</additionalOption>
|
||||||
|
</additionalOptions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sign-artifacts</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</project>
|
|
@ -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<String> languages() {
|
||||||
|
Set<String> 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;
|
||||||
|
}
|
||||||
|
}
|
58
src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java
Normal file
58
src/main/java/ca/blarg/prism4j/languages/Prism_6502asm.java
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
56
src/main/java/ca/blarg/prism4j/languages/Prism_basic.java
Normal file
56
src/main/java/ca/blarg/prism4j/languages/Prism_basic.java
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
54
src/main/java/ca/blarg/prism4j/languages/Prism_c.java
Normal file
54
src/main/java/ca/blarg/prism4j/languages/Prism_c.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
54
src/main/java/ca/blarg/prism4j/languages/Prism_clike.java
Normal file
54
src/main/java/ca/blarg/prism4j/languages/Prism_clike.java
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
41
src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java
Normal file
41
src/main/java/ca/blarg/prism4j/languages/Prism_cpp.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
95
src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java
Normal file
95
src/main/java/ca/blarg/prism4j/languages/Prism_csharp.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
53
src/main/java/ca/blarg/prism4j/languages/Prism_java.java
Normal file
53
src/main/java/ca/blarg/prism4j/languages/Prism_java.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
106
src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java
Normal file
106
src/main/java/ca/blarg/prism4j/languages/Prism_javascript.java
Normal file
|
@ -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<Token> 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("(<script[\\s\\S]*?>)[\\s\\S]*?(?=<\\/script>)", CASE_INSENSITIVE),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
"language-javascript",
|
||||||
|
js
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return js;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
28
src/main/java/ca/blarg/prism4j/languages/Prism_json.java
Normal file
28
src/main/java/ca/blarg/prism4j/languages/Prism_json.java
Normal file
|
@ -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)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
46
src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java
Normal file
46
src/main/java/ca/blarg/prism4j/languages/Prism_makefile.java
Normal file
|
@ -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("[:;(){}]")))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
77
src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java
Normal file
77
src/main/java/ca/blarg/prism4j/languages/Prism_pascal.java
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
55
src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java
Normal file
55
src/main/java/ca/blarg/prism4j/languages/Prism_qbasic.java
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
43
src/main/java/ca/blarg/prism4j/languages/Prism_sql.java
Normal file
43
src/main/java/ca/blarg/prism4j/languages/Prism_sql.java
Normal file
|
@ -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("[;\\[\\]()`,.]")))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
83
src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java
Normal file
83
src/main/java/ca/blarg/prism4j/languages/Prism_x86asm.java
Normal file
File diff suppressed because one or more lines are too long
65
src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java
Normal file
65
src/main/java/ca/blarg/prism4j/languages/Prism_yaml.java
Normal file
|
@ -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("---|[:\\[\\]{}\\-,|>?]|\\.\\.\\.")))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue