Old hand at parsers, new to javascript and nodejs

23 views
Skip to first unread message

Asterion Daedalus

unread,
Aug 11, 2017, 6:25:32 PM8/11/17
to PEG.js: Parser Generator for JavaScript
I have an embarrassing problem.

I have built parsers before with lex and yacc.

I have built a parser in pegjs and tested it on the web version.  All good.

My target environment will be node-red but I wanted to test it running node from the console.

This is my first project in javascript.

I have a sheltered exposure to the language use in node-red.

I am entirely vague, however, on the nuisances of importing into nodejs.

Starting from the exported parser, with module.exports as the parser variable, what should my import declaration be for the node console please?

I have tried various options but all seem to raise errors.

I am assuming that will be the same then for node-red?

Cheers,
A

Asterion Daedalus

unread,
Aug 11, 2017, 9:47:42 PM8/11/17
to PEG.js: Parser Generator for JavaScript


On Saturday, August 12, 2017 at 7:55:32 AM UTC+9:30, Asterion Daedalus wrote:
 
I have tried various options but all seem to raise errors.

 
Ah ha! One combination I had not tried is the following:

var parser = require('./parser.js');

The thing I fell over on was that I am running on windoze where directories are '\" and the node harmonises directories, it seems, to the linux "/".

So, I am up and running.

Thanks, by the way, for pegjs.  Way cool.

Cheers,
A


Reply all
Reply to author
Forward
0 new messages