tmdl-parser-service v0.1.0
tmdl-parser-service
The tmdl-parser-service is a TypeScript-based library that provides a robust solution for parsing the Tabular Model Definition Language (TMDL). This library is designed to work efficiently with TMDL scripts, allowing developers to easily parse and analyze these scripts within their applications
Usage
To install the library, use the following command:
npm i tmdl-parser-service
Here's an example demonstrating how to use the library:
// Import the TMDLLexer and TMDLParser classes from the tmdl-parser-service library
import { TMDLParser, TMDLLexer } from 'tmdl-parser-service';
// Get the text from a text document (e.g., a TMDL file)
const text = textDocument.getText();
// Convert the text to a stream of characters (CharStream)
const chars = CharStreams.fromString(text);
// Create a lexer instance using the CharStream
const lexer = new TMDLLexer(chars);
// Create a token stream from the lexer
const tokens = new CommonTokenStream(lexer);
// Create a parser instance using the token stream
const parser = new TMDLParser(tokens);
// Trigger the parsing process by starting from the top-level rule (`prog`)
const tree = parser.prog();
// Print the parse tree for testing purposes
console.log(tree.toStringTree(parser.ruleNames, parser));
Contribution Guidelines
Regenerate lexer and parser files
After making changes to the .g4 files, generate new parser and lexer files by running the following commands:
antlr4 -visitor -Dlanguage=TypeScript TMDLLexer.g4 -o ../parser
antlr4 -visitor -Dlanguage=TypeScript TMDLParser.g4 -o ../parser
Publish
To publish the library, use the following commands:
tsc -b
npm publish
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
4 days ago
7 days ago
7 days ago
12 days ago
14 days ago
17 days ago
24 days ago
24 days ago