~ubuntu-branches/ubuntu/oneiric/haxe/oneiric

« back to all changes in this revision

Viewing changes to haxe/std/haxe/Template.hx

  • Committer: Bazaar Package Importer
  • Author(s): Jens Peter Secher
  • Date: 2009-03-18 23:09:50 UTC
  • mfrom: (3.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090318230950-pgfuxg2ucolps74t
Tags: 1:2.2-2
* Use ocamlfind to locate and use the libraries xml-light and extlib
  which already exist in Debian as separate packages.
  (Closes: #519630)
* Fixed compile error with camlp4 3.11, thanks to Stéphane Glondu.
  (Closes: #519627)
* Use quilt instead of dpatch for patches, and describe how to use
  quilt in Debian.source (thanks to Russ Allbery).
* Added a Vcs-Hg control filed to indicate the location of the public
  repository.
* Bumped Standards-Version to 3.8.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
class Template {
49
49
 
50
 
        static var splitter = ~/(::[A-Za-z0-9_ ()&|!+=\/><*.-]+::|\$\$([A-Za-z0-9_-]+)\()/;
51
 
        static var expr_splitter = ~/(\(|\)|[!+=\/><*.&|-]+)/;
 
50
        static var splitter = ~/(::[A-Za-z0-9_ ()&|!+=\/><*."-]+::|\$\$([A-Za-z0-9_-]+)\()/;
 
51
        static var expr_splitter = ~/(\(|\)|[ \r\n\t]*"[^"]*"[ \r\n\t]*|[!+=\/><*.&|-]+)/;
52
52
        static var expr_trim = ~/^[ ]*([^ ]+)[ ]*$/;
53
53
        static var expr_int = ~/^[0-9]+$/;
54
54
        static var expr_float = ~/^([+-]?)(?=\d|,\d)\d*(,\d*)?([Ee]([+-]?\d+))?$/;
55
55
 
56
 
        public static var globals = Reflect.empty();
 
56
        public static var globals : Dynamic = {};
57
57
 
58
58
        var expr : TemplateExpr;
59
59
        var context : Dynamic;
69
69
        }
70
70
 
71
71
        public function execute( context : Dynamic, ?macros : Dynamic ) {
72
 
                this.macros = if( macros == null ) Reflect.empty() else macros;
 
72
                this.macros = if( macros == null ) {} else macros;
73
73
                this.context = context;
74
74
                stack = new List();
75
75
                buf = new StringBuf();
197
197
                        var k = p.pos + p.len;
198
198
                        if( p.pos != 0 )
199
199
                                l.add({ p : data.substr(0,p.pos), s : true });
200
 
                        l.add({ p : expr_splitter.matched(0), s : false });
 
200
                        var p = expr_splitter.matched(0);
 
201
                        l.add({ p : p, s : p.indexOf('"') >= 0 });
201
202
                        data = expr_splitter.matchedRight();
202
203
                }
203
204
                if( data.length != 0 )
207
208
                        e = makeExpr(l);
208
209
                        if( !l.isEmpty() )
209
210
                                throw l.first().p;
210
 
                } catch( s : Int ) {
 
211
                } catch( s : String ) {
211
212
                        throw "Unexpected '"+s+"' in "+expr;
212
213
                }
213
214
                return function() {
222
223
        function makeConst( v : String ) : Void -> Dynamic {
223
224
                expr_trim.match(v);
224
225
                v = expr_trim.matched(1);
 
226
                if( v.charCodeAt(0) == 34 ) {
 
227
                        var str = v.substr(1,v.length-2);
 
228
                        return function() return str;
 
229
                }
225
230
                if( expr_int.match(v) ) {
226
231
                        var i = Std.parseInt(v);
227
232
                        return function() { return i; };
355
360
                                var msg = "Macro call "+m+"("+plstr+") failed ("+Std.string(e)+")";
356
361
                                #if neko
357
362
                                neko.Lib.rethrow(msg);
358
 
                                #else true
 
363
                                #else
359
364
                                throw msg;
360
365
                                #end
361
366
                        }