├── package.json ├── LICENSE ├── README.md └── grammars └── inform.cson /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-inform7", 3 | "version": "1.0.3", 4 | "description": "Inform 7 package for Atom", 5 | "repository": "https://github.com/iftechfoundation/language-inform7", 6 | "license": "MIT", 7 | "engines": { 8 | "atom": ">=1.0.0 <2.0.0" 9 | }, 10 | "dependencies": {} 11 | } 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2016, Andrew Plotkin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Inform 7 language grammar for Atom 2 | - Supported by the [Interactive Fiction Technology Foundation][iftf] 3 | - Created by Andrew Plotkin 4 | - https://github.com/iftechfoundation/language-inform7 5 | - https://atom.io/packages/language-inform7 6 | 7 | This package permits syntax coloring of [Inform 7][i7] source code in the [Atom][] editor (and compatible syntax colorers). 8 | 9 | This started as a fork of [Robert Clarke's Inform grammar][kumo]. It's turned into a total rewrite, however. I've renamed it to include the "7" (since Inform 6 is a different language) and added "7" to all the syntax classes. 10 | 11 | [i7]: http://inform7.com/ 12 | [atom]: https://atom.io/ 13 | [kumo]: https://github.com/kumo/language-inform 14 | [iftf]: https://iftechfoundation.org/ 15 | 16 | This correctly colors: 17 | 18 | - Strings with bracketed substitutions 19 | - Nested comments 20 | - Section header lines 21 | - Inform 6 inclusions 22 | - The documentation section at the end of an extension 23 | 24 | I do not try to color all of Inform 6 syntax. (There's a standard algorithm for this, but it's not regexp-based and I never liked it anyhow.) I just color I6 strings, dict words, and comments within I6 inclusions. 25 | 26 | Known bugs: 27 | 28 | - I7 requires section headers to be set off by blank lines above and below. This grammar does not check that requirement. 29 | 30 | Screenshot: 31 | 32 | ![Screenshot](https://cloud.githubusercontent.com/assets/65666/12072581/bf622752-b0b3-11e5-98b4-19dd0179fac4.png) 33 | 34 | For more sample Inform 7 code, see the [Linguist I7 samples][linguist] or the [friends of I7 repo][i7e]. 35 | 36 | [linguist]: https://github.com/github/linguist/tree/master/samples/Inform%207 37 | [i7e]: https://github.com/i7 38 | 39 | -------------------------------------------------------------------------------- /grammars/inform.cson: -------------------------------------------------------------------------------- 1 | 'scopeName': 'source.inform7' 2 | 'fileTypes': [ 3 | 'ni' 4 | 'i7x' 5 | ] 6 | 'name': 'Inform 7' 7 | 'limitLineLength': no 8 | 'maxTokensPerLine': 1000 9 | 10 | 'repository': { 11 | # Strings. These can contain [substitutions]. 12 | 'string': 13 | 'patterns': [ 14 | { 15 | 'name': 'string.quoted.double.inform7' 16 | 'begin': '"' 17 | 'beginCaptures': { 18 | '0': { 'name': 'punctuation.definition.string.begin.inform7' } 19 | } 20 | 'end': '"' 21 | 'endCaptures': { 22 | '0': { 'name': 'punctuation.definition.string.end.inform7' } 23 | } 24 | 'patterns': [ 25 | { 26 | 'include': '#substitution' 27 | } 28 | ] 29 | } 30 | ] 31 | 32 | # Bracketed substitutions in strings. 33 | 'substitution': 34 | 'patterns': [ 35 | { 36 | 'name' : 'keyword.control' 37 | 'begin': '\\[' 38 | 'beginCaptures': { 39 | '0': { 'name': 'keyword.control.begin.inform7' } 40 | } 41 | 'end': '\\]' 42 | 'endCaptures': { 43 | '0': { 'name': 'keyword.control.end.inform7' } 44 | } 45 | } 46 | ] 47 | 48 | # Comments inside comments. 49 | 'nestedcomment': 50 | 'patterns': [ 51 | { 52 | 'begin': '\\[' 53 | 'end': '\\]' 54 | 'patterns': [ 55 | { 56 | 'include': '#nestedcomment' 57 | } 58 | ] 59 | } 60 | ] 61 | 62 | # Patterns in an (- Inform 6 section -). 63 | 'i6comment': 64 | 'patterns': [ 65 | { 66 | 'name': 'comment.line.bang.inform6.inform7' 67 | 'match': '!.*$' 68 | } 69 | ] 70 | 'i6string': 71 | 'patterns': [ 72 | { 73 | 'name': 'string.quoted.double.inform6.inform7' 74 | 'begin': '"' 75 | 'end': '"' 76 | } 77 | ] 78 | 'i6dictword': 79 | 'patterns': [ 80 | { 81 | 'name': 'string.quoted.single.inform6.inform7' 82 | 'begin': '\'' 83 | 'end': '\'' 84 | } 85 | ] 86 | 87 | # Lines in a DOCUMENTATION section at the end of an extension. This is all lines that don't begin with a tab. 88 | 'doccomment': 89 | 'patterns': [ 90 | { 91 | 'name': 'comment.block.documentation.inform7' 92 | 'match': '^[^\t].*$' 93 | } 94 | ] 95 | } 96 | 97 | 'patterns': [ 98 | 99 | # Strings. See the #string pattern above. 100 | { 101 | 'include': '#string' 102 | } 103 | 104 | # Comments. These can be nested! 105 | { 106 | 'name': 'comment.block.inform7' 107 | 'begin': '\\[' 108 | 'beginCaptures': { 109 | '0': { 'name': 'punctuation.definition.comment.begin.inform7' } 110 | } 111 | 'end': '\\]' 112 | 'endCaptures': { 113 | '0': { 'name': 'punctuation.definition.comment.end.inform7' } 114 | } 115 | 'patterns': [ 116 | { 'include': '#nestedcomment' } 117 | ] 118 | } 119 | 120 | # Header lines. These are case-insensitive and can be indented. 121 | # We capture the header type ("Chapter") and name separately. All are wrapped in an entity.name.inform7 span. 122 | { 123 | 'name': 'entity.name.inform7' 124 | 'match': '(?i)^\\s*(volume|book|part|chapter|section)[ \t]+(.*)$' 125 | 'captures': { 126 | 1: { 'name': 'entity.type.section.inform7' } 127 | 2: { 'name': 'entity.name.section.inform7' } 128 | } 129 | } 130 | 131 | # Inform 6 inclusions. This could include a whole separate grammar for I6 code, but I don't currently have one set up, so we just mark I6 comments and strings. 132 | { 133 | 'contentName': 'support.other.inform6.inform7' 134 | 'begin': '\\(-' 135 | 'beginCaptures': { 136 | 0: { 'name': 'punctuation.definition.inform6.begin.inform7' } 137 | } 138 | 'end': '-\\)' 139 | 'endCaptures': { 140 | 0: { 'name': 'punctuation.definition.inform6.end.inform7' } 141 | } 142 | 'patterns': [ 143 | { 'include': '#i6comment' } 144 | { 'include': '#i6string' } 145 | { 'include': '#i6dictword' } 146 | ] 147 | } 148 | 149 | # The documentation at the end of an Inform extension. 150 | # The "---- DOCUMENTATION ----" line is case-insensitive and can be indented. 151 | # Whitespace is required around the word "DOCUMENATION", but it doesn't matter how much. 152 | # We only apply the comment.block.documentation style to lines which *don't* begin with a tab. See the #doccomment pattern above. 153 | # Text after the second "----" is accepted as part of the doc comment, although I hope nobody does that. 154 | { 155 | 'contentName': 'meta.documentation.inform7' 156 | 'begin': '(?i)^\\s*(----[ \t]+(documentation)[ \t]+----)(.*)$' 157 | 'end': '$ENDOFDOC' # This regexp can never match anything! We want to run to end-of-file. 158 | 'beginCaptures': { 159 | 1: { 'name': 'entity.name.inform7' } 160 | 2: { 'name': 'entity.type.section.inform7' } 161 | 3: { 'name': 'comment.block.documentation.inform7' } 162 | } 163 | 'patterns': [ 164 | { 'include': '#doccomment' } 165 | { 'include': '#string' } 166 | ] 167 | } 168 | ] 169 | --------------------------------------------------------------------------------