Skip to content

Commit

Permalink
Allow whitespaces in argument list in erl/erlgo
Browse files Browse the repository at this point in the history
Now, it is possible to have white spaces, before comma character in our
simple parser. Still some more whitespace ignoring is needed to supports
things like:   "module : function ()", but it looks that all white space
problems in argument list is solved.
  • Loading branch information
baryluk committed Dec 20, 2011
1 parent 97aacec commit 824f3e5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions js_src/erljs_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ function erl(X, ShowInput) {
var r = /^\s*([^:]+):([^(]+)\((.*)\)\.?\s*$/;
var m = r.exec(X);
if (m) {
/*
var args = m[3].length==0 ? [] : m[3].split(/,/);
var arity = args.length;
for (var i = 0; i < arity; i++) {
args[i] = new Number(args[i]);
}
*/

var args = [];
var A = 0;
if (m[3].length) {
var s = m[3];
if (s.length) {
var i = 0;
var a = get_next(m[3],i,false);
var a = get_next(s,i,false);
args[A++]=a[0];
i=a[1];
while (m[3][i] == ",") {
// skip white space
while ((s[i] == " " || s[i] == "\t" || s[i] == "\n" || s[i] == "\r") && i < s.length) {
i++;
var a = get_next(m[3],i,false);
}
while (s[i] == ",") {
i++;
var a = get_next(s,i,false);
args[A++]=a[0];
i=a[1];
while ((s[i] == " " || s[i] == "\t" || s[i] == "\n" || s[i] == "\r") && i < s.length) {
i++;
}
}
if (i != m[3].length) throw "bad syntax in arguments list";
}
Expand Down

0 comments on commit 824f3e5

Please sign in to comment.