Skip to content

Commit

Permalink
feat: TextMate grammar for jikespg grammars
Browse files Browse the repository at this point in the history
jikespg is the parser generator used in ECJ.
This TextMate grammar provides basic syntax highlighting for the grammar
files that jikespg uses.
In order to try out this grammar,
try editing
https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core.compiler.batch/grammar/java.g
,
or try editing some of the example grammars in the jikespg repo:
https://github.com/daveshields/jikespg

I wrote this grammar.
It doesn't come from the VS Code repository,
so it can't be auto-updated from there.

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 authored and mickaelistria committed Dec 12, 2023
1 parent 0237ecf commit ee0477b
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 5 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.language_pack.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.tm4e.language_pack.feature"
label="%featureName"
version="0.2.1.qualifier"
version="0.3.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.language_pack.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

<artifactId>org.eclipse.tm4e.language_pack.feature</artifactId>
<packaging>eclipse-feature</packaging>
<version>0.2.1-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
</project>
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.language_pack/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.language_pack;singleton:=true
Bundle-Version: 0.2.1.qualifier
Bundle-Version: 0.3.0.qualifier
Require-Bundle: org.eclipse.tm4e.ui;bundle-version="[0.1.0,2.0.0)",
org.eclipse.tm4e.registry;bundle-version="[0.1.0,2.0.0)",
org.eclipse.tm4e.languageconfiguration;bundle-version="[0.1.0,2.0.0)",
Expand Down
167 changes: 167 additions & 0 deletions org.eclipse.tm4e.language_pack/jikespg/jikespg.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Jikespg Grammar",
"fileTypes": [
"g"
],
"patterns": [
{
"include": "#keywords"
},
{
"include": "#options"
},
{
"include": "#sections"
},
{
"include": "#comments"
},
{
"include": "#embeddedCode"
},
{
"include": "#macro"
},
{
"include": "#productions"
}
],
"repository": {
"keywords": {
"patterns": [
{
"name": "keyword.control.jikespg",
"match": "\\b(?<=\\$)([Dd][Ee][Ff][Ii][Nn][Ee]|[Ee][Mm][Pp][Tt][Yy]|[Ee][Rr][Rr][Oo][Rr]|[Ee][Oo][Ll]|[Ee][Oo][Ff]|[Ee][Nn][Dd]|[Rr][Uu][Ll][Ee][Ss]|[Aa][Ll][Ii][Aa][Ss]|[Ss][Tt][Aa][Rr][Tt]|[Nn][Aa][Mm][Ee][Ss])\\b",
"comment": "Dollar prefixed keywords. keywords are case insensitive"
}
]
},
"comments": {
"patterns": [
{
"name": "comment.line.double-dash.jikespg",
"match": "(?<!')(--.*)"
}
]
},
"options": {
"patterns": [
{
"begin": "\\b(?<=%)([Oo][Pp][Tt][Ii][Oo][Nn][Ss])",
"end": "$\\n?",
"beginCaptures": {
"1": {
"name": "keyword.control.less.jikespg"
}
},
"patterns": [
{
"match": "([^=,]+)(?:=([^,]+))?",
"captures": {
"1": {
"name": "variable.name.jikespg"
},
"2": {
"name": "constant.language.jikespg"
}
}
}
]
}
]
},
"sections": {
"begin": "\\b(?<=\\$)([Tt][Ee][Rr][Mm][Ii][Nn][Aa][Ll][Ss])\\b",
"end": "(?=\\$)",
"beginCaptures": {
"1": {
"name": "keyword.control"
}
},
"patterns": [
{
"name": "constant.language",
"match": "\\b(\\w+)\\b"
},
{
"include": "#comments"
}
]
},
"embeddedCode": {
"patterns": [
{
"name": "string.quoted.triple.jikespg",
"begin": "\\s*/\\.",
"end": "\\./"
},
{
"name": "string.quoted.triple.jikespg",
"begin": "\\s*/:",
"end": ":/"
}
]
},
"macro": {
"patterns": [
{
"match": "\\b(?<=\\$)(\\w+)\\b",
"name": "entity.name.function"
}
]
},
"productions": {
"patterns": [
{
"name": "variable.name.jikespg",
"begin": "^\\s*([%\\{\\}\\[\\]\\w]+)\\s*(::=)",
"end": "(?:(?=--)|$\\n?)",
"beginCaptures": {
"1": {
"name": "variable.name.jikespg"
},
"2": {
"name": "keyword.operator.jikespg"
}
}
},
{
"name": "variable.name.jikespg",
"begin": "^\\s*([%\\{\\}\\[\\]\\w]+)\\s*(->)",
"end": "(?:(?=--)|$\\n?)",
"beginCaptures": {
"1": {
"name": "variable.name.jikespg"
},
"2": {
"name": "keyword.operator.jikespg"
}
}
},
{
"name": "variable.name.jikespg",
"begin": "^\\s*(\\|)",
"end": "(?:(?=--)|$\\n?)",
"beginCaptures": {
"1": {
"name": "keyword.operator.jikespg"
}
}
},
{
"comment": "if not yet captured, it's probably a continued definition line. use hard symbols to avoid reparsing something",
"begin": "^",
"end": "(?:(?:/.)|(?:\\$)|(?=--)|$\\n?)",
"patterns": [
{
"name": "variable.name.jikespg",
"match": "([%\\{\\}\\[\\]\\w]+)"
}
]
}
]
}
},
"scopeName": "lngpck.source.jikespg"
}
25 changes: 25 additions & 0 deletions org.eclipse.tm4e.language_pack/jikespg/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"comments": {
"lineComment": "--"
},
"brackets": [
["/.", "./"],
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
14 changes: 13 additions & 1 deletion org.eclipse.tm4e.language_pack/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,18 @@
<scopeNameContentTypeBinding scopeName="lngpck.source.json.lines" contentTypeId="lng.jsonl"/>
</extension>

<!-- jikespg -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="lng.jikespg" base-type="org.eclipse.tm4e.language_pack.basetype" name="jikespg grammar" priority="low" file-extensions="g" />
</extension>
<extension point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
<languageConfiguration contentTypeId="lng.jikespg" path="jikespg/language-configuration.json"/>
</extension>
<extension point="org.eclipse.tm4e.registry.grammars">
<grammar scopeName="lngpck.source.jikespg" path="jikespg/jikespg.tmLanguage.json"/>
<scopeNameContentTypeBinding scopeName="lngpck.source.jikespg" contentTypeId="lng.jikespg"/>
</extension>

<!-- julia -->
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type id="lng.julia" base-type="org.eclipse.tm4e.language_pack.basetype" name="Julia (Syntax Highlighting)" priority="low" file-extensions="jl"/>
Expand Down Expand Up @@ -704,4 +716,4 @@
-->


</plugin>
</plugin>
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.language_pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

<artifactId>org.eclipse.tm4e.language_pack</artifactId>
<packaging>eclipse-plugin</packaging>
<version>0.2.1-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
</project>

0 comments on commit ee0477b

Please sign in to comment.