Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 21cf5c0

Browse files
committed
WIP
1 parent 35127a6 commit 21cf5c0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

testy.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import fs from 'fs';
2+
import { Lexer } from 'chevrotain';
3+
import { lexicalGrammar } from './lib/config/ConfigLexer.js';
4+
import ConfigParser from './lib/config/ConfigParser.js';
5+
6+
const lexer = new Lexer(lexicalGrammar, {
7+
debug: true
8+
});
9+
10+
const text = fs.readFileSync('./test.config', 'utf8');
11+
const results = lexer.tokenize(text);
12+
13+
console.log(results.tokens.map((token) => {
14+
return [token.image, token.tokenClassName];
15+
}));
16+
17+
const parser = new ConfigParser([]);
18+
19+
parser.input = results.tokens;
20+
21+
parser.top();
22+
23+
if (parser.errors.length > 0) {
24+
console.log(parser.errors);
25+
} else {
26+
console.log('PARSING SUCCESS');
27+
}
28+
29+
// results.tokens = results.tokens.map((token) => {
30+
// return [token.image, token.tokenClassName];
31+
// });
32+
33+
// console.log(text);
34+
// console.log(results);

0 commit comments

Comments
 (0)