diff --git a/.vscodeignore b/.vscodeignore index 8afec3c..bd4e302 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,6 +1,6 @@ # Directories .vscode -examples +test # Files .gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf3a42..927ee15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,23 @@ -# Change Log +# Changelog -All notable changes to the "laye-vscode" extension will be documented in this file. +## v0.1.2 -## [Unreleased] +### Additions -- Initial release \ No newline at end of file +* `@see` and `@deprecated` annotation in doc-comments +* `tokens.laye` example + +### Changes + +* Adapted *new* `laye` syntax +* Refactored grammar for more readability and faster parsing +* Reduced file sizes +* Renamed `examples` to `test` + +## v0.1.1 + +Bug fixes + +## v0.1.0 + +Initial release \ No newline at end of file diff --git a/README.md b/README.md index 2899f7b..38bafb5 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,12 @@ Find on [GitHub](https://github.com/laye-lang/laye-vscode) or [Local's Personal Laye is a programming language designed to be used alongside C. Where many languages aim to be a C replacement, Laye instead wants to co-exist in its own unique manner. This relationship is so important that the Laye compiler, `layec`, is also a C compiler. -## Features - -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. - -For example if there is an image subfolder under your extension project workspace: - -\!\[feature X\]\(images/feature-x.png\) - -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. - - +* Basic syntax highlighting +* Icons for `.laye` files ## Contributing diff --git a/examples/bootloader.laye b/examples/bootloader.laye deleted file mode 100644 index cf660a9..0000000 --- a/examples/bootloader.laye +++ /dev/null @@ -1,116 +0,0 @@ -import * from "efi.h"; -import * from "efilib.h"; -import * from "elf.h"; - -alias kernel_start_function = callconv(sysv) i32(); - -i32 memcmp(readonly rawptr a, rawptr b, uint n) -{ - var a_ = cast(u8[*]) a; - var b_ = cast(u8[*]) b; - - for (uint i = 0; i < n; i++) - { - if (a_[i] < b_[i]) return -1; - if (a_[i] > b_[i]) return 1; - } - - return 0; -} - -EFI_FILE*? load_file(EFI_FILE* directory, CHAR16[*] path, - EFI_HANDLE image_handle, EFI_SYSTEM_TABLE* system_table) -{ - EFI_FILE*? loaded_file; - - EFI_LOADED_IMAGE_PROTOCOL*? loaded_image; - system_table->BootServices->HandleProtocol(image_handle, - &gEfiLoadedImageProtocolGuid, &loaded_image); - - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL*? file_system; - system_table->BootServices->HandleProtocol(loaded_image->DeviceHandle, - &gEfiSimpleFileSystemProtocolGuid, &file_system); - - if (directory is nil) - file_system->OpenVolume(file_system, &directory); - - var status = directory->Open(directory, &loaded_file, path, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY); - if (status != EFI_SUCCESS) return nil; - - return loaded_file; -} - -EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) { - InitializeLib(image_handle, system_table); - - var kernel_file = load_file(nil, "kernel.elf", image_handle, system_table); - if (kernel_file is nil) - { - Print("Could not load kernel.elf\n\r"); - return EFI_ABORTED; - } - - Print("Successfully loaded kernel.elf\n\r"); - - Elf64_Ehdr kernel_header; - { - UINTN file_info_size; - EFI_FILE_INFO*? file_info; - kernel_file->GetInfo(kernel_file, &gEfiFileInfoGuid, &file_info_size, nil); - system_table->BootServices->AllocatePool(EfiLoaderData, file_info_size, file_info); - kernel_file->GetInfo(kernel_file, &gEfiFileInfoGuid, &file_info_size, &file_info); - - UINTN kernel_header_size = sizeof(Elf64_Ehdr); - kernel_file->Read(kernel_file, &kernel_header_size, &kernel_header); - } - - bool check_magic = 0 == memcmp(&kernel_header.e_ident[EI_MAG0], ELFMAG, SELFMAG); - bool check_class = kernel_header.e_ident[EI_CLASS] == ELFCLASS64; - bool check_data = kernel_header.e_ident[EI_DATA] == ELFDATA2LSB; - bool check_type = kernel_header.e_type == ET_EXEC; - bool check_machine = kernel_header.e_machine == EM_X86_64; - bool check_version = kernel_header.e_version == EV_CURRENT; - - if (not check_magic or not check_class or not check_data or - not check_type or not check_machine or not check_version) - { - Print("kernel.elf format is bad\n\r"); - return EFI_ABORTED; - } - - Print("kernel.elf format successfully verified\n\r"); - - Elf64_Phdr[*] program_headers; - { - kernel_file->SetPosition(kernel_file, kernel_header.e_phoff); - var program_header_size = kernel_header.e_phnum * kernel_header.e_phentsize; - system_table->BootServices->AllocatePool(EfiLoaderData, program_header_size, (void**)&program_headers); - kernel_file->Read(kernel_file, &program_header_size, program_headers); - } - - for (int i = 0; i < kernel_header.e_phnum; i++) - { - var program_header = cast(Elf64_Phdr*) (cast(rawptr) program_header + i * kernel_header.e_phentsize); - switch (program_header->p_type) - { - case PT_LOAD: - { - int page_count = (program_header->p_memsz + 16#1000 - 1) / 16#1000; - var segment = program_header->p_paddr; - system_table->BootServices->AllocatePages(AllocateAddress, EfiLoaderData, page_count, &segment); - kernel_file->SetPosition(kernel_file, program_header->p_offset); - var program_header_file_size = program_header->p_filesz; - kernel_file->Read(kernel_file, &program_header_file_size, cast(rawptr) segment); - } break; - } - } - - Print("kernel.elf loaded\n\r"); - - var kernel_start = cast(kernel_start_function) kernel_header.e_entry; - int kernel_result = kernel_start(); - - Print("%d\n\r", kernel_result); - - return EFI_SUCCESS; -} diff --git a/language-configuration.json b/language-configuration.json index 11d8a2c..50dadf7 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -12,7 +12,7 @@ { "open": "/*", "close": "*/", - "notIn": [ "string", "comment" ] + "notIn": [ "string" ] }, { "open": "'", @@ -35,19 +35,7 @@ [ "\"", "\"" ], [ "(", ")" ], [ "[", "]" ], - [ "{", "}" ] - ], - "autoCloseBefore": "=?; \t\n", - "folding": { - "offSide": true, - "markers": { - "start": "(\\(|\\[|\\{)", - "end": "(\\)|\\]|\\})" - } - }, - "wordPattern": "\\b[a-zA-Z0-9_]+\\b", - "indentationRules": { - "increaseIndentPattern": "(?=[\\(\\[\\{]).\\s*$", - "decreaseIndentPattern": "(?" ] + ] } \ No newline at end of file diff --git a/package.json b/package.json index 1d56927..e1eac46 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Laye support for Visual Studio Code", "publisher": "laye-lang", "license": "MIT", - "version": "0.1.1", + "version": "0.1.2", "icon": "images/icon.png", "repository": { "type": "git", diff --git a/syntax/laye.tmLanguage.json b/syntax/laye.tmLanguage.json index f0e3857..264dd8e 100644 --- a/syntax/laye.tmLanguage.json +++ b/syntax/laye.tmLanguage.json @@ -1,290 +1,161 @@ { - "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "Laye", "patterns": [ - { "include": "#comment.block" }, - { "include": "#comment.line" }, - { "include": "#keyword.directive" }, - { "include": "#storage.modifier" }, - { "include": "#storage.type" }, - { "include": "#storage" }, - { "include": "#keyword.control.conditional" }, - { "include": "#keyword.control.loop" }, - { "include": "#keyword.control.flow" }, - { "include": "#keyword.control" }, - { "include": "#keyword.operator.assignment.logical" }, - { "include": "#keyword.operator.assignment.arithmetic" }, - { "include": "#keyword.operator.accessor" }, - { "include": "#keyword.operator.logical" }, - { "include": "#keyword.operator.arithmetic" }, - { "include": "#keyword.operator.relational" }, - { "include": "#keyword.operator" }, - { "include": "#constant.language.boolean" }, - { "include": "#constant.language" }, - { "include": "#string.quoted.single" }, - { "include": "#string.quoted.double" }, - { "include": "#punctuation.definition" }, - { "include": "#punctuation.separator" }, - { "include": "#constant.numeric" }, - { "include": "#entity.name.scope-resolution" }, - { "include": "#entity.name.type" }, - { "include": "#entity.name.function" }, - { "include": "#variable.other.constant" }, - { "include": "#variable" }, - { "include": "#invalid.illegal" } + { "include": "#punctuation" }, + { "include": "#comment" }, + { "include": "#keyword" }, + { "include": "#operator" }, + { "include": "#number" }, + { "include": "#string" }, + { "include": "#namespace" }, + { "include": "#type" }, + { "include": "#function" }, + { "include": "#variable.readonly" }, + { "include": "#variable" } ], "repository": { - "comment.block": { - "name": "comment.block.laye", - "begin": "/\\*", - "end": "\\*/", + "punctuation": { + "name": "punctuation.laye", + "match": "::|[(),.:;\\[\\]{}]|<(?=[\\s,0-9A-Z_a-z]*>)|(?<=<[\\s,0-9A-Z_a-z]*)>" + }, + "comment": { "patterns": [ - { "include": "#comment.block" }, - { "include": "#meta.embedded" }, { - "name": "keyword.laye", - "match": "@(?:author|param|return|since)\\b" + "name": "comment.laye", + "begin": "/\\*", + "end": "\\*/", + "patterns": [ + { + "begin": "/\\*", + "end": "\\*/" + }, + { + "match": "\\\\`" + }, + { + "name": "meta.embedded.laye", + "begin": "`", + "end": "`", + "patterns": [ + { "include": "$self" } + ] + }, + { + "name": "keyword.laye", + "match": "@(?:author|deprecated|param|return|see|since)\\b" + }, + { + "name": "variable.other.constant.laye", + "match": "(?<=@author\\s+)[\\-.0-9A-Z_a-z]+\\b" + }, + { + "name": "variable.parameter.laye", + "match": "(?<=@param\\s+[0-9A-Z_a-z]+\\s*(?:<[\\s,0-9A-Z_a-z]*>\\s*)?)[0-9A-Z_a-z]+\\b" + }, + { + "name": "entity.name.type.laye", + "match": "(?<=@(?:param|return)\\s+(?:[0-9A-Z_a-z]+\\s*<(?:[\\s,0-9A-Z_a-z]+,)?\\s*)?)[0-9A-Z_a-z]+\\b" + }, + { + "name": "constant.numeric.laye", + "match": "(?<=@since\\s+)[\\-.0-9A-Z_a-z]+\\b" + } + ] }, - { "include": "#comment.documentation.author" }, - { "include": "#comment.documentation.param" }, - { "include": "#comment.documentation.return" }, - { "include": "#comment.documentation.since" } + { + "name": "comment.laye", + "match": "//.*" + } ] }, - "comment.line": { - "name": "comment.line.double-slash.laye", - "begin": "//", - "end": "\\n", + "keyword": { "patterns": [ - { "include": "#meta.embedded" }, { "name": "keyword.laye", - "match": "@author\\b" + "match": "\\b(?:alias|alignof|and|as|break|c(?:ast|atch|allconv|ase|onst|ontinue)|default|defer|delete|do|else|enum|export|for|foreign|from|goto|if|import|inline|mut|new|nodiscard|not|offsetof|operator|or|return|sizeof|struct|switch|test|try|varargs|variant|xor|xyzzy)\\b" }, - { "include": "#comment.documentation.author" } + { + "name": "constant.language.laye", + "match": "\\b(?:false|global|nil|true)\\b" + }, + { + "name": "storage.type.laye", + "match": "\\b(?:bool|[biu]\\d+|f(?:loat|16|32|64|80|128)|int|noreturn|uint|var|void)\\b" + } ] }, - "keyword.directive": { - "name": "keyword.directive.laye", - "match": "\\b(?:import|export|from|as)\\b" - }, - "storage.modifier": { - "name": "storage.modifier.laye", - "match": "\\b(?:const|inline|mut)\\b" - }, - "storage.type": { - "name": "storage.type.laye", - "match": "\\b(?:var|void|noreturn|rawptr|bool|b\\d+|int|i\\d+|uint|u\\d+|float|f16|f32|f64|f80|f128|struct|variant|enum|alias|error)\\b" - }, - "storage": { - "name": "storage.laye", - "match": "\\b(?:varargs|foreign|callconv|test)\\b" - }, - "keyword.control.conditional": { - "name": "keyword.control.conditional.laye", - "match": "\\b(?:if|else|switch|case|default)\\b" - }, - "keyword.control.loop": { - "name": "keyword.control.loop.laye", - "match": "\\b(?:for|do)\\b" - }, - "keyword.control.flow": { - "name": "keyword.control.flow.laye", - "match": "\\b(?:return|break|continue|defer|goto)\\b" - }, - "keyword.control": { - "name": "keyword.control.laye", - "match": "\\b(?:new|delete|cast|try|catch|discard|sizeof|alignof|offsetof|not|and|or|xor|is|assert)\\b" - }, - "keyword.operator.assignment.logical": { - "name": "keyword.operator.assignment.logical.laye", - "match": "&=|\\|=|~=|<<=|>>=" - }, - "keyword.operator.assignment.arithmetic": { - "name": "keyword.operator.assignment.arithmetic.laye", - "match": "\\+=|-=|\\*=|/=|%=" - }, - "keyword.operator.accessor": { - "name": "keyword.operator.accessor.laye", - "match": "->" - }, - "keyword.operator.logical": { - "name": "keyword.operator.logical.laye", - "match": "<<|>>|\\+\\+|--|[&|~]" - }, - "keyword.operator.arithmetic": { - "name": "keyword.operator.arithmetic.laye", - "match": "[+\\-*/%]" - }, - "keyword.operator.relational": { - "name": "keyword.operator.relational.laye", - "match": "==|!=|<=|>=|[<>]" - }, - "keyword.operator": { + "operator": { "name": "keyword.operator.laye", - "match": "=>|[=?]" - }, - "constant.language.boolean": { - "name": "constant.language.boolean.laye", - "match": "\\b(?:true|false)\\b" + "match": "\\?|=>|(?:<<|>>|[!%&*+\\-/<=>|~])=?" }, - "constant.language": { - "name": "constant.language.laye", - "match": "\\b(?:nil|global)\\b" + "number": { + "name": "constant.numeric.laye", + "match": "\\b(?:1(?:0#(?:[0-9]+_)*[0-9]+|1#(?:[0-9aA]+_)*[0-9aA]+|2#(?:[0-9abAB]+_)*[0-9a-bA-B]+|3#(?:[0-9a-cA-C]+_)*[0-9a-cA-C]+|4#(?:[0-9a-dA-D]+_)*[0-9a-dA-D]+|5#(?:[0-9a-eA-E]+_)*[0-9a-eA-E]+|6#(?:[0-9a-fA-F]+_)*[0-9a-fA-F]+|7#(?:[0-9a-gA-G]+_)*[0-9a-gA-G]+|8#(?:[0-9a-hA-H]+_)*[0-9a-hA-H]+|9#(?:[0-9a-iA-I]+_)*[0-9a-iA-I]+)|2(?:#(?:[01]+_)*[01]+|0#(?:[0-9a-jA-J]+_)*[0-9a-jA-J]+|1#(?:[0-9a-kA-K]+_)*[0-9a-kA-K]+|2#(?:[0-9a-lA-L]+_)*[0-9a-lA-L]+|3#(?:[0-9a-mA-M]+_)*[0-9a-mA-M]+|4#(?:[0-9a-nA-N]+_)*[0-9a-nA-N]+|5#(?:[0-9a-oA-O]+_)*[0-9a-oA-O]+|6#(?:[0-9a-pA-P]+_)*[0-9a-pA-P]+|7#(?:[0-9a-qA-Q]+_)*[0-9a-qA-Q]+|8#(?:[0-9a-rA-R]+_)*[0-9a-rA-R]+|9#(?:[0-9a-sA-S]+_)*[0-9a-sA-S]+)|3(?:#(?:[0-2]+_)*[0-2]+|0#(?:[0-9a-tA-T]+_)*[0-9a-tA-T]+|1#(?:[0-9a-uA-U]+_)*[0-9a-uA-U]+|2#(?:[0-9a-vA-V]+_)*[0-9a-vA-V]+|3#(?:[0-9a-wA-W]+_)*[0-9a-wA-W]+|4#(?:[0-9a-xA-X]+_)*[0-9a-xA-X]+|5#(?:[0-9a-yA-Y]+_)*[0-9a-yA-Y]+|6#(?:[0-9a-zA-Z]+_)*[0-9a-zA-Z]+)|4#(?:[0-3]+_)*[0-3]+|5#(?:[0-4]+_)*[0-4]+|6#(?:[0-5]+_)*[0-5]+|7#(?:[0-6]+_)*[0-6]+|8#(?:[0-7]+_)*[0-7]+|9#(?:[0-8]+_)*[0-8]+|(?:\\d+_)*(?:\\d+\\.)?\\d+)\\b" }, - "string.quoted.single": { - "name": "string.quoted.single.laye", - "begin": "'(?=(?:[^' ]|\\\\')*'| ')", - "end": "'", - "patterns": [ - { - "name": "constant.character.escape.laye", - "match": "\\\\'" - }, - { "include": "#escape" } - ] + "escape": { + "name": "constant.character.escape.laye", + "match": "\\\\(?:[\\\\0abefnrtv]|x[0-7][0-9a-fA-F]|o[0-1]?[0-7]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})" }, - "string.quoted.double": { - "name": "string.quoted.double.laye", - "begin": "\"(?=(?:[^\"]|\\\\\")*\")", - "end": "\"", + "string": { "patterns": [ { - "name": "constant.character.escape.laye", - "match": "\\\\\"" - }, - { - "name": "constant.other.placeholder.laye", - "match": "%[\\+#]*\\d*(?:\\.\\d+)?(?:hh|ll|l)?[c-gopsuxEGX%]" + "name": "string.laye", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.laye", + "match": "\\\\\"" + }, + { "include": "#escape" }, + { + "name": "constant.other.placeholder.laye", + "match": "%[\\+#]*\\d*(?:\\.\\d+)?(?:hh|ll|l)?[%EGXc-gopsux]" + }, + { + "name": "invalid.laye", + "match": "[\\\\%]." + } + ] }, { - "name": "invalid.illegal.laye", - "match": "%." - }, - { "include": "#escape" } + "name": "string.laye", + "begin": "'", + "end": "'", + "patterns": [ + { + "name": "constant.character.escape.laye", + "match": "\\\\'" + }, + { "include": "#escape" }, + { + "name": "invalid.laye", + "match": "\\\\." + } + ] + } ] }, - "punctuation.definition": { - "name": "punctuation.definition.laye", - "match": "[\\(\\)\\[\\]\\{\\}]" - }, - "punctuation.separator": { - "name": "punctuation.separator.laye", - "match": "::|[.,:;]" - }, - "constant.numeric": { - "name": "constant.numeric.laye", - "match": "\\b(?:2#(?:(?:[0-1]+_)?[0-1]+)+|3#(?:(?:[0-2]+_)?[0-2]+)+|4#(?:(?:[0-3]+_)?[0-3]+)+|5#(?:(?:[0-4]+_)?[0-4]+)+|6#(?:(?:[0-5]+_)?[0-5]+)+|7#(?:(?:[0-6]+_)?[0-6]+)+|8#(?:(?:[0-7]+_)?[0-7]+)+|9#(?:(?:[0-8]+_)?[0-8]+)+|10#(?:(?:[0-9]+_)?[0-9]+)+|11#(?:(?:[0-9aA]+_)?[0-9aA]+)+|12#(?:(?:[0-9a-bA-B]+_)?[0-9a-bA-B]+)+|13#(?:(?:[0-9a-cA-C]+_)?[0-9a-cA-C]+)+|14#(?:(?:[0-9a-dA-D]+_)?[0-9a-dA-D]+)+|15#(?:(?:[0-9a-eA-E]+_)?[0-9a-eA-E]+)+|16#(?:(?:[0-9a-fA-F]+_)?[0-9a-fA-F]+)+|17#(?:(?:[0-9a-gA-G]+_)?[0-9a-gA-G]+)+|18#(?:(?:[0-9a-hA-H]+_)?[0-9a-hA-H]+)+|19#(?:(?:[0-9a-iA-I]+_)?[0-9a-iA-I]+)+|20#(?:(?:[0-9a-jA-J]+_)?[0-9a-jA-J]+)+|21#(?:(?:[0-9a-kA-K]+_)?[0-9a-kA-K]+)+|22#(?:(?:[0-9a-lA-L]+_)?[0-9a-lA-L]+)+|23#(?:(?:[0-9a-mA-M]+_)?[0-9a-mA-M]+)+|24#(?:(?:[0-9a-nA-N]+_)?[0-9a-nA-N]+)+|25#(?:(?:[0-9a-oA-O]+_)?[0-9a-oA-O]+)+|26#(?:(?:[0-9a-pA-P]+_)?[0-9a-pA-P]+)+|27#(?:(?:[0-9a-qA-Q]+_)?[0-9a-qA-Q]+)+|28#(?:(?:[0-9a-rA-R]+_)?[0-9a-rA-R]+)+|29#(?:(?:[0-9a-sA-S]+_)?[0-9a-sA-S]+)+|30#(?:(?:[0-9a-tA-T]+_)?[0-9a-tA-T]+)+|31#(?:(?:[0-9a-uA-U]+_)?[0-9a-uA-U]+)+|32#(?:(?:[0-9a-vA-V]+_)?[0-9a-vA-V]+)+|33#(?:(?:[0-9a-wA-W]+_)?[0-9a-wA-W]+)+|34#(?:(?:[0-9a-xA-X]+_)?[0-9a-xA-X]+)+|35#(?:(?:[0-9a-yA-Y]+_)?[0-9a-yA-Y]+)+|36#(?:(?:[0-9a-zA-Z]+_)?[0-9a-zA-Z]+)+|(?:(?:\\d+_)?\\d+)+)\\b" - }, - "entity.name.scope-resolution": { - "name": "entity.name.scope-resolution.laye", - "match": "\\b[0-9a-zA-Z_]+(?=\\s*::)|(?<=\\bimport\\b(?:.+?\\bfrom)?\\s+(?:[0-9a-zA-Z_]+\\s*::\\s*)*|\\bas\\s+)[0-9a-zA-Z_]+\\b(?!.+?\\bfrom\\b)" + "namespace": { + "name": "entity.name.namespace.laye", + "match": "\\b[0-9A-Z_a-z]+(?=::)|(?<=\\bimport\\s+(?:[\\s*,0-9A-Z_a-z]+\\sfrom\\s+(?:\"[0-9A-Z_a-z]+\"\\s+as\\s+)?)?)[0-9A-Z_a-z]+\\b" }, - "entity.name.type": { + "type": { "name": "entity.name.type.laye", - "match": "(?<=\\b(?:struct|variant|enum|alias|error)\\s+)[0-9a-zA-Z_]+\\b|\\b[0-9a-zA-Z_]+\\b(?=\\s*(?:(?:mut)?(?:\\s*\\[[0-9a-zA-Z_]+\\])?[\\s*?]*[0-9a-zA-Z_]+\\s*(?:[^0-9a-zA-Z_\\s.\\]\"])|[<|\\{]))|(?<=<\\s*(?:[0-9a-zA-Z_\\s]+,\\s*)*)[0-9a-zA-Z_]+(?=(?:\\s*,[0-9a-zA-Z_\\s]+)*\\s*>)" + "match": "(?<=\\b(?:alias|const|enum|struct|variant)\\s+)[0-9A-Z_a-z]+\\b|(?\\s*)?(?:\\*\\s*)*(?:\\?\\s*)*[0-9A-Z_a-z])|(?<=<(?:[\\s,0-9A-Z_a-z]+,)?\\s*)[0-9A-Z_a-z]+(?=\\s*[,>])" }, - "entity.name.function": { + "function": { "name": "entity.name.function.laye", - "match": "\\b[0-9a-zA-Z_]+(?=\\s*\\()" + "match": "\\b[0-9A-Z_a-z]+(?=\\s*\\()" }, - "variable.other.constant": { + "variable.readonly": { "name": "variable.other.constant.laye", - "match": "\\b[0-9_]*[A-Z][0-9A-Z_]*\\b|(?<=\\bconst[0-9a-zA-Z_\\s*?\\[\\]:]+)[0-9a-zA-Z_]+\\b|(?<=::\\s*)[0-9a-z_]*[A-Z][0-9a-zA-Z_]*\\b" + "match": "(?<=\\bconst\\s+[\\s,0-9A-Z_a-z<>]+\\s+)[0-9A-Z_a-z]+\\b|\\b[0-9_]*[A-Z][0-9A-Z_a-z]*\\b" }, "variable": { "name": "variable.laye", - "match": "\\b[0-9a-zA-Z_]+\\b" - }, - "invalid.illegal": { - "name": "invalid.illegal.laye", - "match": "#[0-9a-zA-Z_]*|'(?:[^']*?'|.*?\\s)|\"[^\"\\n;]*|[^0-9a-zA-Z_\\s*?\\[\\]]" - }, - "escape": { - "name": "constant.character.escape.laye", - "match": "\\\\(?:[\\\\0abefnrtv]|x[0-7][0-9a-fA-F]|o[0-1]?[0-7]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})" - }, - "meta.embedded": { - "name": "meta.embedded.laye", - "begin": "`", - "end": "`", - "patterns": [ - { "include": "#comment.block" }, - { "include": "#keyword.directive" }, - { "include": "#storage.modifier" }, - { "include": "#storage.type" }, - { "include": "#storage" }, - { "include": "#keyword.control.conditional" }, - { "include": "#keyword.control.loop" }, - { "include": "#keyword.control.flow" }, - { "include": "#keyword.control" }, - { "include": "#keyword.operator.assignment.logical" }, - { "include": "#keyword.operator.assignment.arithmetic" }, - { "include": "#keyword.operator.accessor" }, - { "include": "#keyword.operator.logical" }, - { "include": "#keyword.operator.arithmetic" }, - { "include": "#keyword.operator.relational" }, - { "include": "#keyword.operator" }, - { "include": "#constant.language.boolean" }, - { "include": "#constant.language" }, - { "include": "#string.quoted.single" }, - { "include": "#string.quoted.double" }, - { "include": "#punctuation.definition" }, - { "include": "#punctuation.separator" }, - { "include": "#constant.numeric" }, - { "include": "#entity.name.scope-resolution" }, - { "include": "#entity.name.type" }, - { "include": "#entity.name.function" }, - { "include": "#variable.other.constant" }, - { "include": "#variable" } - ] - }, - "comment.documentation.author": { - "name": "variable.other.constant.laye", - "match": "(?<=@author\\s+)[0-9a-zA-Z_.\\-]+\\b" - }, - "comment.documentation.param": { - "name": "meta.embedded.laye", - "begin": "(?<=@param)\\s", - "end": "[\\n;]", - "patterns": [ - { "include": "#comment.line" }, - { "include": "#storage.modifier" }, - { "include": "#storage.type" }, - { "include": "#invalid.illegal" }, - { "include": "#keyword.operator.arithmetic" }, - { "include": "#keyword.operator" }, - { "include": "#punctuation.definition" }, - { "include": "#punctuation.separator" }, - { "include": "#constant.numeric" }, - { "include": "#entity.name.scope-resolution" }, - { "include": "#entity.name.type" }, - { "include": "#variable.other.constant" }, - { "include": "#variable" } - ] - }, - "comment.documentation.return": { - "name": "meta.embedded.laye", - "begin": "(?<=@return)\\s", - "end": "[\\n;]", - "patterns": [ - { "include": "#comment.line" }, - { "include": "#storage.modifier" }, - { "include": "#storage.type" }, - { "include": "#invalid.illegal" }, - { "include": "#keyword.operator.arithmetic" }, - { "include": "#keyword.operator" }, - { "include": "#punctuation.definition" }, - { "include": "#punctuation.separator" }, - { "include": "#constant.numeric" }, - { "include": "#entity.name.scope-resolution" }, - { "include": "#entity.name.type" } - ] - }, - "comment.documentation.since": { - "name": "constant.numeric.laye", - "match": "(?<=@since\\s+)\\d+(?:\\.\\d+)*[0-9a-zA-Z_.\\-]*\\b" + "match": "\\b[0-9A-Z_a-z]+\\b" } }, "scopeName": "source.laye" -} +} \ No newline at end of file diff --git a/examples/conditional_compilation/build.laye b/test/conditional_compilation/build.laye similarity index 100% rename from examples/conditional_compilation/build.laye rename to test/conditional_compilation/build.laye diff --git a/examples/conditional_compilation/main.laye b/test/conditional_compilation/main.laye similarity index 100% rename from examples/conditional_compilation/main.laye rename to test/conditional_compilation/main.laye diff --git a/examples/conditional_compilation/mylib-linux.laye b/test/conditional_compilation/mylib-linux.laye similarity index 100% rename from examples/conditional_compilation/mylib-linux.laye rename to test/conditional_compilation/mylib-linux.laye diff --git a/examples/conditional_compilation/mylib-windows.laye b/test/conditional_compilation/mylib-windows.laye similarity index 100% rename from examples/conditional_compilation/mylib-windows.laye rename to test/conditional_compilation/mylib-windows.laye diff --git a/examples/hello.laye b/test/hello.laye similarity index 90% rename from examples/hello.laye rename to test/hello.laye index 5e6cbd5..0fdbd10 100644 --- a/examples/hello.laye +++ b/test/hello.laye @@ -11,9 +11,11 @@ import * from "stdio.h"; /* * Documentation needs highlighting too * @author Zedritsch + * @see https://example.com * @param void name * @return i32 * @since 1.0.0-pre1 + * @deprecated */ i32 main() diff --git a/examples/templates.laye b/test/templates.laye similarity index 100% rename from examples/templates.laye rename to test/templates.laye diff --git a/examples/token.laye b/test/token.laye similarity index 100% rename from examples/token.laye rename to test/token.laye diff --git a/test/tokens.laye b/test/tokens.laye new file mode 100644 index 0000000..60fba49 --- /dev/null +++ b/test/tokens.laye @@ -0,0 +1,13 @@ +~ ! % & * ( ) [ ] { } | - = + : ; , . / < > ? // comment here +:: <= >= << >> == != += -= *= /= &= %= |= <<= >>= ~= => +main parse_node 3d_object f23 +123_456_789 3433141651 24601 -69 16#DEAD_BEEF 1.23 -0.5 +"Hello, $laye!" "r=\rn=\n \" t=\t v=\v \\" +'\0' '\n' 'a' 'Z' '$' +void var noreturn +bool b32 b7 int uint i32 i27 u19 u64 float f32 f64 f16 f128 +true false nil global +not and or xor new delete cast try catch nodiscard sizeof alignof offsetof +varargs const foreign inline callconv(cdecl) +if else for do switch case default return break continue defer goto xyzzy +struct variant enum alias test import export from as operator mut \ No newline at end of file