wsh Syntax - Version 5

abstract syntax 5

kind = '-' | '.' | '=' | '#' | '@'| ':' | '^' | '%'

  • - = kindStr ⇒ string expression including wshPrimaries
  • . = kindObj ⇒ object expression
  • = = kindSkel ⇒ skeleton
  • # = kindText ⇒ constant text
  • @ = kindExe ⇒ rexx and wsh statements
  • : = kindWsh ⇒ wsh statements only
  • % = kindCall ⇒ call
  • ^ = kindFun ⇒ function call (return value)
op = '.' | '-' | '<' | '@' | '!' | '?' | '^' | '%'
primary = op* sConst | op* var | (op* ki)? block
var = name | '{' expr '}'
expr = textLi | var oPrBlEx? | (noDo+ | '$' sConst | '$' var | '$' ( '.' | '-' ) primary )+

  • the first variant is for kindText which allows only text
  • the second variant is for kindCall or kindFun which are calls: var is the run to call, oPrBlEx give the facultativ arguments
  • the third variant for the other kinds
  • $/../ is a blockEnd, neither a primary nor an assignment, $[ is illegal
oPrBlEx = primary | ( op* ('#' | '=' | '<' ) | (op* kind )? spCom+ ) expr
pipe = ('<' oPrBlEx)* (( '>' | '>>') oPrBlEx)? exprStmts ( '|' exprStmts )*

  • default kind for oPrBlEx is =, default kind for expr given by context, for kind # everything is text
unit = pipe? ('<>' pipe?)*
nmBlock = kind? '/' name '/' unit '/' name '/'
block = kind? '[' unit ']' | nmBlock
ass = ('='? var)? '=' oPrBlEx

  • default kind for oPrBlEx is =
  • omitting var is only allowed, if a named block follows
  • '$'var is a primary, not the start of an assignment!
stmt = '$$' oPrBlEx

| 'arg' (var | ',')+
| ass
| '@' oPrBlEx

| 'ct' stmt
| 'proc' var? stmt

  • omitting var is only allowed, if a named block follows
| ( 'do' | 'with' ) (ass | expr ) stmt
| ('for' | 'forWith' ) var? stmt
exprStmts = ( expr | stmt | 'withNew' )+
wsh = nl'$#version'version)? (nl unit)? ( nl'$#' ( kind (spCom* nl)? unit | hook nl unit | ('*' | 'out' | 'end') textLi+ ) )*
hook = name noNl*

concrete syntax

'$', nl, spaces, comments

 dolNlEscape ignoredexplanation
primary   no $, nl, spaces, comments except, of course within a started block
expr  com$ only to start a primary, spaces are part of noDo, comments are squashed to 1 or 0 spaces
var  exStr 
expP  com sp 
pipe< > >> | stmt com spcom and sp are handled by expr if neighbouring, nl separates stmts and/or expr see stmtExpr and dolStmt
unit; com spcom sp are handled by pipe if neighbouring
nmBloending /.../   
block]   
exprBlo  exStr 
ass  com sp nl 
stmtstmt com sp nl 
  • ignored: lexcicals ignored within term, but not before and after (there rule for parent element applies)
  • exStr: leading and trailing spaces and comments around expr are stripped
  • dolNlEscape which syntax terms must be prefixed by an escape character, so they are recognized
    • mandatory prefixed by '$' if kind is not £
    • either prefixed by '$' or nl (sp | com)*, otherwise
  • stmtExpr = (spCom* | expr) ( nl expr)* (nl spCom*)?
    • partial lines besides statements are ingored
  • dolStmt
    • '$$' does neither need nor allow a third $
    • both forms of the assignment statement must be prefixed by '$=', but not by '$=='
    • all other statements must be prefixed by a single '$'. For historical reason a prefix of '$@' (but not '$@@') is allowed

lexicals

  • com = '**' noNL* | '*+' noNL* nl | '$*(' text '$*)'
  • name = alfaChar (alfaNumChar | '_', '@')*
    • wsh variable pool is casesensitive, but not rexx names!
    • statement names for, with etc. are not a name, however ${for} is a primary
  • sp = a single space character
  • nl = new line (pseudo character in z/os for next line)
  • noNl = any single character except nl
  • noDo = any single character neither $ nor nl
  • text = any text possibly including '$' or nl until to the context dependent stopper, which must be prefixed by '$')
  • sConst = string constant: single or double quoted String with any nl's: 'abc', "e", 'I''m' etc.

variable name operators:

  • . inline dot (ohne variable expansion wie in rexx)
  • > access to m., plus field access if binary
  • & access to varPool, plus field access if binary
  • if no op at all, then like final op &