TOML-Tools/lexer
A Toml Lexer implemented in JavaScript using the Chevrotain Parsing Toolkit.
This package could be used as part of a Toml Parser,
a Toml syntax highlighter or any other use case where a Toml Token Vector would be useful.
Installation
yarn add @toml-tools/lexer
npm install @toml-tools/lexer
APIs
This package's APIs are exported as a TypeScript definition file.
Usage
const { tokenize } = require("@toml-tools/lexer");
const input = `# This is a TOML document.
title = "TOML Example"
`;
const lexingResult = tokenize(input);
console.log(lexingResult.errors.length);
console.log(lexingResult.tokens.length);
const tokens = lexingResult.tokens;
console.log(tokens[0].image);
console.log(tokens[0].startLine);
console.log(tokens[0].endOffset);