Author: Rob Raisch [email protected]
Create a parser for "{float a =3;a*3+1;}" such that it will produce a result value of 10 per the StackOverflow question "The element of the two statements are mutually referenced with peg.js"
{ | |
/* | |
Filename: grammar.pegjs | |
Author: [email protected] | |
*/ | |
const util = require('util') | |
const _ = require('lodash') |
Author: Rob Raisch [email protected]
Create a parser for "{float a =3;a*3+1;}" such that it will produce a result value of 10 per the StackOverflow question "The element of the two statements are mutually referenced with peg.js"
/* Created by raisch on 3/21/16. */ | |
/*jshint node:true, bitwise:true, camelcase:false, curly:true, undef:false, unused:false, eqeqeq:true, shadow:true */ | |
'use strict'; | |
var assert = require('assert'), | |
event = require('events'); | |
/** |
var atoi = function atoi(addr) { | |
var parts = addr.split('.').map(function(str) { | |
return parseInt(str); | |
}); | |
return (parts[0] ? parts[0] << 24 : 0) + | |
(parts[1] ? parts[1] << 16 : 0) + | |
(parts[2] ? parts[2] << 8 : 0) + | |
parts[3]; | |
}; |
'use strict'; | |
const | |
fs = require('fs'), | |
filename = process.argv[2]; | |
console.log('--watching %s',filename); | |
var watcher=fs.watch(filename); | |
watcher.on('change',function(){ |
module.exports={ | |
foo:true, | |
bar:false | |
}; |
var util=require('util'), | |
events=require('events'), | |
EventEmitter=events.EventEmitter; | |
/* | |
* TaskRunner - runs any number of functions asynchronously and in order | |
* | |
* var runner = new TaskRunner( func(s) || { options } ); | |
* | |
* runner.init({ |
// tokenize(str) | |
// extracts semantically useful tokens from a string containing English-language sentences | |
// @param {String} the string to tokenize | |
// @returns {Array} contains extracted tokens | |
function tokenize(str) { | |
var punct='\\['+ '\\!'+ '\\"'+ '\\#'+ '\\$'+ // since javascript does not | |
'\\%'+ '\\&'+ '\\\''+ '\\('+ '\\)'+ // support POSIX character | |
'\\*'+ '\\+'+ '\\,'+ '\\\\'+ '\\-'+ // classes, we'll need our |