Skip to content

Commit

Permalink
Merge branch 'v1.0.0' of https://github.com/superscriptjs/ss-parser i…
Browse files Browse the repository at this point in the history
…nto v1.0.0
  • Loading branch information
Rob Ellis committed Dec 27, 2016
2 parents 747b650 + f378f8b commit 83f5fb2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ss-parser",
"version": "1.0.0-alpha14",
"version": "1.0.0-alpha16",
"description": "The parser interface for SuperScript",
"main": "./lib/index.js",
"repository": {
Expand All @@ -17,28 +17,28 @@
"license": "MIT",
"homepage": "https://github.com/superscriptjs/ss-parser",
"dependencies": {
"async": "^2.1.2",
"async": "^2.1.4",
"async-replace": "^1.0.1",
"bot-lang": "^1.0.3",
"bot-lang": "^1.0.7",
"checksum": "^0.1.1",
"debug": "^2.3.0",
"lodash": "^4.11.1",
"debug": "^2.5.1",
"lodash": "^4.17.2",
"pegjs": "^0.10.0",
"recursive-readdir": "^2.1.0",
"wordpos": "^1.1.0"
"wordpos": "^1.1.1"
},
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-preset-env": "^1.0.2",
"babel-preset-env": "^1.1.4",
"babel-register": "^6.18.0",
"coveralls": "^2.11.9",
"coveralls": "^2.11.15",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.6.0",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^3.1.2",
"should": "^11.1.1"
"mocha": "^3.2.0",
"should": "^11.1.2"
}
}
64 changes: 32 additions & 32 deletions src/ss-grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
}

start
= data:(gambitsStart:gambits?
data:(topics:topics gambits:gambits? { return { topics, gambits }; })*
{
var topics = [];
var gambits = [];
data.forEach((data) => {
if (data.topics) data.topics.forEach((topic) => topics.push(topic));
if (data.gambits) data.gambits.forEach((gambit) => gambits.push(gambit));
});
if (gambitsStart) gambitsStart.forEach((gambit) => gambits.push(gambit));
return { topics, gambits };
= data:gambitsOrTopic*
{
const topics = [];
const gambits = [];
data.forEach((item) => {
if (item.type === 'gambits') {
item.payload.forEach(gambit => gambits.push(gambit));
} else if (item.type === 'topic') {
topics.push(item.payload);
}
) {
return data;
}
});
return { topics, gambits };
}

gambitsOrTopic
= gambits:gambits { return { type: 'gambits', payload: gambits }; }
/ topic:topic nlOrEOF { return { type: 'topic', payload: topic }; }

argCharacter
= "\\" char:[()] { return char; }
Expand Down Expand Up @@ -141,9 +143,6 @@ topic
};
}

topics
= topics:(topic:topic nl+ { return topic; })+ { return topics; }

string
= str:[a-zA-Z]+ { return { type: "string", val: str.join("")}; }

Expand Down Expand Up @@ -280,9 +279,8 @@ gambit
};
}


gambitsBlock
= conditional:conditional ws* "{" nl+ gambits:(gambit:gambit nl+ { return gambit; })+ nl* ws* "}" nl+
gambitBlock
= conditional:conditional ws* "{" nl+ gambits:(gambit:gambit nl+ { return gambit; })+ nl* ws* "}" nlOrEOF
{
gambits.forEach((gambit) => {
if (gambit.conditional) {
Expand All @@ -293,24 +291,26 @@ gambitsBlock
});
return gambits;
}
/ gambits:(gambit:gambit nl+ { return gambit; })+
{ return gambits; }
/ gambits:(gambit:gambit nlOrEOF { return gambit; })+
{ return gambits; }

gambits
= gambitsBlock:gambitsBlock+
{
var returnedGambits = [];
gambitsBlock.forEach((gambitBlock) => {
gambitBlock.forEach((gambit) => {
returnedGambits.push(gambit);
});
});
return returnedGambits;
}
= gambitBlocks:gambitBlock+
{
let gambits = [];
gambitBlocks.forEach((gambitBlock) => {
gambits = gambits.concat(gambitBlock);
});
return gambits;
}

integer "integer"
= digits:[0-9]+ { return makeInteger(digits); }

ws "whitespace" = [ \t]

nl "newline" = [\n\r]

nlOrEOF
= nl+
/ !.

0 comments on commit 83f5fb2

Please sign in to comment.