|
|
@@ -359,7 +359,7 @@ var generator = function (node) {
|
|
359
|
359
|
switch (node.type) {
|
|
360
|
360
|
case 'Prog':
|
|
361
|
361
|
let program = node.body.map(generator)
|
|
362
|
|
- program.unshift('var _ = require("./libjs/stdlib.js")(this)')
|
|
|
362
|
+ program.unshift('var _ = require("' + libjsPath + '/stdlib.js")(this)')
|
|
363
|
363
|
return program.join('\n')
|
|
364
|
364
|
break
|
|
365
|
365
|
case 'Statement':
|
|
|
@@ -370,7 +370,7 @@ var generator = function (node) {
|
|
370
|
370
|
if (node.callee.name.match('include')) {
|
|
371
|
371
|
// Include is a special function and we will write the generation ourselves
|
|
372
|
372
|
return node.args.map((arg) => {
|
|
373
|
|
- let lib = './libjs/' + arg.value + '.js'
|
|
|
373
|
+ let lib = libjsPath + '/' + arg.value + '.js'
|
|
374
|
374
|
return ('var _' + arg.value + ' = require("' + lib + '")(this)')
|
|
375
|
375
|
}).join("\n")
|
|
376
|
376
|
} else {
|
|
|
@@ -430,10 +430,14 @@ var generator = function (node) {
|
|
430
|
430
|
|
|
431
|
431
|
}
|
|
432
|
432
|
|
|
|
433
|
+let libjsPath = process.env['LIBJS_PATH']
|
|
433
|
434
|
const fileNameIn = process.argv[2]
|
|
434
|
435
|
const fileNameOut = fileNameIn + '.js'
|
|
435
|
436
|
const myInput = fs.readFileSync(process.argv[2], { encoding: 'utf-8' })
|
|
436
|
437
|
|
|
|
438
|
+if (libjsPath === '') {
|
|
|
439
|
+ libjsPath = './libjs'
|
|
|
440
|
+}
|
|
437
|
441
|
const preProcessedInput = preprocess(fileNameIn, myInput) // Run the preprocessor to evaluate any `source's
|
|
438
|
442
|
const myTokens = tokenizer(preProcessedInput) // Convert our input into individual tokens
|
|
439
|
443
|
const parsedTree = parser(myTokens) // Convert these tokens into a syntax tree
|