Skip to content

Commit 2c41df9

Browse files
author
Thomas Bell
committed
added parser deps
1 parent 48b8161 commit 2c41df9

File tree

8 files changed

+822
-86
lines changed

8 files changed

+822
-86
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dependencies": {
1919
"angular": "~1.x",
2020
"jquery": "2.x",
21-
"jquery-ui": "latest"
21+
"jquery-ui": "latest",
22+
"jison":"git://github.com/zaach/jison.git"
2223
},
2324
"devDependencies": {
2425
"angular-mocks": "~1.x"

lexersrc/parser.lex

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
%{
2+
/* Note for future hackers */
3+
/* Jison by default gets the first matched item, working top down
4+
* This is NOT the same as lex, which matches longest
5+
* Adding the %option flex to the file will make jison work like lex
6+
* but, this is not heavily tested
7+
*
8+
* The safest thing to do is have more important rules before less
9+
* important rules, which is why . is last
10+
*/
11+
%}
12+
int "-"?([0-9]|[1-9][0-9]+)
13+
exp [eE][-+]?[0-9]+
14+
frac "."[0-9]+
15+
16+
%x json singleQuoteString dblQuoteString
17+
%flex
18+
%%
19+
20+
[^{,][^,]+ return 'LITERAL';
21+
"{" {
22+
saver.currText = "{";
23+
this.begin('json');
24+
}
25+
"," {
26+
// do nothing we don't want commas
27+
}
28+
<<EOF>> return 'EOF';
29+
30+
<json>"}" {
31+
saver.currText = saver.currText + yytext;
32+
if (saver.braceCount == 0) {
33+
yytext = saver.currText;
34+
saver.currText = "";
35+
this.popState();
36+
return 'JSON';
37+
}
38+
else {
39+
saver.braceCount -= 1;
40+
}
41+
}
42+
<json>"{" {
43+
saver.currText = saver.currText + yytext;
44+
saver.braceCount += 1;
45+
}
46+
<json><<EOF>> {
47+
yytext = saver.currText;
48+
saver.currText = "";
49+
this.popState();
50+
return 'EOF';
51+
}
52+
<json>\s+ { saver.currText = saver.currText + yytext; }
53+
<json>"'" { saver.currText = saver.currText + yytext; this.begin('singleQuoteString'); }
54+
<json>\" { saver.currText = saver.currText + yytext; this.begin('dblQuoteString'); }
55+
<json>"//" { this.begin('singleLineComment'); }
56+
<json>"/*" { this.begin('multiLineComment'); }
57+
<json>. { saver.currText = saver.currText + yytext; }
58+
59+
<singleQuoteString>"\'" { saver.currText = saver.currText + yytext; }
60+
<singleQuoteString>"'" { saver.currText = saver.currText + yytext; this.popState(); }
61+
<singleQuoteString>. { saver.currText = saver.currText + yytext; }
62+
63+
<dblQuoteString>"\\\"" { saver.currText = saver.currText + yytext; }
64+
<dblQuoteString>\" { saver.currText = saver.currText + yytext; this.popState(); }
65+
<dblQuoteString>. { saver.currText = saver.currText + yytext; }
66+
67+
%%
68+
69+
var saver = { currText: "", braceCount:0 }

lexersrc/parser.y

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
%start parsedargs
2+
3+
%{
4+
5+
%}
6+
7+
%%
8+
9+
parsedargs
10+
: arguments EOF
11+
{
12+
$$ = $1;
13+
return $$;
14+
}
15+
;
16+
arguments
17+
: stringarg
18+
{
19+
$$ = [$1];
20+
}
21+
| JSON
22+
{{
23+
$$ = [$1];
24+
}}
25+
| arguments stringarg
26+
{
27+
$1.push($2);
28+
$$ = $1;
29+
}
30+
| arguments JSON
31+
{{
32+
$1.push($2)
33+
$$ = $1;
34+
}}
35+
;
36+
37+
stringarg
38+
: LITERAL
39+
{
40+
$$ = $1;
41+
}
42+
| LITERAL stringarg
43+
{
44+
$$ = $1 + $2;
45+
}
46+
;
47+
48+
%%

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"license": "MIT",
77
"homepage": "http://codef0rmer.github.io/angular-dragdrop",
88
"main": "src/angular-dragdrop.js",
9-
"dependencies": {},
9+
"dependencies": {
10+
"jison":"*"
11+
},
1012
"devDependencies": {
1113
"grunt": "~0.4.1",
1214
"grunt-karma": "~0.4.4"

0 commit comments

Comments
 (0)