krl-parser
Advanced tools
Comparing version 0.12.9 to 0.13.0
{ | ||
"name": "krl-parser", | ||
"version": "0.12.9", | ||
"version": "0.13.0", | ||
"description": "Parse KRL source code into an AST", | ||
@@ -41,3 +41,2 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"comment-regex": "^1.0.0", | ||
"excerpt-at-line-col": "^1.0.0", | ||
@@ -44,0 +43,0 @@ "line-column": "^1.0.2", |
var nearley = require('nearley'); | ||
var grammar = require('./grammar.js'); | ||
var tokenizer = require('./tokenizer'); | ||
var lineColumn = require('line-column'); | ||
var commentsToSpaces = require('./commentsToSpaces'); | ||
var excerptAtLineCol = require('excerpt-at-line-col'); | ||
@@ -32,8 +32,16 @@ | ||
var tokens = tokenizer(src).filter(function(t){ | ||
return true | ||
&& t.type !== "WHITESPACE" | ||
&& t.type !== "LINE-COMMENT" | ||
&& t.type !== "BLOCK-COMMENT" | ||
; | ||
}); | ||
var p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart); | ||
try{ | ||
p.feed(commentsToSpaces(src)); | ||
p.feed(tokens); | ||
}catch(e){ | ||
if(typeof e.offset === "number"){ | ||
var lc = lineColumn(src, e.offset); | ||
if(typeof e.offset === "number" && tokens[e.offset] && tokens[e.offset].loc){ | ||
var lc = lineColumn(src, tokens[e.offset].loc.start); | ||
if(lc){ | ||
@@ -40,0 +48,0 @@ throw mkParseError(src, lc.line, lc.col, e, opts.filename); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3
1229
83443
- Removedcomment-regex@^1.0.0
- Removedcomment-regex@1.0.1(transitive)