Skip to content

Instantly share code, notes, and snippets.

@sadikovi
Created May 31, 2018 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadikovi/d1a400ef3020be2e07999f20d47fbe74 to your computer and use it in GitHub Desktop.
Save sadikovi/d1a400ef3020be2e07999f20d47fbe74 to your computer and use it in GitHub Desktop.
Java 9 module grammar for language-java
diff --git a/grammars/java.cson b/grammars/java.cson
index cb9947a..399c914 100644
--- a/grammars/java.cson
+++ b/grammars/java.cson
@@ -109,6 +109,9 @@
{
'include': '#code'
}
+ {
+ 'include': '#module'
+ }
]
'repository':
'all-types':
@@ -916,6 +919,39 @@
'include': '#comments'
}
]
+ 'module':
+ # a uniquely named, reusable group of related packages, as well as resources (such as images
+ # and XML files).
+ 'begin': '((open)\\s)?(module)\\s+(\\w+)'
+ 'end': '}'
+ 'beginCaptures':
+ '1':
+ 'name': 'storage.modifier.java'
+ '3':
+ 'name': 'storage.modifier.java'
+ '4':
+ 'name': 'entity.name.type.module.java'
+ 'endCaptures':
+ '0':
+ 'name': 'punctuation.section.module.end.bracket.curly.java'
+ 'name': 'meta.module.java'
+ 'patterns': [
+ {
+ 'begin': '{'
+ 'beginCaptures':
+ '0':
+ 'name': 'punctuation.section.module.begin.bracket.curly.java'
+ 'end': '(?=})'
+ 'contentName': 'meta.module.body.java'
+ 'patterns': [
+ # TODO: Write more rules for module grammar
+ {
+ 'match': '\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b'
+ 'name': 'keyword.module.java'
+ }
+ ]
+ }
+ ]
'numbers':
# See http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.1 (integers)
# and http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.2 (floats)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment