An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          





syntax








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.


line


## 🚀 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
```




line

- #### 🔗 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.




line