forked from GerHobbelt/jison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
611 lines (424 loc) · 16.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
NANOC := $(shell command -v nanoc 2> /dev/null)
ROLLUP = node_modules/.bin/rollup
BABEL = node_modules/.bin/babel
MOCHA = node_modules/.bin/mocha
NYC = node_modules/.bin/nyc --clean=false --temp-directory ./.nyc_output
ifndef FULL_CODE_COVERAGE
JISON = node dist/cli-cjs-es5.js
else
JISON = $(NYC) --reporter=lcov -- node dist/cli-cjs-es5.js
endif
all: clean-nyc build test test-nyc examples-test report-nyc
everything: \
clean \
npm-update \
prep \
all \
site
prep: subpackages-prep npm-install
# `make site` will perform an extensive (re)build of the jison tool, all examples and the web pages.
# Use `make compile-site` for a faster, if less complete, site rebuild action.
site: build test examples-test web-examples web/content/assets/js/jison.js compile-site
clean-site:
-@rm -rf web/tmp/
-@rm -rf web/output/jison/
-@rm -rf web/content/examples/
-rm web/content/assets/js/jison.js
-rm web/content/assets/js/calculator.js
# `make compile-site` will perform a quick (re)build of the web pages
compile-site: web-examples web/content/assets/js/jison.js
-@rm -rf web/tmp/
-@rm -rf web/content/examples/
cp -r examples web/content/examples/
ifndef NANOC
$(warning "*** nanoc is not available, please install ruby, gem and nanoc. ***")
$(warning "*** JISON website pages have NOT been updated! ***")
else
cd web/ && nanoc compile
-@rm -rf docs/
-mkdir -p docs
cp -r web/output/jison/* docs/
endif
web/content/assets/js/jison.js: build
@[ -a node_modules/.bin/browserify ] || echo "### FAILURE: Make sure you run 'make prep' before as the browserify tool is unavailable! ###"
sh node_modules/.bin/browserify entry.js --exports require > web/content/assets/js/jison.js
preview:
ifndef NANOC
$(error "nanoc is not available, please install ruby, gem and nanoc")
else
cd web/ && nanoc view &
open http://localhost:3000/jison/
endif
# `make deploy` is `make site` plus GIT checkin of the result into the gh-pages branch
deploy: site
#git checkout gh-pages
#cp -r web/output/jison/* ./
#git add . --all
git commit -a -m 'Deploy site updates'
#git checkout master
test:
$(MOCHA) --timeout 18000 --check-leaks --globals assert --recursive tests/
analyze-coverage:
istanbul cover test/unit-tests.js
check-coverage:
istanbul check-coverage --statement 96 --branch 96 --function 96
dynamic-analysis: analyze-coverage check-coverage
clean-nyc:
# clear the coverage cache, etc.
-rm -rf ./.nyc_output
-rm -rf ./coverage/
test-nyc:
# DO NOT clear the coverage cache, etc.: earlier build tasks MAY also have contributed coverage info!
cd packages/helpers-lib && make test-nyc
cd packages/lex-parser && make test-nyc
cd packages/jison-lex && make test-nyc
cd packages/ebnf-parser && make test-nyc
cd packages/json2jison && make test-nyc
cd packages/jison2json && make test-nyc
$(NYC) --reporter=lcov --reporter=text --exclude 'examples/issue-lex*.js' -- $(MOCHA) --timeout 18000 --check-leaks --globals assert --recursive tests/
-rm -rf ./coverage/
# report PRELIMINARY collective coverage results:
$(NYC) report --reporter=html
report-nyc:
-rm -rf ./coverage/
# report collective coverage results:
$(NYC) report --reporter=html
web-examples: web/content/assets/js/calculator.js
examples: examples_directory
web/content/assets/js/calculator.js: examples/calculator.jison build
$(JISON) examples/calculator.jison -o $@
comparison:
cd examples/ && make comparison
lexer-comparison: build
cd packages/jison-lex && make comparison
examples_directory: build
cd examples/ && make all
examples-test: build
cd examples/ && make error-handling-tests basic-tests github-issue-tests misc-tests
error-handling-tests: build
cd examples/ && make error-handling-tests
basic-tests: build
cd examples/ && make basic-tests
github-issue-tests: build
cd examples/ && make github-issue-tests
misc-tests: build
cd examples/ && make misc-tests
examples/ansic: build
cd examples/ && make ansic
examples/basic: build
cd examples/ && make basic
examples/basic2: build
cd examples/ && make basic2
examples/basic2_lex: build
cd examples/ && make basic2_lex
examples/basic_lex: build
cd examples/ && make basic_lex
examples/basic_w_error_rule: build
cd examples/ && make basic_w_error_rule
examples/bloop: build
cd examples/ && make bloop
examples/btyacc-ansiC: build
cd examples/ && make btyacc-ansiC
examples/btyacc-ansiC2: build
cd examples/ && make btyacc-ansiC2
examples/btyacc-ftp: build
cd examples/ && make btyacc-ftp
examples/btyacc-t1: build
cd examples/ && make btyacc-t1
examples/btyacc-t2: build
cd examples/ && make btyacc-t2
examples/c99: build
cd examples/ && make c99
examples/calc_LA_on_demand: build
cd examples/ && make calc_LA_on_demand
examples/calculator: build
cd examples/ && make calculator
examples/calculator_json: build
cd examples/ && make calculator_json
examples/ccalc: build
cd examples/ && make ccalc
examples/classy: build
cd examples/ && make classy
examples/classy_ast: build
cd examples/ && make classy_ast
examples/comments: build
cd examples/ && make comments
examples/compiled_calc: build
cd examples/ && make compiled_calc
examples/dism: build
cd examples/ && make dism
examples/dism_lr0: build
cd examples/ && make dism_lr0
examples/dot: build
cd examples/ && make dot
examples/error-handling-and-yyclearin: build
cd examples/ && make error-handling-and-yyclearin
examples/error-handling-and-yyerrok-loopfix: build
cd examples/ && make error-handling-and-yyerrok-loopfix
examples/error-handling-and-yyerrok-looping1: build
cd examples/ && make error-handling-and-yyerrok-looping1
examples/error-handling-and-yyerrok-looping2: build
cd examples/ && make error-handling-and-yyerrok-looping2
examples/error-handling-and-yyerrok-macro: build
cd examples/ && make error-handling-and-yyerrok-macro
examples/error-handling-and-yyerrok-part1: build
cd examples/ && make error-handling-and-yyerrok-part1
examples/error-handling-and-yyerrok-part2: build
cd examples/ && make error-handling-and-yyerrok-part2
examples/error-handling-and-yyerrok-part3: build
cd examples/ && make error-handling-and-yyerrok-part3
examples/error-handling-and-yyerrok-part4a: build
cd examples/ && make error-handling-and-yyerrok-part4a
examples/error-handling-and-yyerrok-part4b: build
cd examples/ && make error-handling-and-yyerrok-part4b
examples/error-handling-and-yyerrok-part5: build
cd examples/ && make error-handling-and-yyerrok-part5
examples/error-only: build
cd examples/ && make error-only
examples/error-recognition-actions: build
cd examples/ && make error-recognition-actions
examples/faking-multiple-start-rules: build
cd examples/ && make faking-multiple-start-rules
examples/faking-multiple-start-rules-alt: build
cd examples/ && make faking-multiple-start-rules-alt
examples/flow: build
cd examples/ && make flow
examples/formula: build
cd examples/ && make formula
examples/fsyacc-cgrammar: build
cd examples/ && make fsyacc-cgrammar
examples/gantt: build
cd examples/ && make gantt
examples/grammar: build
cd examples/ && make grammar
examples/handlebars: build
cd examples/ && make handlebars
examples/happyhappy: build
cd examples/ && make happyhappy
examples/inherited_y: build
cd examples/ && make inherited_y
examples/issue-205: build
cd examples/ && make issue-205
examples/issue-205-2: build
cd examples/ && make issue-205-2
examples/issue-205-3: build
cd examples/ && make issue-205-3
examples/issue-205-4: build
cd examples/ && make issue-205-4
examples/issue-254: build
cd examples/ && make issue-254
examples/issue-289: build
cd examples/ && make issue-289
examples/issue-293: build
cd examples/ && make issue-293
examples/issue-342: build
cd examples/ && make issue-342
examples/issue-344: build
cd examples/ && make issue-344
examples/issue-344-2: build
cd examples/ && make issue-344-2
examples/issue-348: build
cd examples/ && make issue-348
examples/issue-357-url-lexing: build
cd examples/ && make issue-357-url-lexing
examples/issue-360: build
cd examples/ && make issue-360
examples/jscore: build
cd examples/ && make jscore
examples/json_ast_js: build
cd examples/ && make json_ast_js
examples/json_js: build
cd examples/ && make json_js
examples/klammergebirge: build
cd examples/ && make klammergebirge
examples/lalr-but-not-slr: build
cd examples/ && make lalr-but-not-slr
examples/lambdacalc: build
cd examples/ && make lambdacalc
examples/lex: build
cd examples/ && make lex
examples/lojban-300: build
cd examples/ && make lojban-300
examples/lr-but-not-lalr: build
cd examples/ && make lr-but-not-lalr
examples/mermaid: build
cd examples/ && make mermaid
examples/mfcalc: build
cd examples/ && make mfcalc
examples/no-prec-hack-needed: build
cd examples/ && make no-prec-hack-needed
examples/codegen-feature-tester: build
cd examples/ && make codegen-feature-tester
examples/nv_classy_ast: build
cd examples/ && make nv_classy_ast
examples/olmenu-proto2: build
cd examples/ && make olmenu-proto2
examples/parser-to-lexer-communication-test: build
cd examples/ && make parser-to-lexer-communication-test
examples/parser-to-lexer-communication-test--profiling: build
cd examples/ && make parser-to-lexer-communication-test--profiling
profiling:
cd examples/ && make profiling
examples/pascal: build
cd examples/ && make pascal
examples/phraser: build
cd examples/ && make phraser
examples/precedence: build
cd examples/ && make precedence
examples/reduce_conflict: build
cd examples/ && make reduce_conflict
examples/regex: build
cd examples/ && make regex
examples/semwhitespace: build
cd examples/ && make semwhitespace
examples/test-EOF-bugfix: build
cd examples/ && make test-EOF-bugfix
examples/test-epsilon-rules-early-reduce: build
cd examples/ && make test-epsilon-rules-early-reduce
examples/test-literal-quote-tokens-in-grammar: build
cd examples/ && make test-literal-quote-tokens-in-grammar
examples/test-nonassociative-operator-0: build
cd examples/ && make test-nonassociative-operator-0
examples/test-nonassociative-operator-1: build
cd examples/ && make test-nonassociative-operator-1
examples/test-nonassociative-operator-2: build
cd examples/ && make test-nonassociative-operator-2
examples/test-propagation-rules-reduction-1: build
cd examples/ && make test-propagation-rules-reduction-1
examples/theory-left-recurs-01: build
cd examples/ && make theory-left-recurs-01
examples/tikiwikiparser: build
cd examples/ && make tikiwikiparser
examples/unicode: build
cd examples/ && make unicode
examples/unicode2: build
cd examples/ && make unicode2
examples/with-includes: build
cd examples/ && make with-includes
examples/with_custom_lexer: build
cd examples/ && make with_custom_lexer
examples/yacc-error-recovery: build
cd examples/ && make yacc-error-recovery
build: \
subpackages \
prep_util_dir \
dist/cli-cjs-es5.js \
packages/ebnf-parser/ebnf.y \
packages/ebnf-parser/bnf.y \
packages/ebnf-parser/bnf.l \
packages/lex-parser/lex.y \
packages/lex-parser/lex.l
npm-install:
npm install
npm-update: subpackages-npm-update
ncu -a --packageFile=package.json
-rm -f package-lock.json
prep_util_dir:
#@[ -d node_modules/jison-gho/dist ] || echo "### FAILURE: Make sure you have run 'make prep' before as the jison compiler backup utility files are unavailable! ###"
#@[ -f node_modules/jison-gho/dist/cli-cjs-es5.js ] || echo "### FAILURE: Make sure you have run 'make prep' before as the jison compiler backup utility files are unavailable! ###"
-mkdir -p dist
#+[ -f dist/cli-cjs-es5.js ] || ( cp node_modules/jison-gho/dist/cli-cjs-es5.js dist/cli-cjs-es5.js && touch -d 1970/1/1 dist/cli-cjs-es5.js )
dist/cli-cjs-es5.js: dist/jison.js rollup.config-cli.js
node __patch_version_in_js.js
-mkdir -p dist
$(ROLLUP) -c rollup.config-cli.js
$(BABEL) dist/cli-cjs.js -o dist/cli-cjs-es5.js
$(BABEL) dist/cli-umd.js -o dist/cli-umd-es5.js
node __patch_nodebang_in_js.js
dist/jison.js: rollup.config.js
node __patch_version_in_js.js
node __patch_parser_kernel_in_js.js
-mkdir -p dist
$(ROLLUP) -c
$(BABEL) dist/jison-cjs.js -o dist/jison-cjs-es5.js
$(BABEL) dist/jison-umd.js -o dist/jison-umd-es5.js
subpackages: helpers-lib lex-parser jison-lex ebnf-parser json2jison jison2json
helpers-lib:
cd packages/helpers-lib && make
lex-parser:
cd packages/lex-parser && make
jison-lex:
cd packages/jison-lex && make
ebnf-parser:
cd packages/ebnf-parser && make
json2jison:
cd packages/json2jison && make
jison2json:
cd packages/jison2json && make
subpackages-prep:
cd packages/helpers-lib && make prep
cd packages/lex-parser && make prep
cd packages/jison-lex && make prep
cd packages/ebnf-parser && make prep
cd packages/jison2json && make prep
cd packages/json2jison && make prep
subpackages-npm-update:
cd packages/helpers-lib && make npm-update
cd packages/lex-parser && make npm-update
cd packages/jison-lex && make npm-update
cd packages/ebnf-parser && make npm-update
cd packages/jison2json && make npm-update
cd packages/json2jison && make npm-update
# increment the XXX <prelease> number in the package.json file: version <major>.<minor>.<patch>-<prelease>
bump:
npm version --no-git-tag-version prerelease
node __patch_version_in_js.js
git-tag:
node -e 'var pkg = require("./package.json"); console.log(pkg.version);' | xargs git tag
git:
-git pull --all
-git push --all
subpackages-publish:
cd packages/helpers-lib && make publish
cd packages/lex-parser && make publish
cd packages/jison-lex && make publish
cd packages/ebnf-parser && make publish
cd packages/jison2json && make publish
cd packages/json2jison && make publish
publish: subpackages-publish
npm run pub
clean: clean-site
cd examples/ && make clean
cd packages/helpers-lib && make clean
cd packages/lex-parser && make clean
cd packages/jison-lex && make clean
cd packages/ebnf-parser && make clean
cd packages/jison2json && make clean
cd packages/json2jison && make clean
#
# When you've run `make superclean` you must run `make prep`, `make` and `make deploy` to regenerate all content again.
#
# The 'superclean' target is to be used when you need to update/edit the jison code generators and want to
# make sure that jison is rebuilt from scratch.
# The 'superclean' target is also useful in the above context for it enables you to find the 'originals'
# of each part of the generator (lexer & parser) as all derived copies have been killed.
#
superclean: clean clean-site
-rm -rf node_modules/
-rm -f package-lock.json
cd examples/ && make superclean
cd packages/helpers-lib && make superclean
cd packages/lex-parser && make superclean
cd packages/jison-lex && make superclean
cd packages/ebnf-parser && make superclean
cd packages/jison2json && make superclean
cd packages/json2jison && make superclean
-rm -rf dist
-find . -type d -name 'node_modules' -exec rm -rf "{}" \;
# recover old jison run-time so we can bootstrap without failure and need for manual git-revert action
git checkout dist/
.PHONY: all everything \
prep subpackages-prep \
helpers-lib lex-parser jison-lex ebnf-parser json2jison jison2json \
site preview deploy test web-examples examples examples-test \
examples_directory comparison lexer-comparison \
error-handling-tests basic-tests github-issue-tests misc-tests \
build npm-install \
subpackages \
clean superclean git prep_util_dir \
bump \
git-tag subpackages-git-tag \
compile-site clean-site \
publish subpackages-publish \
npm-update subpackages-npm-update \
test-nyc clean-nyc report-nyc