Skip to content

Commit aba24a2

Browse files
committed
update readme
1 parent c8704a9 commit aba24a2

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Diff for: README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# @syntaxs/compiler `v0.0.1-alpha`
2+
![Stars](https://badgen.net/github/stars/syntax-script/compiler)
3+
![Releases](https://badgen.net/github/release/syntax-script/compiler)
4+
![Version](https://badgen.net/npm/v/@syntaxs/compiler)
5+
![License](https://badgen.net/github/license/syntax-script/compiler)
26

37
> Main compiler module of Syntax Script.
48
@@ -9,15 +13,33 @@ This module is used to either compile a syntax script project, or create diagnos
913
Using the compiler.
1014

1115
```typescript
12-
// Compiling
1316
import { SyntaxScriptCompiler } from '@syntaxs/compiler';
1417

1518
const compiler = new SyntaxScriptCompiler('/path/to/root/dir','/path/to/out/dir','ts');
1619
compiler.compile();
1720
```
1821

19-
Creating diagnostic reports.
22+
Creating diagnostic reports for language servers.
2023

2124
```typescript
22-
//TODO
25+
import {createSyntaxScriptDiagnosticReport} from '@syntaxs/compiler';
26+
27+
const report = createSyntaxScriptDiagnosticReport('/path/to/file.syx');
28+
console.log(`${report.items.length} Problems found in the file.`);
29+
```
30+
31+
Handling compiler errors
32+
```typescript
33+
import { SyntaxScriptCompiler,isCompilerError } from '@syntaxs/compiler';
34+
35+
const compiler = new SyntaxScriptCompiler('/path/to/root/dir','/path/to/out/dir','ts');
36+
try {
37+
compiler.compile();
38+
} catch (e) {
39+
if(isCompilerError(e)) {
40+
console.log(`There is a syntax error in the file: ${e.message}`);
41+
console.log(`This problem is at line ${e.range.start.line}`);
42+
console.log(`There are ${e.actions.length} recommended solutions to this problem.`)
43+
}
44+
}
2345
```

0 commit comments

Comments
 (0)