Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
,['OPTIONS OPTION', ""]
]
,'OPTION' : [["EOL" , "return (this);"]
,['HOS TEX' ,"this.hostname=$2"]
,['PRT TEX' ,"this.port=parseInt($2)"]
,['IME TEX' ,"this.mmsi=parseInt($2)"]
,['MSG TEX' ,"this.type=parseInt($2)"]
,['DEB TEX' ,"this.debug=$2"]
,['DUM TEX' ,"this.dumpfile=$2"]
,['VER' ,"this.verbose=true"]
,['HLP' ,"this.help=true"]
]
}};
// instanciate command line parser
var parser=new jison (cmdgrammar);
try {this.opts = parser.parse (args.toString());}
catch (err) {
console.log ("Syntax error [please check --help] err=[%s]", err);
this.error=true;
return;
}
// get basename from command line
var cmd= command.split ('/');
var bin= cmd[cmd.length -1];
// if help call then display help and exit
if (this.opts.help) {
console.log ("----------------------------------------------------------------------------------------------------------");
console.log ("## Syntaxe: %s --hostname=xxxx --port=xxxx [--mmsi=xxx] [--dumpfile=xxx] \\",bin);
,['WID TEX' ,"this.wid=parseInt($2)"]
,['LEN TEX' ,"this.len=parseInt($2)"]
,['CAR TEX' ,"this.cargo=parseInt($2)"]
,['WAY TEX' ,"this.uway=parseInt($2)"]
,['SRC TEX' ,"this.srvmod=JSON.parse($2)"]
,['LOP TEX' ,"this.loopwait=parseInt($2*1000)"] // millisecond
,['RAN TEX' ,"this.randomize=$2"]
,['VER' ,"this.verbose=true"]
,['SRV' ,"this.srvmod=true"]
,['PAR' ,"this.testpar=true"]
,['HLP' ,"this.help=true"]
]
}};
// instanciate command line parser
var parser=new jison (cmdgrammar);
var arguments= args.toString();
this.opts = parser.parse (arguments);
// get basename from command line
var cmd= command.split ('/');
var bin= cmd[cmd.length -1];
// if help call then display help and exit
if (this.opts.help) {
console.log ("----------------------------------------------------------------------------------------------------------");
console.log ("## Client: %s --gpxfile=./your-gpxfile.gpx [--proto=gprmc] [--speed=12] [--tic=2] \\",bin);
console.log (" [--srvmod | --hostname=localhost] [--port=5000] \\");
console.log (" [--dumpgpxfile=xxx] [--loopwait=timeout] [--debug=4]");
console.log ("## Server: %s --gpxfile=./your-gpxfile.gpx [--proto=aivdm] [--speed=6] [--tic=30] \\", bin);
console.log (" [--srvmod | --hostname=localhost] [port=5000] [--debug=4]\\");
console.log (" [--shipname=xxx] [--cargo=xxx] [--callsign=xxx] [--underway=xx] [--width=xxx] [--length=xxx]");
,['OPTIONS OPTION', ""]
]
,'OPTION' : [["EOL" , "return (this);"]
,['GPX TEX' ,"this.gpxdir=$2 + '/' ;"]
,['TIC TEX' ,"this.tic=parseInt($2);"]
,['PRT TEX' ,"this.port=parseInt($2)"]
,['DEB TEX' ,"this.debug=$2"]
,['DUM TEX' ,"this.dumpfile=$2"]
,['LOP TEX' ,"this.loopwait=parseInt($2*1000)"] // millisecond
,['VER' ,"this.verbose=true"]
,['HLP' ,"this.help=true"]
]
}};
// instanciate command line parser
var parser=new jison (cmdgrammar);
this.opts = parser.parse (args.toString());
// get basename from command line
var cmd= command.split ('/');
var bin= cmd[cmd.length -1];
// if help call then display help and exit
if (this.opts.help) {
console.log ("----------------------------------------------------------------------------------------------------------");
console.log ("## %s --gpxdir=./xxx --port=1234 --verbose \\",bin);
console.log ("## %s --gpxdir=./sample/hub-route --port=5001 \\",bin);
console.log ("----------------------------------------------------------------------------------------------------------");
}
};
// myparser.js
var fs = require("fs");
var jison = require("jison");
var bnf = fs.readFileSync(__dirname+"/grammar.jison", "utf8");
var parser = new jison.Parser(bnf);
module.exports = parser;
]
, 'FLOATSEP' : [
["FLOAT SEP", "$$=$1"]
]
, 'INTSEP' : [
["INT SEP", "$$=$1"]
]
}};
this.id = controller.svc;
this.uid = "//" + controller.svcopts.adapter + "/" + controller.svc + ":" + controller.svcopts.port;;
this.control = 'tcpsock';
this.info = 'TraccarDroid';
this.debug = controler.svcopts.debug; // inherit debug from controler
this.controler = controler; // keep a link to device controler and TCP socket
this.parser = new Jison(grammar);
this.Debug (1,"uid=%s", this.uid);
};
,["SEND HELP TXT" , "this.cmd='SEND'; this.devid=$3; this.action='help';"]
]
,'ARGS':[
["TXT" , "this.args=[$1];"]
,["ARGS TXT" , "this.args.push ($2);"]
]
}};
this.id = controller.svc;
this.uid = "//" + controller.svcopts.adapter + "/" + controller.svc + ":" + controller.svcopts.port;;
this.control = "tcpsock";
this.info = "Telnet";
this.debug = controller.svcopts.debug; // inherit debug from controller
this.Debug (1,"uid=%s", this.uid);
this.controller= controller; // keep a link to device controller and TCP socket
this.parser = new Jison(grammar);
this.request = 0; // job request number for gateway queue
try {
this.prompt= controller.gateway.opts.name +"> ";
} catch (err) {
this.prompt= "GatewayTracker> ";
}
};
constructor(opts = {}) {
dbg('Starting', opts);
parser = new jison.Parser(bnf);
if (opts.core !== false) {
// TODO: Parse all core libraries (when we have more)
const qelib1 = fs.readFileSync(
path.resolve(__dirname, '../core/qelib1.inc'),
'utf8',
);
this.qelibParsed = parser.parse(qelib1);
}
}
return function() {
var grammar = {
"lex": {
"rules": [
["\\s+", ''],
["[A-Za-z]+", "return 'word';"],
[",", "return ',';"],
["$", "return 'EOF';"]
]
},
"start": "top",
"bnf": ebnf.transform({"top": [top]})
};
assert.deepEqual(grammar['bnf'], obj);
assert.ok(new Parser(grammar).parse(str));
};
}
for (name in ref$ = bnf) {
alts = ref$[name];
for (i$ = 0, len$ = (ref1$ = alts).length; i$ < len$; ++i$) {
alt = ref1$[i$];
for (j$ = 0, len1$ = (ref2$ = alt[0]).length; j$ < len1$; ++j$) {
token = ref2$[j$];
if (!(token in bnf)) {
results$.push(token);
}
}
}
}
return results$;
}()).join(' ');
bnf.Root = [[['Body'], 'return $$']];
module.exports = new (require('jison')).Parser({
bnf: bnf,
operators: operators,
tokens: tokens,
startSymbol: 'Root'
});
var Parser = function() {
var parser = new JisonParser(grammar);
parser.yy.ast = _ast;
_ast.initialize();
return parser;
};