https://github.com/je-es/syntax
Unified wrapper that streamlines syntax creation with integrated lexer-parser coordination, LSP support, and enhanced linting capabilities.
https://github.com/je-es/syntax
ast je-es lexer lint parser syntax tool
Last synced: 10 months ago
JSON representation
Unified wrapper that streamlines syntax creation with integrated lexer-parser coordination, LSP support, and enhanced linting capabilities.
- Host: GitHub
- URL: https://github.com/je-es/syntax
- Owner: je-es
- License: mit
- Created: 2025-08-17T09:36:10.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-05T02:34:10.000Z (10 months ago)
- Last Synced: 2025-09-05T04:19:23.561Z (10 months ago)
- Topics: ast, je-es, lexer, lint, parser, syntax, tool
- Language: TypeScript
- Homepage:
- Size: 323 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A comprehensive wrapper that unifies lexer and
parser modules into a streamlined interface for creating custom syntax.
It provides LSP integration, CLI tooling support, and advanced linting with early error detection.
## 🚀 Installation
```bash
npm install @je-es/syntax
```
```typescript
import * as syntax from '@je-es/syntax';
```
## 🌟 How to Use
> The [@je-es/lexer](https://github.com/je-es/lexer) and [@je-es/parser](https://github.com/je-es/parser) modules are designed as completely independent, lightweight components with zero dependencies.
>
> While this modular architecture ensures flexibility and focused functionality, integrating these modules can be complex for end users.
> **@je-es/syntax** solves this by providing a unified wrapper that streamlines the development experience.
>
> This enables you to create different syntaxes through a consistent API, while offering dedicated interfaces for Language Server Protocol (LSP) and CLI applications.
>
> The wrapper facilitates seamless parsing, advanced linting capabilities, and early syntax error detection before code generation.
```ts
const mySyntax = syntax.create({
name : 'mySyntax',
version : '0.0.1',
lexer : { .. },
parser : [ .. ],
settings : { .. }
});
const result = mySyntax.parse('some code');
```
## 📖 API Reference
- #### Functions
```ts
// Create a new syntax object with the given configuration.
function create(config: SyntaxConfig): Syntax
```
- #### Syntax Class
- #### Fields
```ts
// The configuration object for the syntax, containing
// the lexer rules, parser rules, and parser settings.
public config: SyntaxConfig;
```
```ts
// The parser instance used to parse the syntax tree.
public parser: parser.Parser;
```
- #### Functions
```ts
// Parse a given input string into a structured syntax
// tree using the syntax's parser.
parse(input: string): parser.ParseResult
```
```ts
// Similar to parse, but returns only the errors in the parse result.
lint(input: string): parser.ParseError[]
```
```ts
// Create a new Syntax object with the given start rule and debug level,
// using the current syntax's configuration.
from(ruleName: string, debug: parser.DebugLevel | null = null) : Syntax
```
- #### 🔗 Related
- ##### [@je-es/lexer](https://github.com/je-es/lexer)
> Fundamental lexical analyzer that transforms source text into structured tokens with type and position information.
- ##### [@je-es/parser](https://github.com/je-es/parser)
> Advanced syntax analyzer that converts tokens into AST with customizable grammar rules and intelligent error detection.
- ##### @je-es/syntax
> Unified wrapper that streamlines syntax creation with integrated lexer-parser coordination, LSP support, and enhanced linting capabilities.
- ##### [@je-es/program](https://github.com/je-es/program)
> A high-performance, type-safe program representation library with advanced semantic analysis for programming languages.