Defines the formal grammar and syntax rules.
Acts as the single source of truth for all language constructs and structures.
-
npm install @je-es/syntax
import * as Syntax from "@je-es/syntax";
-
// [1] Create syntax object const syntax = Syntax.create({ name : 'Kemet', version : '0.0.1', lexer : lexerRules, // Hint: use `@je-es/lexer` for lexer rules parser : parserRules, // Hint: use `@je-es/parser` for parser rules settings : parserSettings // Hint: use `@je-es/parser` for parser settings lsp : lspConfig // Hint: use `@je-es/lsp` for lsp config } as Syntax.SyntaxConfig);
// [2] One instruction that abbreviates both: lexer.tokenize() and parser.parse() syntax.parse('<your-text>');
-
The
@je-es/syntaxpackage now supports LSP (Language Server Protocol) configuration, allowing you to define language-specific features for IDE integration.-
import type { LSPConfig } from '@je-es/syntax'; const lspConfig: LSPConfig = { keywords: { declarations : ['let', 'fn', 'def', 'use', 'pub'], types : ['i8', 'i16', 'i32', 'i64', 'bool', 'str'], controlFlow : ['if', 'else', 'while', 'for', 'return'], modifiers : ['mut', 'pub', 'static', 'inline'], operators : ['as', 'typeof', 'sizeof', 'try', 'catch'], literals : ['true', 'false', 'null', 'und'], builtins : ['@print', '@i', 'self'] }, keywordDocs: { 'let': { signature : '[pub] let [mut] name: type = value', description : 'Declare a variable', example : 'let mut counter: i32 = 0;' }, 'fn': { signature : '[pub] fn name(params) -> type { }', description : 'Declare a function', example : 'pub fn add(a: i32, b: i32) -> i32 { return a + b; }' } // ... }, builtinDocs: { '@print' : '```kemet\nfn @print(text: str) -> void\n```\n\nBuilt-in function to print text.', // ... }, triggerCharacters : ['.', ':', '@', ' '], fileExtension : '.k' };
-
import { LSP } from '@je-es/lsp'; import { kemetSyntax } from '@kemet-rules/lang'; const lsp = new LSP(connection, documents, { syntax : kemetSyntax, // ← Pass syntax with LSP config rootPath : process.cwd() }); lsp.start();
-
-
-
1. @je-es/lexer
3. @je-es/ast
8. @je-es/lsp
-

