Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/shivamka1/js-dot-antlr-parser

The objective of this project is to demostrate how to capture diagnostics i.e., semantic and syntactic errors for DOT language using ANTLR parser written in Javascript.
https://github.com/shivamka1/js-dot-antlr-parser

antlr4 diagnostics dot javascript parser

Last synced: about 8 hours ago
JSON representation

The objective of this project is to demostrate how to capture diagnostics i.e., semantic and syntactic errors for DOT language using ANTLR parser written in Javascript.

Awesome Lists containing this project

README

        

# js-dot-antlr-parser
The objective of this project is to demostrate how to capture diagnostics i.e., semantic and syntactic errors for DOT language using ANTLR parser written in Javascript.

# Installation
```script
npm install --save js-dot-antlr-parser
```

# Usage
```javascript
const jdap = require('js-dot-antlr-parser');
console.log(JSON.stringify(jdap.doValidation("gaph { \n a -- b \n a - b \n b - a [color=blue] \n }")));
console.log(JSON.stringify(jdap.doValidation("gaph { \n a -- b \n a - b \n b - a [color=blue] \n }").semanticErrors));
console.log(JSON.stringify(jdap.doValidation("gaph { \n a -- b \n a - b \n b - a [color=blue] \n }").syntacticErrors));
```

# Output
```
{
"syntacticErrors": [{
"message": "token recognition error at: '- '",
"line": 2,
"character": 3,
"symbol": "",
"length": 1
}, {
"message": "token recognition error at: '- '",
"line": 3,
"character": 3,
"symbol": "",
"length": 1
}],
"semanticErrors": [{
"message": "mismatched input 'gaph' expecting {STRICT, GRAPH, DIGRAPH}",
"line": 0,
"character": 0,
"symbol": "gaph",
"length": 4
}]
}
```