Scripting

2009-02-16
2013-04-09
  • We need a scripting language for configuring the search. Any scripting processor will do. The easiest for doing it from the scratch is probably a postfix-style adhoc syntax similar to PostScript: Any object is placed on a stack, and an operation will remove its operands from the stack.

    Disadvantage: All the parsing has to be implemented in the DLL - although this is not its genuine purpose.

    Another idea could be a JavaScript style. After having defined the possible objects, one could write:

    // Search all conjunctions JU CON SAT from 1900 to 2000
    result = [];
    r = new Range( 1900, 2000, 50 );  // 50-days-steps
    p = new AspectPattern( "ju", "con", "sa" );
    times = r.apply( p);             // or: Times.apply( r, p );
    alert( times.length );           // any standard JS function will be available
    for ( i = 0; i < times.length; i++ ) result.push( times.at(i).full() );
    // ------------------------------------------------------------------

    This gives the full flexibility of a scripting language. Possibly, even the built-in JavaScript processor of the Win32 processor can be used. This approach has several advantages:

    - Code snippets can be reused by the user
    - It can be made more flexible, since processing logic of the JavaScript language can be added: In the example above,
      a "for" loop has been added for processing the result.
    - A user interface may be built on top, with predefined code snippets, for ease of use. Or, the AstroPatterns API
      can be adressed directly.
    - The parsing and execution is performed via the external scripting engine.

    Search for examples: How to make the DLL objects or functions known to a JavaScript. Are there any examples out there
    of a C++ program interacting with JavaScript in this way? (There should be plenty).