ASPL Manual v 1.00
© 2024 by SetSphere.COM


2-3

   ASPL Scripts

ASPL scripting language is simple for: (a) it is not a structured language, (b) its identifiers are typeless, and (c) all its variables are global and their namespace is constrained to the workspace where they belong.
An ASPL script starts with the shebang line, a first line starting with #!, to tell the kernel which interpreter to be used to hand over the script name along the content of the script.
In this chapter, we describe only those features of ASPL that are sufficient for writing reasonably interesting scripts. To make ASPL scripts run on different UNIX brands a special consideration was given to the shebang line and to the treatement of the environment env command. This chapter starts with a discussion on how the shebang line is being handled by ASPL,

■ Shebang

The ASPL interpreter provides a scripting language and it can parse, analyze, and execute the statement of an ASPL scripts. However, how to get the kernel to load the interpeter so that the later can execute the content of the script?
The shebang, the first line that appears in the script of an interpreted language, dictates the starting point where the kernel will dispatch the interpreter, once dispatched the interpreter takes control then it interprets the statements of the script. For this to happen, the script must be executable, then the kernel reads the first two bytes in the opening line of the script, should it be matching #! then it will call exec with whatever follows #! passing any extra arguments followed (and ending) with the name of the script. On the UNIX system such an exec will also pass the parent environment to the interpreter.

Typically, the env command is used on many systems to execute whatever follows it as being the interpreter program followed by the rest of the arguments then ending with the script name. However, the parsing of the shebang line has been problematic when dissected by different UNIX vendors and even by different releases of the same vendor.

The execution of an interpreter along its script content via the kernel is typically done in two ways:

The scripting language of an interpreter typically provides a mechanism to load its scripts via the kernel of the UNIX system. This can be done in two ways:

In either case the script is loaded through the UNIX shell environment. The first case requires specifying the full path to the location of the interpreter, and may not work on some UNIX systems where the loading of the #! has been disabled. The second case may seem simple, yet we need to pay special attention considering the many UNIX systems and the fact that env loading mechanism has not been addressed by POSIX (different vendors implement the env following their needs). Furthermore some vendors provide the -S option supposedly to be followed by a string to be split into the script name and its arguments, but fail the split and present the whole string as it is: one long string that is assumed to be the interpreter name (hence failing again with "no such script" when concatenating the arguments to the script name). In addition, the location of the env command may vary between systems: the env program may be located in /usr/bin, or /bin, or somewhere else.

Since all UNIX vendors (at least) load what follows the env as a single string pointing to the interpreter named program, then it is possible to generalize a solution to the loading of the interpreter and its arguments. To overcome the env loading issues and to make ASPL portable on different UNIX systems, ASPL uses a two-lines shebangs line: the first line is to read the interpreter name, and the second line is to pass the arguments of the program. Note that the script name is the program name itself and is implicitly passed by env as $0 shell variable.

This chapter shows some scripting examples that can be run by the ASPL interpreter. All scripts can be found in the shared folder where you have installed the ASPL interpreter.

 

● Comments

To make programs more easily readable, comments will sometimes be used. A line starting with two successive semicolons is a comment and will not be executed by the interpreter. Comments may be added to a statement by typing two successive semicolons (;;) anywhere to the right and following it with the comment.

On any line the presence of two successive semicolons followed by anything is considered a comment and will be ignored. Execution of a program is sequential. (ASPL is not a structured language).

Two successive semicolons ;; are used for comments in ASPL. Any line that start with ;; is ignored, and any statement that contain anywhere ;; appears is ignored with anything following it till the end of line. Putting a space between the semicolons is not the same as without it, therefor the following are not equivalent

Statements are typed one to a line. The components of a statement must be seperated by at least one blank. Comments may be added to a statement by typing two successive semicolons (;;) anywhere to the right and following it with the comment.
Any line starting with two successive semicolons (;;) is considered a comment and is ignored.

Try it out: aspl> ;; 123 aspl> ; ;

 

■ Metagrouping Tied Attributes

Tied attributes allow to specify a domain or RANGE. The metagroup will parse a RANGE, it is written as

-attributes "point1,t" "point2,t" "point3,t"

which says that the attribute with names point1 point2 point3 are tied attribute

"mean123,c,__mean123 point1 point2 point3 /[0.0,4.99] 1-5feet/[5.0,6.5] 5-6feet/>6.5 above7feet/"

which says that the attribute mean123 is CODE with subroutine __mean123 to be executed, and point1 point2 point3 are

passed as actual parameters; also the range

 

Example 2.3.1

bof bof bof

The following example shows how ASPL variables get to exist once they are assigned

aspl> a1 = ggdir /tmp/aa1
    (result is assigned to a1)

aspl> a2 = ggdir /tmp/aa2
    (result is assigned to a2)

aspl> a12 = f& a1 a2
    (a12 is assigned the intersection of a1 and a2)

aspl> v
    (print the variables)

 

● ASPL Variables are Eternal

ASPL variables cannot be deleted, however they can be reassigned.

①   On the shell prompt before starting ASPL interpreter export ASPL_CONFIG

export ASPL_CONFIG=$HOME/WS,WS1,10,10,10,1000,30,2,0,1,0

②   Start ASPL

③   Type envvar at ASPL prompt to have ASPL print the environment variable

aspl> envvar
    (ASPL will print the environment variable)

 

Operation 2.3.1

Anchor Tit Placeholder

①  aspl> c123 = c& a1 a2 a3
    (c123 is assigned all checksums intersections of a1 a2 a3)

②  aspl> adisplay c123
    (print out c123)

aspl> av c123
    (view internals of set variable c123)

③   Just dump the rest to a file

AS BEING SET IN THE SHELL:
--------------------------
ASPL_CONFIG=/root/WS,WS3,10,10,10,1000,30,2,0,0,0