Add Language: Imba (#6130)
* Add Language: Imba * Update lib/linguist/languages.yml Co-authored-by: Colin Seymour <colin@github.com> Co-authored-by: Colin Seymour <colin@github.com>
This commit is contained in:
Родитель
deb13a4576
Коммит
e438f159db
|
@ -506,6 +506,9 @@
|
|||
[submodule "vendor/grammars/idris"]
|
||||
path = vendor/grammars/idris
|
||||
url = https://github.com/idris-hackers/idris-sublime.git
|
||||
[submodule "vendor/grammars/imba-linguist-grammar"]
|
||||
path = vendor/grammars/imba-linguist-grammar
|
||||
url = https://github.com/imba/imba-linguist-grammar.git
|
||||
[submodule "vendor/grammars/ini.tmbundle"]
|
||||
path = vendor/grammars/ini.tmbundle
|
||||
url = https://github.com/textmate/ini.tmbundle
|
||||
|
|
|
@ -426,6 +426,8 @@ vendor/grammars/idl.tmbundle:
|
|||
- text.idl-idldoc
|
||||
vendor/grammars/idris:
|
||||
- source.idris
|
||||
vendor/grammars/imba-linguist-grammar:
|
||||
- source.imba
|
||||
vendor/grammars/ini.tmbundle:
|
||||
- source.ini
|
||||
vendor/grammars/io.tmbundle:
|
||||
|
|
|
@ -2877,6 +2877,14 @@ ImageJ Macro:
|
|||
ace_mode: text
|
||||
tm_scope: none
|
||||
language_id: 575143428
|
||||
Imba:
|
||||
type: programming
|
||||
color: "#16cec6"
|
||||
extensions:
|
||||
- ".imba"
|
||||
ace_mode: text
|
||||
tm_scope: source.imba
|
||||
language_id: 1057618448
|
||||
Inform 7:
|
||||
type: programming
|
||||
wrap: true
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
let stdout = process.stdout
|
||||
let clear_screen = do stdout.write "\x1b[2J"
|
||||
let hide_cursor = do stdout.write "\x1b[?25l"
|
||||
let show_cursor = do stdout.write "\x1b[?25h"
|
||||
let smcup = do stdout.write "\x1b[?1049h"
|
||||
let rmcup = do stdout.write "\x1b[?1049l"
|
||||
let place_cursor = do stdout.write "\x1b[1;1H"
|
||||
|
||||
let alive_cell_char = "◼"
|
||||
let dead_cell_char = " "
|
||||
|
||||
class Game
|
||||
|
||||
constructor rows, cols
|
||||
self.rows = rows
|
||||
self.cols = cols
|
||||
self.board = get_empty_board!
|
||||
randomize_board!
|
||||
|
||||
def get_empty_board
|
||||
new Array((rows + 2) * (cols + 2)).fill(no)
|
||||
|
||||
def idx i, j
|
||||
(i + 1) * (cols + 2) + (j + 1)
|
||||
|
||||
def randomize_board
|
||||
for i in [0 .. rows - 1]
|
||||
for j in [0 .. cols - 1]
|
||||
board[idx(i, j)] = Math.random! < 0.5
|
||||
|
||||
def print_whole_board
|
||||
let s = ""
|
||||
for cell, i in board
|
||||
if cell
|
||||
s += alive_cell_char
|
||||
else
|
||||
s += dead_cell_char
|
||||
if (i + 1) % (cols + 2) == 0
|
||||
s += "\n"
|
||||
stdout.write s
|
||||
|
||||
def print_board
|
||||
let s = ""
|
||||
for i in [0 .. rows - 1]
|
||||
for j in [0 .. cols - 1]
|
||||
if board[idx(i, j)]
|
||||
s += alive_cell_char
|
||||
else
|
||||
s += dead_cell_char
|
||||
s += "\n"
|
||||
stdout.write s
|
||||
|
||||
def count_neighbors i, j
|
||||
board[idx(i - 1, j - 1)] +
|
||||
board[idx(i - 1, j)] +
|
||||
board[idx(i - 1, j + 1)] +
|
||||
board[idx(i, j - 1)] +
|
||||
board[idx(i, j + 1)] +
|
||||
board[idx(i + 1, j - 1)] +
|
||||
board[idx(i + 1, j)] +
|
||||
board[idx(i + 1, j + 1)]
|
||||
|
||||
def tick
|
||||
let next = get_empty_board!
|
||||
let nc
|
||||
for i in [0 .. rows - 1]
|
||||
for j in [0 .. cols - 1]
|
||||
nc = count_neighbors i, j
|
||||
next[idx(i, j)] = board[idx(i, j)] and nc == 2 or nc == 3
|
||||
board = next
|
||||
|
||||
process.on('exit') do
|
||||
clear_screen!
|
||||
show_cursor!
|
||||
rmcup!
|
||||
|
||||
process.on('SIGINT', process.exit)
|
||||
|
||||
def main
|
||||
smcup!
|
||||
hide_cursor!
|
||||
let game = new Game rows, cols
|
||||
let count = 0
|
||||
setInterval(&, 50) do
|
||||
if count > max_generations
|
||||
clearInterval this
|
||||
place_cursor!
|
||||
stdout.write "{count}/{max_generations}\n"
|
||||
game.print_board!
|
||||
game.tick!
|
||||
count += 1
|
||||
|
||||
let max_generations = 500
|
||||
let delay = 50
|
||||
let rows = stdout.rows >>> 1
|
||||
let cols = stdout.columns >>> 1
|
||||
main!
|
|
@ -237,6 +237,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
|
|||
- **INI:** [textmate/ini.tmbundle](https://github.com/textmate/ini.tmbundle)
|
||||
- **Idris:** [idris-hackers/idris-sublime](https://github.com/idris-hackers/idris-sublime)
|
||||
- **Ignore List:** [Alhadis/language-etc](https://github.com/Alhadis/language-etc)
|
||||
- **Imba:** [imba/imba-linguist-grammar](https://github.com/imba/imba-linguist-grammar)
|
||||
- **Inform 7:** [iftechfoundation/language-inform7](https://github.com/iftechfoundation/language-inform7)
|
||||
- **Inno Setup:** [idleberg/atom-language-innosetup](https://github.com/idleberg/atom-language-innosetup)
|
||||
- **Io:** [textmate/io.tmbundle](https://github.com/textmate/io.tmbundle)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 2900c2df08244bd63d73cdb3a271ae2993e6aec8
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
name: imba-linguist-grammar
|
||||
version: 2900c2df08244bd63d73cdb3a271ae2993e6aec8
|
||||
type: git_submodule
|
||||
homepage: https://github.com/imba/imba-linguist-grammar.git
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Sindre
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
Загрузка…
Ссылка в новой задаче