- syntaxNotation
- 12.8.10 is a litte better than syntaxCs
- 1.9.10 with und forWith
- 12.9.10 neue directives, call mit Argumenten
- todo
- besser with Semantics: mit lexial links statt hist Links!
- todo
- $@arg statement, das ein parse, in objekt macht und with
wsh input consists of a compilation unit possibly followed by named compilation units, that are put into the variable pool. This allows to combine the arguments to the interpreter and several fragments of the source file.
cUnit = unit ? ( '$#' kind unit )*
a compilationUnit consists possibly of an unit of implicit kind, possibly followed by units of explicit kind.
unit = data | shell | assAtt | assTab | litText
A unit with implicit kind, which is determined by the environment
data = ( spCom* | expr) (nl (expr | sp* comment spCom* )* (nl spCom* )? (stmt data )*
Defines line oriented data and consists of expressions and statements.
shell = pipe ? ('$;' pipe? )*
- All expressions are of the same kind or constant
- Partial lines (i.e. at begin, end or beside a stmt) are ignored, if they consist only of spaces and comments.
- Empty lines with comments are also ignored
A pipe is a statement or language code with optional IO redirections. Caution: Semicolons without $ do not terminate a pipe but are part of the underlying language.
expr = (( noDo+ | primary ) comment* )+
expressions consists text (without dollars or newLines) and primaries, comments are ignored (i.e. substitued by 0 or 1 space depending on the context). The kind of the expression determines how text is interpreted.
exprS = spCom* expr spCom*
an expression with leading and trailing spaces stripped
exprB = spCom* (( noBr | primary ) comment* )+ spCom*
a type of expressions with texts without {}=, leading and trailing spaces stripped
exprW = (( word | primary ) comment* )+
an type of expressions with texts without (free) spaces or {}=
kind = '.' | '-' | '=' | ':' | '!' | '#' | '@'
there are 7 kinds with the following meaning
obOp = '.' | '-' | '<' | '@' | '!' | '?'
three flavours of data
. = object: text is rexx, expression yields an object reference
- = string: text is rexx, expression yields a string
= = skeleton: text is literal data, expression yields a string
three flavours of code (yielding an oRun)
@ = shell: text is rexx,
: = attribute assignments (of last with)
! = tabular assignments (of last with)
# = literal text: text without rexx or wsh interpretation
there are 6 object operators:
primary = var | '$' sConst | '$.' obj | '$-' str
- = a2string: objectString to its value, conacatenates the contents of a File or Run (with one space between lines, files any line is no
string), otherwise fails
A primary is a variable expansion, a string constant, an object or a string expression
var ='$' name | '${' ( '?' | '>' )? exprB '}'
variable expansion to a string or an object depending on context). The form with braces allows options, nested variables and variable names that are not a name.
obj = obOp* '<' file | block | obOp* primary | obOp* 'compile' kind
? yields 1 if variable is defined, 0 otherwise
> reads stdIn into variable, yields 1 if not at end
otherwise does a normal expansion
exprB yields an arbitrary variableName, possibly with nested variable expansions
yields an object
str = obj
! singleton operator
primary yields the primary casted to an object
block yields an instance of string, object, Run or File, depending on the kind of the block
file a file as an object
A string term is syntactically the same as an object term, however it is casted differently. A file or a block yields its concatenated output etc.
file = block | kind? exprS
block: each line (or output) is a record of the file, default kind '='
block = (obOp* kind)? ( '{' unit '}' | '[' ( unit ) '$]' | '/' noSla* '/' ( unit ) '$/' noSla* '/' )
exprS cast to file the exprS of the indicated kind (default '=') e.g. String as fileSpec.
A block combines several expressions or statements in a single syntactical entitiy. The content of a block is evaluated as the indicated kind, the default is context dependent. For clarity, {} blocks do not allow nls. The slashes give label a block with the same label at the begin and end
exprBlo = block | kind? exprS
allows a block or an expression of a possibly specified kind
pipe = ioRedir stmts ( '$|' stmts )*
this is execution order, syntax order is more flexible
ioRedir = (('$<' | '$>' | '$>>') file spNlCom* )+
$< designates an input file, several input files are concatenated. An Output with $> replaces an existing file, $>> appends to it. Several Outputs are an error.
stmts = ( ( stmt | expr ) spNlCom* )+
expr yields rexx statements with trailing comma handling for rexx line continuations
stmt = '$=' ass
$@for readloop on stdIn, the read object is assigned to the variabe named exprB
ass = ( exprB '=')? exprBlo
$@ct executes the statement at compile time
$@proc declares the variable named exprB as a procedure (an instance of run) at compile time
$@do: rexx do logic, control variable assigned
$@name() run the procedure (oRun of the object in variable pool) of the given name
$@name?{exprB} run the procedure (object in variable pool) of the given name with exprB as arguments, the kind of exprB is given between name and {.
$@obj run the object
assigns variable named exprB the contents of exprBlo.
assAtt = ( ass | stmt | ( '$'? (':' class | ':.' exprB)? ';' ) | spNlCom )*
- If exprB is missing, the expr must be a named block, and its name is used as the name of the variable, e.g. $=/lines/ ... $/lines/
- an assignment can address object in the variable pool, or an attritute at the end of an attribute chain of an object from the variable pool.
- If the block is of kind attribute or tabular assignment then the addressed variable or attribute defines the environment for that block
the ass (without $) are confined to the latest with, typically from an assignment of the form .... =:... The semicolon (with or without $) create the next element of collection. This only works after =<: (replacment of old collection) or =<<: (append to old collection). Currently it only works for stems. The dollar before the block terminator (] or /../) can be omitted on the beginning of a new line or anywhere, the scanner can recognise it.
assTab = spNlCom? ( name spCom )* nl (spNlCom | stmt | (exprW spCom)+ nl )*
Multiple assignments in the form of a table. The list of names are the headers with the fieldName to be assigned to. Each line of exprWs assigns the fields of one element of a collection. Each expression must overlap with exactly on name from the header. All expression are of kind = and cannot contain free spaces - however $-string constants with spaces are ok (e.g. $" "). The rest is similar to assAtt.
Lexicals
sConst = '$''' ((* noNl not '''' *) | '''''')* '''' | '$"' ((* noNl not '”' *) | '””')* '”'' '''' a string enclosed in single or double quotes, prefixed by a dollar. Inside, two quotes stand for a single one.
name = (* starting with a letter followed by any number of digits or letters, case sensitive! *) nl = (* newLine character(s) or record switch *)
noNl = (* one character not nl *)
sp = (* one space character ' ', tab etc., but not nl *)
noDo = (* one character neither '$' nor nl *)
noSla = (* one character neither '/' nor nl *)
noBr = (* one character neither in '{}=' nor nl *)
word = (* one or more characters of noBr but not space *)
textB = ( noBr+ | '{' textB '}' )*
textLns = spCom* (nl noNl* )*
comment = '$**' noNl* | '$*+' noNl* nl | '$*(' (comment | sConst | noNl | nl )* '$*)'
$** starts a comment until the last character before next nl,
spCom = sp | comment $*+ includes also the next nl (joins lines)
spNlCom = sp | nl | comment
litText = (* any number of any characters, newlines, etc. *)
uninterpreted text, with or without stopper, depending on the context