dymokomi/luced
Source of release 0.4.1
0.4.1 / src / language / default_grammars.luc
## Generated by tools/grammars.py — do not edit. The grammars shipped with luced,
## written into the config directory on first run so highlighting works out of the box.
from luce_std import files
import workspace.paths as paths
func write_default(directory: str, name: str, content: str) -> unit!:
files.create_text(paths.join(directory, name), content) catch failure:
if failure.code != files.already_exists:
error(failure.code, failure.message)
## Write each bundled grammar into `directory`, keeping any file the user already has.
pub func seed(directory: str) -> unit!:
write_default(directory, "luce.tmLanguage.json", "{\n \"name\": \"Luce\",\n \"scopeName\": \"source.luce\",\n \"fileTypes\": [\"luc\", \"lucb\"],\n \"patterns\": [\n { \"include\": \"#comment\" },\n { \"include\": \"#string\" },\n { \"include\": \"#number\" },\n { \"include\": \"#constant\" },\n { \"include\": \"#keyword\" },\n { \"include\": \"#builtin-type\" },\n { \"include\": \"#type-name\" },\n { \"include\": \"#function-call\" }\n ],\n \"repository\": {\n \"comment\": {\n \"patterns\": [\n { \"match\": \"^\\\\s*#\\\\s*mark:.*$\", \"name\": \"comment.section.luce\" },\n { \"match\": \"#.*$\", \"name\": \"comment.line.number-sign.luce\" }\n ]\n },\n \"string\": {\n \"patterns\": [\n {\n \"begin\": \"[rbf]?\\\"\\\"\\\"\",\n \"end\": \"\\\"\\\"\\\"\",\n \"name\": \"string.quoted.triple.double.luce\",\n \"patterns\": [{ \"match\": \"\\\\\\\\.\" , \"name\": \"constant.character.escape.luce\" }]\n },\n {\n \"begin\": \"[rbf]?'''\",\n \"end\": \"'''\",\n \"name\": \"string.quoted.triple.single.luce\",\n \"patterns\": [{ \"match\": \"\\\\\\\\.\", \"name\": \"constant.character.escape.luce\" }]\n },\n {\n \"begin\": \"[rbf]?\\\"\",\n \"end\": \"\\\"\",\n \"name\": \"string.quoted.double.luce\",\n \"patterns\": [{ \"match\": \"\\\\\\\\.\", \"name\": \"constant.character.escape.luce\" }]\n },\n {\n \"begin\": \"[rbf]?'\",\n \"end\": \"'\",\n \"name\": \"string.quoted.single.luce\",\n \"patterns\": [{ \"match\": \"\\\\\\\\.\", \"name\": \"constant.character.escape.luce\" }]\n }\n ]\n },\n \"number\": {\n \"match\": \"\\\\b(0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+|[0-9][0-9_]*(\\\\.[0-9_]+)?([eE][+-]?[0-9]+)?)\\\\b\",\n \"name\": \"constant.numeric.luce\"\n },\n \"constant\": {\n \"match\": \"\\\\b(true|false|none)\\\\b\",\n \"name\": \"constant.language.luce\"\n },\n \"keyword\": {\n \"match\": \"\\\\b(and|as|break|catch|class|const|continue|defer|elif|else|enum|errdefer|extern|for|from|func|if|import|in|init|interface|is|let|match|mutating|new|not|or|pub|recover|return|self|spawn|static|struct|test|try|type|var|wait|while|with|alloc|free|discard)\\\\b\",\n \"name\": \"keyword.control.luce\"\n },\n \"builtin-type\": {\n \"match\": \"\\\\b(int|float|bool|str|bytes|unit|never|list|map|set|Error|ErrorCode|Weak|task|char|i8|i16|i32|i64|u8|u16|u32|u64|usize|isize|f32|f64|void)\\\\b\",\n \"name\": \"storage.type.luce\"\n },\n \"type-name\": {\n \"match\": \"\\\\b[A-Z][A-Za-z0-9_]*\\\\b\",\n \"name\": \"entity.name.type.luce\"\n },\n \"function-call\": {\n \"match\": \"\\\\b([a-z_][A-Za-z0-9_]*)\\\\s*(?=\\\\()\",\n \"name\": \"entity.name.function.luce\"\n }\n }\n}\n")
write_default(directory, "prism.tmLanguage.json", "{\n \"name\": \"Prism\",\n \"scopeName\": \"source.prism\",\n \"fileTypes\": [\"prisma\"],\n \"patterns\": [\n { \"include\": \"#directive\" },\n { \"include\": \"#comment\" },\n { \"include\": \"#string\" },\n { \"include\": \"#char\" },\n { \"include\": \"#keyword\" },\n { \"include\": \"#dtype\" },\n { \"include\": \"#constant\" },\n { \"include\": \"#reference-path\" },\n { \"include\": \"#number\" }\n ],\n \"repository\": {\n \"directive\": {\n \"match\": \"^\\\\s*#prisma\\\\b.*$\",\n \"name\": \"keyword.control.directive.prism\"\n },\n \"comment\": {\n \"match\": \"#.*$\",\n \"name\": \"comment.line.number-sign.prism\"\n },\n \"string\": {\n \"begin\": \"\\\"\",\n \"end\": \"\\\"\",\n \"name\": \"string.quoted.double.prism\",\n \"patterns\": [{ \"match\": \"\\\\\\\\.\", \"name\": \"constant.character.escape.prism\" }]\n },\n \"char\": {\n \"match\": \"'(\\\\\\\\.|[^'])'\",\n \"name\": \"string.quoted.single.prism\"\n },\n \"keyword\": {\n \"match\": \"\\\\b(def|over|reference|connect|disconnect|unset|delete|reorder|string)\\\\b\",\n \"name\": \"keyword.control.prism\"\n },\n \"dtype\": {\n \"match\": \"\\\\b(bool|char|int8|int16|int32|int64|uint8|uint16|uint32|uint64|float16|float32|float64|float|float2|float3|float4|str|matrix|vec2f|vec3f|vec4f|token|asset)\\\\b\",\n \"name\": \"storage.type.prism\"\n },\n \"constant\": {\n \"match\": \"\\\\b(true|false)\\\\b\",\n \"name\": \"constant.language.prism\"\n },\n \"reference-path\": {\n \"match\": \"<[^>\\\\n]*>\",\n \"name\": \"variable.other.reference.prism\"\n },\n \"number\": {\n \"match\": \"-?\\\\b(0[xX][0-9a-fA-F]+|[0-9]+(\\\\.[0-9]+)?([eE][+-]?[0-9]+)?)\\\\b\",\n \"name\": \"constant.numeric.prism\"\n }\n }\n}\n")
write_default(directory, "index.json", "{\"extensions\":{\"luc\":\"luce.tmLanguage.json\",\"lucb\":\"luce.tmLanguage.json\",\"prisma\":\"prism.tmLanguage.json\"},\"scopes\":{\"source.luce\":\"luce.tmLanguage.json\",\"source.prism\":\"prism.tmLanguage.json\"}}\n")