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"
| // 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 |
| 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({ |
| module.exports={ | |
| foo:true, | |
| bar:false | |
| }; |
| 'use strict'; | |
| const | |
| fs = require('fs'), | |
| filename = process.argv[2]; | |
| console.log('--watching %s',filename); | |
| var watcher=fs.watch(filename); | |
| watcher.on('change',function(){ |
| 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]; | |
| }; |
| /* 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'); | |
| /** |
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') |