aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-07-15 11:27:11 +0300
committerMihai Bazon <mihai@bazon.net>2013-07-15 11:27:11 +0300
commit4a0bab0fa3fc6d69507e91fdf17322b808aff7e4 (patch)
tree6b4becc3fd913d0d64f6ad6ad04d9fa9fcac1f7a /lib
parent9243b0cb9dd8469b6f4dbbf6ff9508e56f0e6fc2 (diff)
downloadtracifyjs-4a0bab0fa3fc6d69507e91fdf17322b808aff7e4.tar.gz
tracifyjs-4a0bab0fa3fc6d69507e91fdf17322b808aff7e4.zip
Add "position" option to parser, to specify initial pos/line/col
(for parsing embedded scripts)
Diffstat (limited to 'lib')
-rw-r--r--lib/parse.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/parse.js b/lib/parse.js
index 48ab2167..35fd9c75 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -210,17 +210,17 @@ function is_token(token, type, val) {
var EX_EOF = {};
-function tokenizer($TEXT, filename) {
+function tokenizer($TEXT, filename, position) {
var S = {
text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/\uFEFF/g, ''),
filename : filename,
- pos : 0,
- tokpos : 0,
- line : 1,
- tokline : 0,
- col : 0,
- tokcol : 0,
+ pos : position && position.pos || 0,
+ tokpos : position && position.pos || 0,
+ line : position && position.line || 1,
+ tokline : position && position.line || 1,
+ col : position && position.col || 0,
+ tokcol : position && position.col || 0,
newline_before : false,
regex_allowed : false,
comments_before : []
@@ -591,7 +591,8 @@ function parse($TEXT, options) {
strict : false,
filename : null,
toplevel : null,
- expression : false
+ expression : false,
+ position : { pos: 0, line: 1, col: 0 },
});
var S = {