Skip to content

Commit

Permalink
fix(grammar): scards has a space between each card
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Sep 16, 2016
1 parent 99fb02e commit b4ed913
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function ast(kind) {
/* Tokens */
g.addRule('port', p.number());
g.addRule('protocolVersion', p.number());
setExample('protocolVersion', '18');
g.addRule('teamName', p.string());

/* Expressions */
Expand Down Expand Up @@ -80,7 +81,12 @@ g.addRule('card', p.regex(/^[AKQJT98765432][SHDC]/, 'KH'));

g.addRule('scards', p.either(
p.keyword('-', true),
p.regex(/^[AKQJT98765432]+/, 'AJ43')
p
.regex(/^[AKQJT98765432 ]+/, 'A J 4 3')
.op((stack, cb) => {
stack.push(stack.pop().replace(/ /g,''));
cb();
})
));
g.addRule('hand',
p.kleene(
Expand All @@ -99,7 +105,7 @@ g.addRule('hand',
cb();
})
);
setExample('hand', 'S AKJ43. H -. D 6543. C QJT9.');
setExample('hand', 'S A K J 4 3. H -. D 6 5 4 3. C Q J T 9.');

g.addRule('someCards',
p.sequence(
Expand Down
2 changes: 1 addition & 1 deletion test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Parser', () => {
});

it('should have specific properties of the cards message', done => {
let msg = "north's cards : S AKJ43. H -. D 6543. C QJT9.";
let msg = "north's cards : S A K J 4 3. H -. D 6 5 4 3. C Q J T 9.";
tm.parse(msg, (err, ast) => {
if(err) {
done(err);
Expand Down

0 comments on commit b4ed913

Please sign in to comment.