Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(grammars): add smalltalk
  • Loading branch information
antonreshetov committed Aug 5, 2022
commit 889e712f895dc71e5dafd63d50b7e0bb7716e15d
18 changes: 18 additions & 0 deletions demo/db/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2819,6 +2819,24 @@
"id": "j0F_-__e",
"createdAt": 1659687264814,
"updatedAt": 1659688177442
},
{
"isDeleted": false,
"isFavorites": false,
"folderId": "J7rNZi7X",
"tagsIds": [],
"description": null,
"name": "Smalltalk",
"content": [
{
"label": "Fragment 1",
"language": "smalltalk",
"value": "exampleWithNumber: x\n | y |\n true & false not & (nil isNil) ifFalse: [self halt].\n y := self size + super size.\n #($a #a 'a' 1 1.0)\n do: [ :each |\n Transcript show: (each class name);\n show: ' '].\n ^x < y \"Some comment\""
}
],
"id": "cj0IfumH",
"createdAt": 1659688801793,
"updatedAt": 1659688919992
}
],
"tags": []
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ This is a list of language that supports in massCode.
- SCSS
- SJS
- Slim
- Smalltalk
- Smarty
- Smithy
- Solidity
Expand Down
239 changes: 239 additions & 0 deletions src/renderer/components/editor/grammars/smalltalk.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"information_for_contributors": [
"This file has been converted from https://github.com/textmate/smalltalk.tmbundle/blob/master/Syntaxes/SmallTalk.tmLanguage",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"name": "smalltalk",
"foldingStartMarker": "\\[",
"foldingStopMarker": "^\\s*\\]|^\\s\\]",
"keyEquivalent": "^~S",
"fileTypes": ["st"],
"patterns": [
{
"match": "\\$.",
"name": "constant.character.smalltalk"
},
{
"match": "\\b(class)\\b",
"name": "storage.type.$1.smalltalk"
},
{
"match": "\\b(extend|super|self)\\b",
"name": "storage.modifier.$1.smalltalk"
},
{
"match": "\\b(yourself|new|Smalltalk)\\b",
"name": "keyword.control.$1.smalltalk"
},
{
"match": ":=",
"name": "keyword.operator.assignment.smalltalk"
},
{
"comment": "Parse the variable declaration like: |a b c|",
"match": "/^:\\w*\\s*\\|/",
"name": "constant.other.block.smalltalk"
},
{
"captures": {
"1": {
"name": "punctuation.definition.instance-variables.begin.smalltalk"
},
"2": {
"patterns": [
{
"match": "\\w+",
"name": "support.type.variable.declaration.smalltalk"
}
]
},
"3": {
"name": "punctuation.definition.instance-variables.end.smalltalk"
}
},
"match": "(\\|)(\\s*\\w[\\w ]*)(\\|)"
},
{
"captures": {
"1": {
"patterns": [
{
"match": ":\\w+",
"name": "entity.name.function.block.smalltalk"
}
]
}
},
"comment": "Parse the blocks like: [ :a :b | ...... ]",
"match": "\\[((\\s+|:\\w+)*)\\|"
},
{
"include": "#numeric"
},
{
"match": "<(?!<|=)|>(?!<|=|>)|<=|>=|=|==|~=|~~|>>|\\^",
"name": "keyword.operator.comparison.smalltalk"
},
{
"match": "(\\*|\\+|\\-|/|\\\\)",
"name": "keyword.operator.arithmetic.smalltalk"
},
{
"match": "(?<=[ \\t])!+|\\bnot\\b|&|\\band\\b|\\||\\bor\\b",
"name": "keyword.operator.logical.smalltalk"
},
{
"comment": "Fake reserved word -> main Smalltalk messages",
"match": "(?<!\\.)\\b(ensure|resume|retry|signal)\\b(?![?!])",
"name": "keyword.control.smalltalk"
},
{
"comment": "Fake conditionals. Smalltalk Methods.",
"match": "ifCurtailed:|ifTrue:|ifFalse:|whileFalse:|whileTrue:",
"name": "keyword.control.conditionals.smalltalk"
},
{
"captures": {
"1": {
"name": "entity.other.inherited-class.smalltalk"
},
"3": {
"name": "keyword.control.smalltalk"
},
"4": {
"name": "entity.name.type.class.smalltalk"
}
},
"match": "(\\w+)(\\s+(subclass:))\\s*(\\w*)",
"name": "meta.class.smalltalk"
},
{
"begin": "\"",
"beginCaptures": [
{
"name": "punctuation.definition.comment.begin.smalltalk"
}
],
"end": "\"",
"endCaptures": [
{
"name": "punctuation.definition.comment.end.smalltalk"
}
],
"name": "comment.block.smalltalk"
},
{
"match": "\\b(true|false)\\b",
"name": "constant.language.boolean.smalltalk"
},
{
"match": "\\b(nil)\\b",
"name": "constant.language.nil.smalltalk"
},
{
"captures": {
"1": {
"name": "punctuation.definition.constant.smalltalk"
}
},
"comment": "messages/methods",
"match": "(?>[a-zA-Z_]\\w*(?>[?!])?)(:)(?!:)",
"name": "constant.other.messages.smalltalk"
},
{
"captures": {
"1": {
"name": "punctuation.definition.constant.smalltalk"
}
},
"comment": "symbols",
"match": "(#)[a-zA-Z_][a-zA-Z0-9_:]*",
"name": "constant.other.symbol.smalltalk"
},
{
"begin": "#\\[",
"beginCaptures": [
{
"name": "punctuation.definition.constant.begin.smalltalk"
}
],
"end": "\\]",
"endCaptures": [
{
"name": "punctuation.definition.constant.end.smalltalk"
}
],
"name": "meta.array.byte.smalltalk",
"patterns": [
{
"match": "[0-9]+(r[a-zA-Z0-9]+)?",
"name": "constant.numeric.integer.smalltalk"
},
{
"match": "[^\\s\\]]+",
"name": "invalid.illegal.character-not-allowed-here.smalltalk"
}
]
},
{
"begin": "#\\(",
"beginCaptures": [
{
"name": "punctuation.definition.constant.begin.smalltalk"
}
],
"comment": "Array Constructor",
"end": "\\)",
"endCaptures": [
{
"name": "punctuation.definition.constant.end.smalltalk"
}
],
"name": "constant.other.array.smalltalk"
},
{
"begin": "'",
"beginCaptures": [
{
"name": "punctuation.definition.string.begin.smalltalk"
}
],
"end": "'",
"endCaptures": [
{
"name": "punctuation.definition.string.end.smalltalk"
}
],
"name": "string.quoted.single.smalltalk"
},
{
"match": "\\b[A-Z]\\w*\\b",
"name": "variable.other.constant.smalltalk"
}
],
"repository": {
"numeric": {
"patterns": [
{
"match": "(?<!\\w)[0-9]+\\.[0-9]+s[0-9]*",
"name": "constant.numeric.float.scaled.smalltalk"
},
{
"match": "(?<!\\w)[0-9]+\\.[0-9]+([edq]-?[0-9]+)?",
"name": "constant.numeric.float.smalltalk"
},
{
"match": "(?<!\\w)-?[0-9]+r[a-zA-Z0-9]+",
"name": "constant.numeric.integer.radix.smalltalk"
},
{
"match": "(?<!\\w)-?[0-9]+([edq]-?[0-9]+)?",
"name": "constant.numeric.integer.smalltalk"
}
]
}
},
"scopeName": "source.smalltalk",
"uuid": "1ED64A34-BCB1-44E1-A0FE-84053003E232"
}
14 changes: 10 additions & 4 deletions src/renderer/components/editor/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,10 @@ export const languages: LanguageOption[] = [
scopeName: 'text.slim'
},
{
name: 'Solidity',
value: 'solidity',
grammar: () => import('./grammars/solidity.tmLanguage.json'),
scopeName: 'source.solidity'
name: 'Smalltalk',
value: 'smalltalk',
grammar: () => import('./grammars/smalltalk.tmLanguage.json'),
scopeName: 'source.smalltalk'
},
{
name: 'Smarty',
Expand All @@ -797,6 +797,12 @@ export const languages: LanguageOption[] = [
grammar: () => import('./grammars/smithy.tmLanguage.json'),
scopeName: 'source.smithy'
},
{
name: 'Solidity',
value: 'solidity',
grammar: () => import('./grammars/solidity.tmLanguage.json'),
scopeName: 'source.solidity'
},
{
name: 'Soy Template',
value: 'soy_template',
Expand Down
1 change: 1 addition & 0 deletions src/shared/types/renderer/editor/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export type Language =
| 'sh'
| 'sjs'
| 'slim'
| 'smalltalk'
| 'smarty'
| 'smithy'
| 'solidity'
Expand Down