Skip to content

Commit

Permalink
add docs (#20)
Browse files Browse the repository at this point in the history
* add docs
* add yaspeller-ci and documendation
  • Loading branch information
MikeDevice committed Jan 2, 2020
1 parent 808e5c2 commit 4fdf64e
Show file tree
Hide file tree
Showing 8 changed files with 4,342 additions and 923 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
api.md
*.log
3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"*.js": "nrun lint"
"*.js": "nrun lint",
"*.md": "nrun spellcheck",
}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
node_modules
coverage
api.md
test

.editorconfig
.eslintrc.json
.huskyrc
.lintstagedrc
.travis.yml
.yaspellerrc
jest.config.js
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ node_js:
script:
- npm run lint
- npm run size
- npm run spellcheck
- npm run test -- --coverage --coverageReporters=text-lcov | coveralls
9 changes: 9 additions & 0 deletions .yaspellerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"lang": "en",
"dictionary": [
"getFirstSets",
"getFollowSets",
"getPredictSets",
"gzipped"
]
}
51 changes: 50 additions & 1 deletion lib/Grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ const {
module.exports = class Grammar {
/**
* Create a Grammar.
* @param {array} rules -- The array of rules.
* @param {Array.<object>} rules The array of rules.
*
* @example
* const { Grammar } = require('first-follow');
* const grammar = new Grammar([{
* left: 'S',
* right: ['a']
* }]);
*/
constructor(rules) {
this.rules = rules;
Expand All @@ -25,14 +32,56 @@ module.exports = class Grammar {
this.predictSets = this._makePredictSets();
}

/**
* Get first sets for the grammar.
*
* @return {Object.<string, Array.<string>>} The object that represents the first sets.
*
* @example
* const { Grammar } = require('first-follow');
* const grammar = new Grammar([{
* left: 'S',
* right: ['a']
* }]);
*
* grammar.getFirstSets(); //=> { S: ['a'] }
*/
getFirstSets() {
return this.firstSets;
}

/**
* Get follow sets for the grammar.
*
* @return {Object.<string, Array.<string>>} The object that represents the follow sets.
*
* @example
* const { Grammar } = require('first-follow');
* const grammar = new Grammar([{
* left: 'S',
* right: ['a']
* }]);
*
* grammar.getFollowSets(); //=> { S: ['\u0000'] }
*/
getFollowSets() {
return this.followSets;
}

/**
* Get predict sets for the grammar.
*
* @return {Object.<string, Array.<string>>} The object that represents the predict sets.
*
* @example
* const { Grammar } = require('first-follow');
* const grammar = new Grammar([{
* left: 'S',
* right: ['a']
* }]);
*
* grammar.getPredictSets(); //=> { '1': ['a'] }
*/
getPredictSets() {
return this.predictSets;
}
Expand Down
Loading

0 comments on commit 4fdf64e

Please sign in to comment.