1- // Prolog plugin
2-
3- var yy = alasql . yy ;
4-
5- yy . Term = function ( params ) { return yy . extend ( this , params ) ; }
6- yy . Term . prototype . toString = function ( ) {
7- var s = this . termid ;
8- if ( this . args && this . args . length > 0 ) {
9- s += '(' + this . args . map ( function ( arg ) {
10- return arg . toString ( ) ;
11- } ) + ')' ;
12- }
13- return s ;
14- } ;
15-
16- yy . AddRule = function ( params ) { return yy . extend ( this , params ) ; }
17- yy . AddRule . prototype . toString = function ( ) {
18- var s = '' ;
19- if ( this . left ) s += this . left . toString ( ) ;
20- s += ':-' ;
21- s += this . right . map ( function ( r ) { return r . toString ( ) } ) . join ( ',' ) ;
22- return s ;
23- } ;
24-
25- yy . AddRule . prototype . execute = function ( databaseid , params , cb ) {
26- // var self = this;
27- // console.log(this.expr.toJS());
28- // var fn = new Function('params, alasql','return '+this.expr.toJS());
29- // var res = fn(params, alasql);
30- var res = 1 ;
31- var objects = alasql . databases [ databaseid ] . objects ;
32- var rule = { } ;
33- if ( ! this . left ) {
34- this . right . forEach ( function ( term ) {
35- rule . $class = term . termid ;
36- } ) ;
37- }
38- if ( cb ) res = cb ( res ) ;
39- return res ;
1+ // Prolog plugin
2+
3+ var yy = alasql . yy ;
4+
5+ yy . Term = function ( params ) { return yy . extend ( this , params ) ; }
6+ yy . Term . prototype . toString = function ( ) {
7+ var s = this . termid ;
8+ if ( this . args && this . args . length > 0 ) {
9+ s += '(' + this . args . map ( function ( arg ) {
10+ return arg . toString ( ) ;
11+ } ) + ')' ;
12+ }
13+ return s ;
14+ } ;
15+
16+ yy . AddRule = function ( params ) { return yy . extend ( this , params ) ; }
17+ yy . AddRule . prototype . toString = function ( ) {
18+ var s = '' ;
19+ if ( this . left ) s += this . left . toString ( ) ;
20+ s += ':-' ;
21+ s += this . right . map ( function ( r ) { return r . toString ( ) } ) . join ( ',' ) ;
22+ return s ;
23+ } ;
24+
25+ yy . AddRule . prototype . execute = function ( databaseid , params , cb ) {
26+ // var self = this;
27+ // console.log(this.expr.toJS());
28+ // var fn = new Function('params, alasql','return '+this.expr.toJS());
29+ // var res = fn(params, alasql);
30+ var res = 1 ;
31+ var objects = alasql . databases [ databaseid ] . objects ;
32+ var rule = { } ;
33+ if ( ! this . left ) {
34+ this . right . forEach ( function ( term ) {
35+ rule . $class = term . termid ;
36+ } ) ;
37+ }
38+ if ( cb ) res = cb ( res ) ;
39+ return res ;
4040} ;
0 commit comments