@@ -53,12 +53,14 @@ WOQL.typecast = function(vara, type, varb){ return new WOQLQuery().typecast(vara
5353
5454
5555/* Mathematical Processing */
56- WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
56+ WOQL . eval = function ( arith , v ) { return new WOQLQuery ( ) . eval ( arith , v ) ; }
5757WOQL . plus = function ( ...args ) { return new WOQLQuery ( ) . plus ( ...args ) ; }
5858WOQL . minus = function ( ...args ) { return new WOQLQuery ( ) . minus ( ...args ) ; }
5959WOQL . times = function ( ...args ) { return new WOQLQuery ( ) . times ( ...args ) ; }
6060WOQL . divide = function ( ...args ) { return new WOQLQuery ( ) . divide ( ...args ) ; }
6161WOQL . exp = function ( a , b ) { return new WOQLQuery ( ) . exp ( a , b ) ; }
62+ WOQL . div = function ( ...args ) { return new WOQLQuery ( ) . div ( ...args ) ; }
63+ WOQL . comment = function ( arg ) { return new WOQLQuery ( ) . comment ( arg ) ; }
6264
6365
6466//language extensions that can be chained after 'grounded' stuff (clauses with a specific subject) sub, isa, delete_triple, add_triple, delete_quad, add_quad, node
@@ -437,6 +439,19 @@ WOQLQuery.prototype.sub = function(a, b){
437439 return this . last ( "sub" , a ) ;
438440}
439441
442+ WOQLQuery . prototype . comment = function ( val ) {
443+ if ( val ) {
444+ val = ( val . json ? val . json ( ) : val )
445+ this . cursor [ 'comment' ] = val ;
446+ }
447+ else {
448+ this . cursor [ 'comment' ] = null ;
449+ this . cursor = this . cursor [ 'comment' ] ;
450+ }
451+ return this ;
452+ }
453+
454+
440455WOQLQuery . prototype . abstract = function ( varname ) {
441456 if ( varname ) {
442457 return this . quad ( varname , "tcs:tag" , "tcs:abstract" , "db:schema" ) ;
@@ -464,31 +479,54 @@ WOQLQuery.prototype.trim = function(a, b){
464479}
465480
466481WOQLQuery . prototype . eval = function ( arith , v ) {
482+ arith = arith . json ? arith . json ( ) : arith ;
467483 this . cursor [ 'eval' ] = [ arith , v ] ;
468484 return this . last ( 'eval' , v ) ;
469485}
470486
471487WOQLQuery . prototype . plus = function ( ...args ) {
472- this . cursor . plus = args ;
488+ this . cursor . plus = [ ] ;
489+ for ( var i = 0 ; i < args . length ; i ++ ) {
490+ this . cursor . plus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
491+ }
473492 return this . last ( ) ;
474493} ;
475494
476495WOQLQuery . prototype . minus = function ( ...args ) {
477- this . cursor . minus = args ;
496+ this . cursor . minus = [ ] ;
497+ for ( var i = 0 ; i < args . length ; i ++ ) {
498+ this . cursor . minus . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
499+ }
478500 return this . last ( ) ;
479501} ;
480502
481503WOQLQuery . prototype . times = function ( ...args ) {
482- this . cursor . times = args ;
504+ this . cursor . times = [ ] ;
505+ for ( var i = 0 ; i < args . length ; i ++ ) {
506+ this . cursor . times . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
507+ }
483508 return this . last ( ) ;
484509} ;
485510
486511WOQLQuery . prototype . divide = function ( ...args ) {
487- this . cursor . divide = args ;
512+ this . cursor . divide = [ ] ;
513+ for ( var i = 0 ; i < args . length ; i ++ ) {
514+ this . cursor . divide . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
515+ }
516+ return this . last ( ) ;
517+ } ;
518+
519+ WOQLQuery . prototype . div = function ( ...args ) {
520+ this . cursor . div = [ ] ;
521+ for ( var i = 0 ; i < args . length ; i ++ ) {
522+ this . cursor . div . push ( args [ i ] . json ? args [ i ] . json ( ) : args [ i ] ) ;
523+ }
488524 return this . last ( ) ;
489525} ;
490526
491527WOQLQuery . prototype . exp = function ( a , b ) {
528+ a = ( a . json ? a . json ( ) : a ) ;
529+ b = ( b . json ? b . json ( ) : b ) ;
492530 this . cursor . exp = [ a , b ] ;
493531 return this . last ( ) ;
494532} ;
@@ -645,7 +683,7 @@ WOQLQuery.prototype.label = function(l, lang){
645683 return this ;
646684}
647685
648- WOQLQuery . prototype . comment = function ( c , lang ) {
686+ WOQLQuery . prototype . description = function ( c , lang ) {
649687 if ( this . tripleBuilder ) this . tripleBuilder . comment ( c , lang ) ;
650688 return this ;
651689}
@@ -1243,7 +1281,7 @@ WOQLQuery.prototype.uncleanArguments = function(operator, args, indent, show_con
12431281 */
12441282WOQLQuery . prototype . uncleanArgument = function ( operator , val , index , allArgs ) {
12451283 //numeric values go out untouched...
1246- const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" ] ;
1284+ const numeric_operators = [ "limit" , "start" , "eval" , "plus" , "minus" , "times" , "divide" , "exp" , "div" ] ;
12471285 if ( operator == "isa" ) {
12481286 val = ( index == 0 ? this . unclean ( val , 'subject' ) : this . unclean ( val , 'class' ) ) ;
12491287 }
0 commit comments