ZEDRAM: SCHEME

The SCHEME style for ZEDRAM allows for easy parsing. Under the main concept of (cmd args), the program is fully expandable and dynamic.

Functions Defined

These SCHEME style specific functions are generated by calling the ZEDRAM parser's add_function command that associate a cmd (as in (cmd args) ) with a function. The function names need not be the same as the cmd name. This dispatch table implementation allows for synonyms of the same command to be implemented easily.

All functions should call $zedram_instance->escape_chars($x) and remove the opening and closing double quote if necessary. That function substitutes grammar.zyg replacement characters to ensure that the input $x renders properly. It also translates [] to ().

To define a new function:

$zedram_instance->add_command('cmd_name', \&function_name);
sub function_name {
    my $self = shift;
    .
    .
    .
}

Supplied Functions

open

(open (TAGNAME OPTIONAL_ARGS)): <TAGNAME OPTIONAL_ARGS>

set-attr

(set-attr x y z): x y z

set

(set x y): x = 'y'

define-each

(define-each (TAG SCHEME) (<DATA_IN_SCHEME>) )

would be interpretted as:

SCHEME = foreach DATA_IN_SCHEME {
    (set-attr (for every split('|/|', SCHEME) also split('|/|', DATA...)
}

however! if DATA split starts with (, execute the internals

Therefore:

(define-each (TAG x/y/z) (a/b/c d/e/f g/h/i)) :
        <TAG x=a y=b z=c />
        <TAG x=d y=e z=f />
        <TAG x=g y=h z=i />

close

(close (TAGNAME)): </TAGNAME>

exec

(exec FUNCTION ARGS): runs function when analyzed (lazy)
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2018-07-19 - ZachBornheimer
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback