Skip to content

Commit b31a8e3

Browse files
committed
Initial commit.
0 parents  commit b31a8e3

File tree

115 files changed

+16847
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+16847
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.*
2+
!.gitignore
3+
*~
4+
*.log
5+
*.out
6+
*.zip
7+
*.tgz
8+
*.html
9+
**html/
10+
!dist/guide/*
11+
**node_modules/
12+
**docs/
13+
**input/
14+
**output/
15+
**tmp/
16+
**test/
17+

LICENSE.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause)
2+
3+
<p>
4+
Copyright (c) 2021 Lowell D. Thomas<br>
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
1. Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
13+
2. Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
</p>

README.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# JavaScript APG
2+
3+
## What's New
4+
5+
`apg-js` obsoletes `apg`, `apg-lib`, `apg-exp`, `apg-conv`, `apg-conv-api` and `apg-api`. It changes them in two significant ways.
6+
7+
- It fixes a major problem in the attributes algorithm. Previous versions could fail on large grammars with many or large sets of mutually-recursive rules.
8+
- It combines all of those packages into a single, easier to manage and maintain package.
9+
10+
## Overview
11+
12+
`apg-js` is the JavaScript version of APG, an ABNF Parser Generator. APG generates recursive-descent parsers directly from a superset of [ABNF](https://tools.ietf.org/html/rfc5234) (SABNF). Visit the [APG](https://sabnf.com/`) website for a complete [overview](https://sabnf.com/overview/) of APG and SABNF.
13+
14+
## Installation
15+
16+
> `npm install apg-js`
17+
18+
or
19+
20+
> `git clone https://github.com/ldthomas/apg-js.git`
21+
22+
## Documentation
23+
24+
This package is meant to assist other parsing applications and is normally not installed by itself, rather installed along with those other applications. For details and many examples of using of the libraries, both in node.js and browser applications, see `apg-js-examples` at [GitHub](https://github.com/ldthomas/apg-js-examples) or [npmjs](https://www.npmjs.com/package/apg-js-examples).
25+
However, it does provide access to two, node.js applications.
26+
27+
### Applications
28+
29+
`apg` is the parser generator. To see its usage run,
30+
31+
> `npm run apg`
32+
33+
`apg-conv` is a data conversion application. To see its usage run,
34+
35+
> `npm run apg-conv`
36+
37+
### Libraries
38+
39+
This package also contains four libraries that can be used in either node.js or browser applications.
40+
The libraries depend upon one another and the dependency tree looks like so:
41+
42+
```
43+
apg-exp
44+
|- apg-api
45+
|-|- apg-lib
46+
|-|-|- apg-conv-api
47+
```
48+
49+
Each of the libraries is bundled for browser use along with some special styles.
50+
Each bundle contains all of its dependencies explicitly. That is, if a browser application needs both `apg-api` and `apg-lib`, only the `apg-api` bundle need be scripted into the page.
51+
52+
The library and css bundles are in the `./dist` directory.
53+
54+
```
55+
./dist/apg-exp-bundle.js
56+
./dist/apg-api-bundle.js
57+
./dist/apg-lib-bundle.js
58+
./dist/apg-conv-api-bundle.js
59+
./dist/apg-lib-bundle.css
60+
```
61+
62+
The bundles can all be regenerated with:
63+
64+
```
65+
npm install -g [email protected]
66+
npm install -g [email protected]
67+
npm install -g [email protected]
68+
npm run bundle-apg-conv-api
69+
npm run bundle-apg-lib
70+
npm run bundle-apg-api
71+
npm run bundle-apg-exp
72+
npm run bundle-apg-lib-css
73+
```
74+
75+
### Code Documentation
76+
77+
The code documentation is in [docco](http://ashkenas.com/docco/) format and can be generated with:
78+
79+
```
80+
npm install -g [email protected]
81+
./bin/docco-gen.sh
82+
```
83+
84+
(Higher versions of docco may work, but some lower versions definitely do not.)
85+
The documentation is then at `./docs/index.html` or see it [here](https://sabnf.com/docs/java-script/apg-exp-guide/index.html) at the [APG](https://sabnf.com/) website.

bin/apg-api-bundle.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
browserify ./src/apg-api/web-exports.js > temp-bundle.js
3+
minify temp-bundle.js > ./dist/apg-api-bundle.js
4+
rm temp-bundle.js
5+
exit 0
6+

bin/apg-conv-api-bundle.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
browserify ./src/apg-conv-api/web-exports.js > temp-bundle.js
3+
minify temp-bundle.js > ./dist/apg-conv-api-bundle.js
4+
rm temp-bundle.js
5+
exit 0
6+

bin/apg-conv.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
(require("../src/apg-conv/apg-conv.js"))();

bin/apg-exp-bundle.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
browserify ./src/apg-exp/web-exports.js > temp-bundle.js
3+
minify temp-bundle.js > ./dist/apg-exp-bundle.js
4+
rm temp-bundle.js
5+
exit 0
6+

bin/apg-lib-bundle.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
browserify ./src/apg-lib/web-exports.js > temp-bundle.js
3+
minify temp-bundle.js > ./dist/apg-lib-bundle.js
4+
rm temp-bundle.js
5+
exit 0
6+

bin/apg.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require("../src/apg/apg.js")(process.argv.slice(2));

bin/docco-gen.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
docco -l classic index.md README.md LICENSE.md \
3+
./src/apg/*.js \
4+
./src/apg-api/*.js \
5+
./src/apg-conv/*.js \
6+
./src/apg-conv-api/*.js \
7+
./src/apg-exp/*.js \
8+
./src/apg-lib/*.js
9+
exit 0

dev/apg-lib-bundle-css.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env node
2+
3+
console.log(process.cwd());
4+
let toless = require("./jsonToLESS.js");
5+
let tojs = require("./jsonToCLASS_.js");
6+
let emitcss = require("./cssToJS.js");
7+
let exec = require("child_process").exec;
8+
9+
// 1. Create ./dist/temp.css (temporary, non-compressed)
10+
toless("./dev/style.json", "./temp.less");
11+
console.log("complete: create ./temp.less");
12+
exec("cat ./temp.less ./dev/apg-lib.less > ./temp-cat.less", (error, stdout, stderr) => {
13+
if (error) {
14+
console.error(`exec error: cat ./temp.less ./apg-lib.less > ./temp-cat.less: ${error}`);
15+
return;
16+
}
17+
console.log("complete 1.: composite LESS file created, ./temp-cat.less");
18+
19+
// 2. LESS to create the css file
20+
exec("lessc ./temp-cat.less ./temp.css", (error, stdout, stderr) => {
21+
if (error) {
22+
console.error(`exec error: lessc ./temp-cat.less ./temp.css: ${error}`);
23+
return;
24+
}
25+
console.log("complete 2.: create the uncompressed css file, temp.css");
26+
27+
// 3. Create ./src/emitcss.js
28+
emitcss("./temp.css", "./src/apg-lib/emitcss.js");
29+
console.log("complete 3.: css file generates emitcss.js");
30+
31+
// 4. Create ./src/style.js
32+
tojs(".//dev/style.json", "./src/apg-lib/style.js");
33+
console.log("complete 4.: generate the style.js file");
34+
35+
// 5. compress css -> apg-lib-bundle.css
36+
exec("minify ./temp.css > ./dist/apg-lib-bundle.css", (error, stdout, stderr) => {
37+
if (error) {
38+
console.error(`exec error: minify ./temp.css > ../dist/apg-lib-bundle.css: ${error}`);
39+
return;
40+
}
41+
console.log("complete 5.: compress the css file");
42+
43+
// 6. delete temporary files
44+
exec("rm ./temp.less && rm ./temp-cat.less && rm ./temp.css", (error, stdout, stderr) => {
45+
if (error) {
46+
console.error(`exec error: rm ./temp.less && rm ./temp-cat.less && rm ./temp.css: ${error}`);
47+
return;
48+
}
49+
console.log("complete 6.: delete temporary files");
50+
});
51+
});
52+
});
53+
});
54+
55+
return;

0 commit comments

Comments
 (0)