/* Modification information for LGPL compliance r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm r4085 - 2005-04-13 17:30:42 -0700 (Wed, 13 Apr 2005) - robert - adding meeting scheduler and accept/decline */ /* Copyright (c) 2004 Jan-Klaas Kollhof This file is part of the JavaScript o lait library(jsolait). jsolait is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** Module providing language services like tokenizing JavaScript code or converting JavaScript objects to and from JSON (see json.org). To customize JSON serialization of Objects just overwrite the toJSON method in your class. */ Module("lang", "0.3.7", function(mod){ var ISODate = function(d){ if(/^(\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})/.test(d)){ return new Date(Date.UTC(RegExp.$1, RegExp.$2-1, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6)); }else{ //todo error message throw new mod.Exception("Not an ISO date: " + d); } } mod.JSONParser=Class("JSONParser", function(publ, supr){ publ.init=function(){ this.libs = {}; var sys = {"ISODate" : ISODate}; this.addLib(sys, "sys", ["ISODate"]); } publ.addLib = function(obj, name, exports){ if(exports == null){ this.libs[name] = obj; }else{ for(var i=0;i": case "!": case "|": case "&": switch(s2){ case "==": case "!=": case "<>": case "<=": case ">=":case "||": case "&&": rslt = new mod.Token(mod.tokens.OP, s2, this._pos); break; default: rslt = new mod.Token(mod.tokens.OP, s1, this._pos); } break; case "/": if(s2 == "//" || s3 =="///"){ s1 = extractSLComment(this._working); rslt = new mod.Token(s1.charAt(2) != "/" ? mod.tokens.COMMENT:mod.tokens.DOCCOMMENT, s1, this._pos); }else if(s2 == "/*" || s3 =="/**"){ try{ s1 = extractMLComment(this._working); rslt = new mod.Token(s3 !="/**" ? mod.tokens.COMMENT: mod.tokens.DOCCOMMENT, s1, this._pos); }catch(e){ rslt= new mod.Token(mod.tokens.ERR, s3 != "/**" ? s2 : s3, this._pos, e); } }else{ try{ s1 = extractRegExp(this._working); rslt = new mod.Token(mod.tokens.REGEXP, s1, this._pos); }catch(e){ rslt = new mod.Token(mod.tokens.OP, s1, this._pos, e); } } break; case " ": var i = 0; var s=""; while(this._working.charAt(i) == " "){ s+=" "; i++; } rslt = new mod.Token(mod.tokens.WSP, s, this._pos); break; default: s1=this._working.match(/\d+\.\d+|\d+|\w+/)[0]; if(/^\d|\d\.\d/.test(s1)){//number rslt = new mod.Token(mod.tokens.NUM, s1, this._pos); }else{//name rslt =new mod.Token(mod.tokens.NAME, s1, this._pos); } } this._working=this._working.slice(rslt.value.length); this._pos += rslt.value.length; return rslt; } var searchQoute = function(s, q){ if(q=="'"){ return s.search(/[\\']/); }else{ return s.search(/[\\"]/); } } var extractQString=function(s){ if(s.charAt(0) == "'"){ var q="'"; }else{ var q='"'; } s=s.slice(1); var rs=""; var p= searchQoute(s, q); while(p >= 0){ if(p >=0){ if(s.charAt(p) == q){ rs += s.slice(0, p+1); s = s.slice(p+1); return q + rs; }else{ rs+=s.slice(0, p+2); s = s.slice(p+2); } } p = searchQoute(s, q); } throw new mod.Exception("End of String expected."); } var extractSLComment=function(s){ var p = s.search(/\n/); if(p>=0){ return s.slice(0,p+1); }else{ return s; } } var extractMLComment=function(s){ var p = s.search(/\*\//); if(p>=0){ return s.slice(0,p+2); }else{ throw new mod.Exception("End of comment expected."); } } var extractRegExp=function(s){ var p=0; for(var i=0;i