Class Hierarchy
- syntaxVariables: the corresponding construct
- String with instances string
- Object with instances object
- Run with instances run: contain (compiled) code and can be executed (run) with (or without) arguments
- File with instances file: files allow reading and writing. run will read whole file and write contents to stdOut
- Run with instances run: contain (compiled) code and can be executed (run) with (or without) arguments
kind | name | expression yields | literal text | descritptin |
---|---|---|---|---|
. | object | object | rexx | is interpreted as a rexx expression interwoven with '$'primary |
- | string | string | rexx | is interpreted as a rexx expression interwoven with '$'primary |
= | skeleton | string | literal constant | is a skeleton, with '$'primary as variable parts |
# | literal | string | literal constant | literal constant, no interpretation of $, except for detection of stopper |
@ | code | code | rexx statement | rexx statements with '$'primary, in blocks with rexx line continuation (,) |
: | pure wsh | --- | --- | only wsh statements, with most $ superfluous - no expressions |
% | run output | file | var arguments | runs the contents of variable (must be subclass of ORun) with the givgen arguments and yields the contents of the produced stdOut as file |
^ | run return | String or Object | var arguments | runs the variable (subclass of ORun) with the givgen arguments and yields what is returned by a rexx return statement |
- exprStmts the statements are executed and the expressions evaluated and written to stdOut. The sematics changed after a withNew or table statement, see further down. $$ statements are handled as expression - which may be of a different kind.
- @ run stmt
- $$ output stmt
op: Operators (all unary)
- . 2object → Object:
- @ 2run → Run (attention the @ statement does something else!):
- < 2file → File:
- f → identical file
- r → output of execution of run, arguments are supplied only by £ expression, returnValue is discarded
- s → fileSystem file with string as filespec
- b → 2file 2str block. new: before contents of block - now <@b or pipe syntax needed
- o → dynamically as r, f or s
- - 2string → String:
- s → identical String
- f → if all objects of f are Strings then concatenate f (with separating ' ') otherwise fail
- b, r → 2string of 2file
- o → dynamically as r, f or s
- ! singleton → Object:
- f → if f contains a single object then this object otherwise fail
- else → singleton of 2file
- ? 0or1 → Object:
- f → if f is empty then null else if f contains a single object then this object otherwise fail
- else → 0or1 of 2file
- . 2object → Object:
- b → singleton of output of execution of block
- s → stringValue as object
- else → identity
- % runOut: oRun object, output yields result
- ^ runRet: oRun object, return value yields result
- ( close: bracket by ( ) or do end, if necessary internal only
wlkl
ast kind
- 'S' String Constant
- 'O' Object Constant
- '.' rexx expression yielding object (if .0 = 0 in text else in stems)
- '-' rexx expression yielding string (if .0 = 0 in text else in stems)
- '='
- '@'
- '#'
- '£'
- '<'
- '^'
- '!'
- '?'
offen
- rexx Variables scopes versus block nesting und interprets
- jBuf = File Contents Store formalisieren
- ??
Classes
- b: Block
- s: String
- o: Object
- f: File
- r: Run: execute some code with (or without) arguments, yield return value or output
Semantics
wshInt: compile some separate wshUnits, and add the sequence of units to m.code
- kind: compile the following wshUnit with this kind
- '*': everything is comment up to the next nl'$#'
- hook: extend wsh by
- if name is a registered hook (case insensitive!) execute the registered code
- otherwise (try to) execute
call wshHook<name> m, hook
- in both cases the hook gets the current instance of the compiler as argument, and can do i.e.:
- call compSepUnit m, ... to compile the following unit
- use m.scan to compile some code itself and add it to m.code (to be executed later)
- execute the already compile code, modify m.code etc.
op: Operators (all unary, except execution ???? by < or ^ which get arguments from £ expression)
- & variable Access→ Object: new: was only implicit, is it really necessary as expicit op?
- any → variableAccess of 2string
- r → returned value of execution of run, output is appended to stdOut, arguments are supplied only by £ expression, fail if no value returned
- o → dynamically as r
- else → fail
- @ 2run → Run:
- b → run = execution of the block
- r → identical Run
- f → run = read file and write each object read to stdOut,
- o → dynamically as r, f
- else → fail
- < 2file → File:
- f → identical file
- r → output of execution of run, arguments are supplied only by £ expression, returnValue is discarded
- s → fileSystem file with string as filespec
- b → 2file 2str block. new: before contents of block - now <@b or pipe syntax needed
- o → dynamically as r, f or s
- - 2string → String:
- s → identical String
- f → if all objects of f are Strings then concatenate f (with separating ' ') otherwise fail
- b, r → 2string of 2file
- o → dynamically as r, f or s
- ! singleton → Object:
- f → if f contains a single object then this object otherwise fail
- else → singleton of 2file
- ? 0or1 → Object:
- f → if f is empty then null else if f contains a single object then this object otherwise fail
- else → 0or1 of 2file
- . 2object → Object:
- b → singleton of output of execution of block
- s → stringValue as object
- else → identity
- % runOut: oRun object, if a result needed, output is used, with arguments if there is a call
- ^ runRet: oRun object, yielding return value, with arguments if there is a call
- ( close: bracket by ( ) or do end, if necessary internal only
- String oder Object je nach Anfangs . oder -, default abhängig von kind der expression
- sConst String Konstante → String
- name: variable access mit dem Name → Object
- block:
- /.../ kein Block sondern /BlockEnd
- {...} [...$] Variable access mit BlockKind =
- op+block: block kind vom letzten Operator bestimmt: <→=, andere→.
expR hängt von kind ab
- ., -: rexx expression, noDo+ ist Teil der expression und wird mit primaries zusammen konkatiniert (mit rexx space Logik)
- @: rexx statements primaries werden wie oben zusammenkonkatinert, als Teil von expressions in den statements
- =: skeleton noDo+ ist konstanter unveränderterter text mit primaries zusammen konkatiniert
- #: Literal Text, $ werden nicht interpretiert
unitR statements und expressions, in 0 - n Zeilen, abhängig von kind. für jede Expression wird ein statement generiert und dann alles ausgeführt
- .: jede Expression wird als Object auf stdOut geschrieben - falls ein table statement aktiv ist, wird jede expre in subexpressions aufgeteilt und in ein neuer Objekt abgelegt
- -, =: jede Expression wird als String auf stdOut geschrieben
- @: Expression werden als rexx Statements ausgeführt, Commas als rexxLineContinuation werden unterstützt
- #:
TextCopy
- .:
- -:
- =:
- @:
- #:
old
The following table gives the semantics of the operators. It is read from top downwards: the first matching entry (operator, from kind and conditition) is applied.
From and to rows contain extended kinds. The alphabetic character is used as a variable in the explaination or Rexx. The preceeding special character corresponds to the kind
extended kinds
- b a block with elements (expressions), b1, b2, ...
- ; c: rexx code, pseudoKind ;. kind @ from the syntax is often directly lifted to ; c (this may be documented later)
- . j: object of class JRW
- . r: object of class ORun, includes . j
- . o: Object of any class includes . r and . j
- - s: String
- a: anything
conditions
- aE: if each element of a block is . or -. The optimization with this condititon is semantically equivalent to the following definition without the exception, if none of the expression has side effects
op | from | co | to | result | rexx |
---|---|---|---|---|---|
- | b | aE | - | cocatenates each line (- bi) casted to string, separated by 1 space | |
- | b | - | -; b | ||
- | ; c | - | executes c and concatenates (- oi) for each output oi separated by one space | ||
- | . r | - | -@r | o2string(r) | |
- | - s | - | identy | s | |
- | . o | - | depending of class of o select correct cast from above | o2String(o) | |
. | b | . | !; b | ||
. | - s | . | cast string to strW | s2o(s) | |
. | ; c | . r | yields an ORun with code c as oRun method | oRunner(c) | |
. | . o | . | identity | o | |
< | b | . j | <@b | ||
< | ; c | . j | yields jBuf with output of execution of c | o2file(oRunner(c))) | |
< | - s | . j | file with fileSpec s | file(s) | |
< | . j | . j | identiy | j | |
< | . o | . j | if String or JRW as above, otherwise <@o | o2file(o) | |
! | b | aE | . | yields (. b1) if b has exactly on element otherwise fails | |
! | . j | . | reads j. returns first line read. Fails if 0 or more than 1 lines readable | ||
! | ; c | . | !<c | ||
? | b | aE | . | yields null if b is empty, (. b1) if b has exactly 1 element, otherwise fails | |
? | a | . | analogous to ! | ||
; | ; b | ; | execute each (; bi) element of the block casted to ; | ||
; | - s | ; | write s to stdOut | call out s | |
; | . o | ; | write o to stdOut | call outO o | |
; | ; c | ; | execute c | ||
@ | b | ; | ; b | ||
@ | . j | ; | reads j writes each line read (casted to obj) to stdOut | call jWriteAll j | |
@ | . o | ; | runs o | oRun(o) | |
@ | ; c | ; | executes c |
This semantics table is far from complete
- Expression are not documented yet. This will be done, when they are migrated to AST.
- there are further features for : ! which non atomically create/updates objects, the current with is used to remember the currenty object to update
- directly in a with (
$@with obj $@:[...
or$@with obj $@![...
) the with object obj is updated - a singleton assignment like [" obj =:[...@] or
obj =![...
is converted to awith obj $@:[
, if obj is null, it is created from the class of obj if it is declared, or the class deduced from the assignment block. - a multi assignment to a stem like
obj.st =<:[...
orobj.st =<![...
will set the stem size to zero, and then initialize the next stem element, use it as the with object and update it. - In all other cases each element is created from the class deduced from the assignment block, used as the with object and updated. And the block yields just the sequence of elements created
- still missing is syntax for an explicit class in : and ! blocks (wshDis
- directly in a with (