diff --git a/.gitignore b/.gitignore index dfa7854..ed70925 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules built package-lock.json + temp +syuilo-parser* diff --git a/package.json b/package.json index 5b11a7f..b9e04e9 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "build": "npm run peg && npm run tsc && npm run webpack", "build-dev": "npm run peg-dev && npm run tsc && npm run webpack-dev", - "peg": "mkdirp ./built/parser && pegjs -o built/parser/coreParser.js src/parser/coreParser.pegjs", - "peg-dev": "mkdirp ./built/parser && pegjs -o built/parser/coreParser.js --trace src/parser/coreParser.pegjs", + "peg": "mkdirp ./built/parser && pegjs -o built/parser/core-parser.js src/parser/core-parser.pegjs", + "peg-dev": "mkdirp ./built/parser && pegjs -o built/parser/core-parser.js --trace src/parser/core-parser.pegjs", "tsc": "tsc", "webpack": "webpack --mode=production", "webpack-dev": "webpack --mode=development", @@ -26,5 +26,9 @@ "typescript": "3.7.x", "webpack": "4.40.x", "webpack-cli": "3.3.x" + }, + "dependencies": { + "@types/parsimmon": "^1.10.1", + "parsimmon": "^1.13.0" } } diff --git a/src/client/mainEntry.ts b/src/client/main-entry.ts similarity index 56% rename from src/client/mainEntry.ts rename to src/client/main-entry.ts index 1fb7479..ac3038f 100644 --- a/src/client/mainEntry.ts +++ b/src/client/main-entry.ts @@ -1,13 +1,13 @@ -import { PegParser } from '../parser/pegParser'; +import { PegParser } from '../parser/peg-parser'; async function entryPoint() { - const coreParser: PegParser = require('../../built/parser/coreParser.js'); + const coreParser: PegParser = require('../../built/parser/core-parser.js'); const input = '[hoge]'; console.log('parsing input:', input); const result = coreParser.parse(input); console.log('parsing result:'); - console.log(result); + console.log(JSON.stringify(result)); } entryPoint() .catch(err => console.log(err)); diff --git a/src/index.ts b/src/index.ts index a2c8589..9e1c11c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ -import { PegParser } from './parser/pegParser'; +import { PegParser } from './parser/peg-parser'; -const coreParser: PegParser = require('./parser/coreParser'); +const coreParser: PegParser = require('./parser/core-parser'); const input = '[hoge]'; console.log('parsing input:', input); const result = coreParser.parse(input); console.log('parsing result:'); -console.log(result); +console.log(JSON.stringify(result)); diff --git a/src/parser/coreParser.pegjs b/src/parser/core-parser.pegjs similarity index 100% rename from src/parser/coreParser.pegjs rename to src/parser/core-parser.pegjs diff --git a/src/parser/pegParser.d.ts b/src/parser/peg-parser.d.ts similarity index 100% rename from src/parser/pegParser.d.ts rename to src/parser/peg-parser.d.ts diff --git a/webpack.config.js b/webpack.config.js index a2d36e3..3cca1c5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,5 @@ module.exports = { - entry: './src/client/mainEntry.ts', + entry: './src/client/main-entry.ts', output: { path: `${__dirname}/built/client`, publicPath: '/', // base path of URL