Skip to content

Commit bf3a851

Browse files
author
Thomas Bell
committed
updated parser to handle empty string
1 parent 6c41785 commit bf3a851

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

lexersrc/parser.y

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
%%
88

99
parsedargs
10-
: arguments EOF
10+
: EOF
11+
{
12+
$$ = [undefined];
13+
return $$
14+
}
15+
| arguments EOF
1116
{
1217
$$ = $1;
1318
return $$;
@@ -19,19 +24,19 @@ arguments
1924
$$ = [$1];
2025
}
2126
| JSON
22-
{{
27+
{
2328
$$ = [$1];
24-
}}
29+
}
2530
| arguments stringarg
2631
{
2732
$1.push($2);
2833
$$ = $1;
2934
}
3035
| arguments JSON
31-
{{
36+
{
3237
$1.push($2)
3338
$$ = $1;
34-
}}
39+
}
3540
;
3641

3742
stringarg

src/Parser.js

Lines changed: 19 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/spec/tests.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe('Service: ngDragDropService', function() {
179179
var callbackName = "startDrag("+ JSON.stringify(expectedData) +")";
180180
ngDragDropService.callEventCallback(localScope, callbackName, {}, {});
181181
});
182-
182+
183183
it('should parse json objects along with non json objects', function(){
184184
var localScope = rootScope.$new();
185185
var expectedData = {r1: 1, r2: 2};
@@ -203,4 +203,17 @@ describe('Service: ngDragDropService', function() {
203203
ngDragDropService.callEventCallback(localScope, callbackName, {}, {});
204204
});
205205

206+
it('should parse empty arguments', function(){
207+
var localScope = rootScope.$new();
208+
var expectedEvent = {"foo": "bar"};
209+
var expectedUI = {"bar":"baz"};
210+
localScope.startDrag = function(event, ui, data){
211+
expect(event).toEqual(expectedEvent);
212+
expect(expectedUI).toEqual(expectedUI);
213+
expect(data).toBe(undefined);
214+
};
215+
var callbackName = "startDrag()";
216+
ngDragDropService.callEventCallback(localScope, callbackName, expectedEvent, expectedUI);
217+
});
218+
206219
});

0 commit comments

Comments
 (0)