Hey guys,
inspired by something that Vjeko mentioned during one of the pauses, I tried my hand at writing a state machine "lexer" to parse the files.
My results are mixed, to say the least ;-)
(I had no idea what I was doing here, this might be ridiculously wrong and if you laugh your head off, please let me parttake in your amusement :D)
My guess is that this code creates overhead which the JScript interpreter doesn't have to deal with in the current parsing code.
It actually works, but it seems to perform a bit worse than the original code in my tests.
- I wonder if not instantiating an object of the LexerParser class and getting rid of a few if-statements could help
- The step() code seems dirty compared to what I've seen, if it's correct this way at all
- There's some unecessary variables and assignments in there
Lexer Code:
src/parser/Lexer.ts
https://pastebin.com/vJnHqv8z
A simple way to implement it is to add this to src/parser/parse.ts :
const lexerParser = new LexerParser(uri); const results = lexerParser.readFile(); return results;
(Above the current parsing code, comment the rest out.)
Thanks for having a look, kind regards,
Wolfram
Here's some stopwatch code in case you want to measure results:
var startTime: Date, endTime: Date;
function start() {
startTime = new Date();
}
function end() {
endTime = new Date();
var timeDiff = endTime.getMilliseconds() - startTime.getMilliseconds(); //in ms
console.log(timeDiff + ' milliseconds');
}