Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syntax-script/compiler
Syntax Script compiler.
https://github.com/syntax-script/compiler
compiler compiler-application script syntax syntax-script sys syx
Last synced: 29 days ago
JSON representation
Syntax Script compiler.
- Host: GitHub
- URL: https://github.com/syntax-script/compiler
- Owner: syntax-script
- License: mit
- Created: 2024-04-08T18:36:59.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-20T02:43:42.000Z (6 months ago)
- Last Synced: 2024-08-07T10:56:19.660Z (3 months ago)
- Topics: compiler, compiler-application, script, syntax, syntax-script, sys, syx
- Language: TypeScript
- Homepage:
- Size: 470 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @syntaxs/compiler `v0.0.3-alpha`
![Stars](https://badgen.net/github/stars/syntax-script/compiler)
![Releases](https://badgen.net/github/release/syntax-script/compiler)
![Version](https://badgen.net/npm/v/@syntaxs/compiler)
![License](https://badgen.net/github/license/syntax-script/compiler)> Main compiler module of Syntax Script.
This module is used to either compile a syntax script project, or create diagnostic reports for language servers.
# Usage
Using the compiler.
```typescript
import { SyntaxScriptCompiler } from '@syntaxs/compiler';const compiler = new SyntaxScriptCompiler('/path/to/root/dir','/path/to/out/dir','ts');
compiler.compile();
```Creating diagnostic reports for language servers.
```typescript
import {createSyntaxScriptDiagnosticReport} from '@syntaxs/compiler';const report = createSyntaxScriptDiagnosticReport('/path/to/file.syx');
console.log(`${report.items.length} Problems found in the file.`);
```Handling compiler errors.
```typescript
import { SyntaxScriptCompiler,isCompilerError } from '@syntaxs/compiler';const compiler = new SyntaxScriptCompiler('/path/to/root/dir','/path/to/out/dir','ts');
try {
compiler.compile();
} catch (e) {
if(isCompilerError(e)) {
console.log(`There is a syntax error in the file: ${e.message}`);
console.log(`This problem is at line ${e.range.start.line}`);
console.log(`There are ${e.actions.length} recommended solutions to this problem.`)
}
}
```