Skip to content

Commit fb0e16c

Browse files
committed
Work for 0.1.0 release
0 parents  commit fb0e16c

17 files changed

+6370
-0
lines changed

.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
/*parserOptions: {
4+
project:'./tsconfig.json'
5+
},*/
6+
plugins: ['@typescript-eslint'],
7+
extends: ['plugin:@typescript-eslint/recommended'],
8+
rules: {
9+
"indent": "off",
10+
"semi": "error",
11+
"@typescript-eslint/camelcase": "off",
12+
"@typescript-eslint/indent": ["error", 2],
13+
// not yet released - "@typescript-eslint/semi": ["error"]
14+
}
15+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.DS_Store

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Matthew Peveler
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
parser.js
2+
=========
3+
4+
[![Build Status](https://travis-ci.com/OpenReasoning/parser.js.svg?branch=master)](https://travis-ci.com/OpenReasoning/parser.js)
5+
6+
A parser to be used in logic programs.
7+
8+
This parses formulas within three styles (prefix, infix, and functional) returning
9+
a tree structure of the captured elements.
10+
11+
Installation
12+
------------
13+
```bash
14+
npm install @openreasoning/parser
15+
```
16+
17+
Usage
18+
-----
19+
```typescript
20+
import {prefixParser, infixParser, functionalParser, Node} from '@openreasoning/parser'
21+
22+
let parsed = prefixParser('(and a b)');
23+
let parsed2 = infixParser('(a and b)');
24+
let parsed3 = functionalParser('and(a, b)');
25+
26+
function isEqual(a: Node, b: Node): bool {
27+
if (a.value !== b.value || a.children.length !== b.children.length) {
28+
return false;
29+
}
30+
for (let i = 0; i < a.children.length; i++) {
31+
if (!isEqual(a.children[i], b.children[i])) {
32+
return false;
33+
}
34+
}
35+
return true;
36+
}
37+
38+
console.log(isEqual(parsed, parsed2)); // true
39+
console.log(isEqual(parsed2, parsed3)); // true
40+
```
41+
42+
License
43+
-------
44+
45+
This is uses the [MIT License](./LICENSE.md)

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
rootDir: '.',
3+
roots: ['<rootDir>/test'],
4+
transform: {
5+
'^.+\\.tsx?$': 'ts-jest',
6+
},
7+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
8+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
9+
collectCoverage: true,
10+
collectCoverageFrom: [
11+
'<rootDir>/src/**/*.ts',
12+
'!<rootDir>/src/**/*.d.ts'
13+
],
14+
coverageDirectory: '<rootDir>/coverage',
15+
coverageReporters: ['html', 'lcov', 'text']
16+
}

0 commit comments

Comments
 (0)