Skip to content

Commit

Permalink
Contribute 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 committed Dec 12, 2023
1 parent 0237ecf commit 0decd5a
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 1 deletion.
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>

0 comments on commit 0decd5a

Please sign in to comment.