mirror of
https://github.com/tauri-apps/tauri-toml.git
synced 2026-02-04 18:31:17 +01:00
35 lines
882 B
JavaScript
35 lines
882 B
JavaScript
'use strict'
|
|
const TOMLParser = require('../lib/toml-parser').makeParserClass(require('../lib/parser-debug.js'))
|
|
const prettyError = require('../parse-pretty-error')
|
|
const util = require('util')
|
|
const dump = d => util.inspect(d, {colors: true, depth: Infinity})
|
|
|
|
success()
|
|
failure()
|
|
|
|
function success () {
|
|
let testtoml = `a = [1.0,1e0]`
|
|
|
|
console.log('Parsing:', testtoml)
|
|
const parser = new TOMLParser()
|
|
try {
|
|
parser.parse(testtoml)
|
|
console.log('Result:', dump(parser.finish()))
|
|
} catch (err) {
|
|
console.error('Error:', prettyError(err, testtoml).message)
|
|
}
|
|
}
|
|
|
|
function failure () {
|
|
let testtoml = `a = [1.0,1e0`
|
|
|
|
console.log('Parsing:', testtoml)
|
|
const parser = new TOMLParser()
|
|
try {
|
|
parser.parse(testtoml)
|
|
console.log('Result:', dump(parser.finish()))
|
|
} catch (err) {
|
|
console.error('Error:', prettyError(err, testtoml).message)
|
|
}
|
|
}
|