Skip to content

Commit

Permalink
Add FSL grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
macmv committed Sep 7, 2023
1 parent c8b9742 commit 809e0f2
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 0 deletions.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,28 @@
"light": "./icons/fauna.svg",
"dark": "./icons/fauna-light.svg"
}
},
{
"id": "fsl",
"extensions": [
".fsl"
],
"icon": {
"light": "./icons/fauna.svg",
"dark": "./icons/fauna-light.svg"
}
}
],
"grammars": [
{
"language": "fql",
"scopeName": "source.fql",
"path": "./syntax/fql.tmGrammar.json"
},
{
"language": "fsl",
"scopeName": "source.fsl",
"path": "./syntax/fsl.tmGrammar.json"
}
],
"keybindings": [
Expand Down
155 changes: 155 additions & 0 deletions syntax/fsl.tmGrammar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"name": "fsl",
"scopeName": "source.fsl",
"patterns": [
{
"comment": "Single-line comment",
"name": "comment.line.double-slash.fsl",
"begin": "//",
"end": "$"
},
{
"include": "#block_comment"
},
{
"comment": "Function body",
"name": "constant.function.fsl",
"begin": "\\b(function)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([\\S\\s]*\\)\\s*(:[\\S\\s]*)?\\s*{",
"end": "}",
"captures": {
"1": {
"name": "keyword.control.fsl"
},
"2": {
"name": "entity.name.function.fsl"
}
},
"patterns": [
{
"include": "source.fql"
}
]
},
{
"comment": "Schema block",
"name": "constant.block.fsl",
"match": "\\b(collection|role|index|privileges|membership|(access\\s+provider))\\b(\\s+[a-zA-Z_][a-zA-Z0-9_]*)?",
"captures": {
"1": {
"name": "keyword.control.fsl"
},
"3": {
"name": "entity.name.type.fsl"
}
}
},
{
"comment": "Keyword",
"name": "keyword.control.fsl",
"match": "\\b(collection|function|role|access|provider|index|privileges|membership)\\b"
},
{
"comment": "Action keyword",
"name": "variable.other.constant.property",
"match": "\\b(create|delete|read|write|call|history_read|history_write|unrestricted_read)\\b"
},
{
"comment": "Field keyword",
"name": "variable.other.property",
"match": "\\b(terms|values|unique|predicate|history_days|ttl_days|issuer|jwks_uri)\\b"
},
{
"include": "#single_string_literal"
},
{
"include": "#double_string_literal"
},
{
"comment": "Floating point literal (fraction)",
"name": "constant.numeric.float.fsl",
"match": "\\b[+-]?[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9][0-9_]*)?\\b"
},
{
"comment": "Floating point literal (exponent)",
"name": "constant.numeric.float.fsl",
"match": "\\b[+-]?[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9][0-9_]*\\b"
},
{
"comment": "Integer literal (decimal)",
"name": "constant.numeric.integer.decimal.fsl",
"match": "\\b[+-]?[0-9][0-9_]*\\b"
},
{
"comment": "Integer literal (hexadecimal)",
"name": "constant.numeric.integer.hexadecimal.fsl",
"match": "\\b[+-]?0[xX][0-9a-fA-F_]+\\b"
},
{
"comment": "Integer literal (octal)",
"name": "constant.numeric.integer.octal.fsl",
"match": "\\b[+-]?0[oO][0-7_]+\\b"
},
{
"comment": "Integer literal (binary)",
"name": "constant.numeric.integer.binary.fsl",
"match": "\\b[+-]?0[bB][01_]+\\b"
},
{
"comment": "Boolean constant",
"name": "constant.language.boolean.fsl",
"match": "\\b(true|false)\\b"
},
{
"comment": "Null constant",
"name": "constant.language.null.fsl",
"match": "\\bnull\\b"
}
],
"repository": {
"block_comment": {
"comment": "Block comment",
"name": "comment.block.fsl",
"begin": "/\\*",
"end": "\\*/",
"patterns": [
{
"include": "#block_comment"
}
]
},
"escaped_character": {
"name": "constant.character.escape.fsl",
"match": "\\\\([\\\\0'\"`nrvtbf#]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{2}|u\\{[01]0[0-9a-fA-F]{0,4}\\}|u\\{[0-9a-fA-F]{1,4}\\})"
},
"interpolated_value": {
"name": "constant.character.escape.fsl",
"begin": "#{",
"end": "}"
},
"single_string_literal": {
"comment": "String literal (single quotes)",
"name": "string.quoted.single.fsl",
"begin": "'",
"end": "'",
"patterns": [
{
"include": "#escaped_character"
}
]
},
"double_string_literal": {
"comment": "String literal (double quotes)",
"name": "string.quoted.double.fsl",
"begin": "\"",
"end": "\"",
"patterns": [
{
"include": "#escaped_character"
},
{
"include": "#interpolated_value"
}
]
}
}
}

0 comments on commit 809e0f2

Please sign in to comment.