Skip to content

Commit

Permalink
Use 'use strict'; in generated code too
Browse files Browse the repository at this point in the history
  • Loading branch information
squaremo committed Dec 2, 2013
1 parent b74569d commit 9e7288f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
@@ -1,11 +1,15 @@
.PHONY: test all

GRAMMAR=lib/grammar.pegjs
PEGJS=./node_modules/.bin/pegjs

all: lib/parser.js

lib/parser.js:
./node_modules/pegjs/bin/pegjs $(GRAMMAR) $@
lib/parser.js: $(PEGJS)
$(PEGJS) $(GRAMMAR) $@

$(PEGJS):
npm install

test: lib/parser.js
./node_modules/.bin/mocha --check-leaks -R list -u tdd test/*.js
2 changes: 2 additions & 0 deletions lib/compile.js
Expand Up @@ -146,6 +146,7 @@ function variables(segments) {
function compile_pattern(segments) {
$start();
$line("return function(binary, env) {");
$line("'use strict';");
$line("var bin = binary, env = env || {};");
$line("var offset = 0, binsize = bin.length * 8;");
$line("var bits, result, byteoffset;");
Expand Down Expand Up @@ -275,6 +276,7 @@ function emit_write(segments) {
function compile_ctor(segments) {
$start();
$line('return function(bindings) {');
$line("'use strict';");
size_of(segments);
$line('var buf = new Buffer(buffersize);');
$line('var offset = 0;');
Expand Down

0 comments on commit 9e7288f

Please sign in to comment.