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 sas
  • Loading branch information
antonreshetov committed Aug 5, 2022
commit bfb09995e6b7bb2ffcc52779e3ba4a76322d9326
20 changes: 19 additions & 1 deletion demo/db/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2782,7 +2782,25 @@
],
"id": "n2cZYWla",
"createdAt": 1659674577829,
"updatedAt": 1659676092104
"updatedAt": 1659685133678
},
{
"isDeleted": false,
"isFavorites": false,
"folderId": "J7rNZi7X",
"tagsIds": [],
"description": null,
"name": "SAS",
"content": [
{
"label": "Fragment 1",
"language": "sas",
"value": "*** Some comments;\nproc sort data=preTest;\n by student_ID;\nrun;\nproc sort data=postTest;\n by student_ID;\nrun;\ndata testGroup;\n merge preTest(in=a rename=(score=pre)) \n postTest(in=b rename=(score=post));\n by student_ID;\n if a and b;\n difference=post-pre;\nrun;\nTitle \"Student's T test of difference\"; \nproc means data=testGroup n mean stddev stderr t prt;\n by student_ID;\n var difference;\nrun;"
}
],
"id": "ZbWrvEHT",
"createdAt": 1659686186866,
"updatedAt": 1659686553849
}
],
"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 @@ -123,6 +123,7 @@ This is a list of language that supports in massCode.
- RST
- Ruby
- Rust
- SAS
- SASS
- SCAD
- Scala
Expand Down
306 changes: 306 additions & 0 deletions src/renderer/components/editor/grammars/sas.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"name": "sas",
"patterns": [
{
"include": "#comments"
},
{
"captures": {
"1": {
"name": "support.function.sas"
},
"2": {
"name": "entity.name.function.sas"
}
},
"match": "(?i:(proc) (\\w+))"
},
{
"captures": {
"1": {
"name": "support.function.sas"
},
"2": {
"name": "constant.other.table-name.sas"
}
},
"match": "(?i:^(data) ([^\\s]+))"
},
{
"captures": {
"1": {
"name": "entity.other.attribute-name.sas"
},
"2": {
"name": "constant.other.library-name.sas"
},
"3": {
"name": "constant.other.table-name.sas"
}
},
"match": "(?i:\\b(data|out)=(\\w+\\.)?(\\w*)\\b)"
},
{
"match": "(?i:\\bsort|run|quit|output\\b)",
"name": "support.function.sas"
},
{
"match": "\\b\\d+(\\.\\d+)*\\b",
"name": "constant.numeric.sas"
},
{
"match": "\\blow|high\\b",
"name": "constant.sas"
},
{
"captures": {
"1": {
"name": "keyword.other.sas"
},
"2": {
"name": "variable.other.sas"
}
},
"match": "(?i:\\b(by) ([^\\s]+)\\b)"
},
{
"captures": {
"1": {
"name": "keyword.other.sas"
},
"2": {
"name": "variable.other.sas"
}
},
"match": "(?i:(keep|drop|retain|format|class|var) ([\\w\\s]+))"
},
{
"captures": {
"1": {
"name": "keyword.other.sas"
},
"2": {
"name": "constant.other.table-name.sas"
}
},
"match": "(?i:\\b(set|tables|merge) ([\\w\\s]+)\\b)"
},
{
"match": "\\b(if|else|then|end)\\b",
"name": "keyword.control.sas"
},
{
"match": "(?i)\\b(descending)\\b",
"name": "keyword.other.order.sas"
},
{
"match": "(?i)\\b(title)\\b",
"name": "keyword.other.sas"
},
{
"match": "\\*",
"name": "keyword.operator.star.sas"
},
{
"match": "\\b<|>|eq|ne\\b",
"name": "keyword.operator.comparison.sas"
},
{
"match": " \\. ",
"name": "keyword.null.sas"
},
{
"match": "-|\\+|/",
"name": "keyword.operator.math.sas"
},
{
"match": "(?i)\\b(avg|sum)(?=\\s*\\()",
"name": "support.function.aggregate.sas"
},
{
"captures": {
"1": {
"name": "constant.other.library-name.sas"
},
"2": {
"name": "constant.other.table-name.sas"
}
},
"match": "(\\w+?)\\.(\\w+)"
},
{
"begin": "proc sas;",
"end": "quit;",
"patterns": [
{
"include": "source.sas"
}
]
},
{
"include": "#strings"
}
],
"repository": {
"comments": {
"patterns": [
{
"captures": {
"1": {
"name": "punctuation.definition.comment.sas"
}
},
"match": "^\\s*(\\*).*;\\s*$\\n?",
"name": "comment.line.asterisk.sas"
},
{
"begin": "/\\*",
"captures": {
"0": {
"name": "punctuation.definition.comment.sas"
}
},
"end": "\\*/",
"name": "comment.block.c"
}
]
},
"string_escape": {
"match": "\\\\.",
"name": "constant.character.escape.sas"
},
"string_interpolation": {
"captures": {
"1": {
"name": "punctuation.definition.string.end.sas"
}
},
"match": "(#\\{)([^\\}]*)(\\})",
"name": "string.interpolated.sas"
},
"strings": {
"patterns": [
{
"captures": {
"1": {
"name": "punctuation.definition.string.begin.sas"
},
"3": {
"name": "punctuation.definition.string.end.sas"
}
},
"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and sas files tend to have very long lines.",
"match": "(')[^'\\\\]*(')",
"name": "string.quoted.single.sas"
},
{
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.sas"
}
},
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.sas"
}
},
"name": "string.quoted.single.sas",
"patterns": [
{
"include": "#string_escape"
}
]
},
{
"captures": {
"1": {
"name": "punctuation.definition.string.begin.sas"
},
"3": {
"name": "punctuation.definition.string.end.sas"
}
},
"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and sas files tend to have very long lines.",
"match": "(`)[^`\\\\]*(`)",
"name": "string.quoted.other.backtick.sas"
},
{
"begin": "`",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.sas"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.sas"
}
},
"name": "string.quoted.other.backtick.sas",
"patterns": [
{
"include": "#string_escape"
}
]
},
{
"captures": {
"1": {
"name": "punctuation.definition.string.begin.sas"
},
"3": {
"name": "punctuation.definition.string.end.sas"
}
},
"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and sas files tend to have very long lines.",
"match": "(\")[^\"#]*(\")",
"name": "string.quoted.double.sas"
},
{
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.sas"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.sas"
}
},
"name": "string.quoted.double.sas",
"patterns": [
{
"include": "#string_interpolation"
}
]
},
{
"begin": "%\\{",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.sas"
}
},
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.sas"
}
},
"name": "string.other.quoted.brackets.sas",
"patterns": [
{
"include": "#string_interpolation"
}
]
}
]
}
},
"scopeName": "source.sas"
}
6 changes: 6 additions & 0 deletions src/renderer/components/editor/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,12 @@ export const languages: LanguageOption[] = [
grammar: () => import('./grammars/rust.tmLanguage.json'),
scopeName: 'source.rust'
},
{
name: 'SAS',
value: 'sas',
grammar: () => import('./grammars/sas.tmLanguage.json'),
scopeName: 'source.sas'
},
{
name: 'SASS',
value: 'sass',
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 @@ -137,6 +137,7 @@ export type Language =
| 'rst'
| 'ruby'
| 'rust'
| 'sas'
| 'sass'
| 'sassdoc'
| 'scad'
Expand Down