wsh: Diskussion, Ideen, Fehler

  • with syntax (block analog io redirection, sodass leave und iterate noch funktionieren), nicht getypt, einfach if symbo() == 'VAR then re ...
  • inlineData in wsh Syntax spiegeln mit benanntem Input
  • singleton as special kind ! ==> gibt es schon in Objekt Syntax, oder allgemeinere MultiplicitySyntax?
  • block mit zwei Types (resultatKind innerKind), 2 = im assignment durch resultKind ersetzen?
  • assignment mit namedBlock ohne varName $=/ab/ ... $/ab/ oder $=<./ab/, vielleicht Namenssysntax vereinfachen?
  • ref =:[...] modifiziert bestehende Referenz, new falls null
  • ref =<:[...] als Code. file führt Code beim Oeffnen aus
  • stem =<:[...] ersetzt stemInhalt, new macht automatisch die Stem Typen
  • stem =!
  • oder besser:
    • @ block --> runner
    • < block --> jBuf mit Inhalt (via ioRedirection)
    • - block --> concat
    • other block: unwrap single (or no) object
    • stem = <:[...

anforderungen general input / return reader oder writeAll in pipe

  • eingentlich wäre Idee über stdIn stdOut (mit pipe) aber wie macht man das aus rexx?
    • call pipeBeLa '<' file(); code ; call pipeEnd dreiZeilen?!
    • call pipe1 '<' file(), 'code' quotingInterpret?!
    • call sql pipeInOnce(s2o(...)) -- sql müsse inOnce einmal abholen und poppen
    • pipeSemicolon
    • pipeStrCall 'select .......', sql
  • alternative mit einem Parameter
    • direct als string: sql s2o('select ...)
    • aus file: sql file('a.b.c')
    • std input: sql jIn()

anforderungen directives / starter

  • interpreter aufrufen, d.h. source als input nehmen, z.B. call sql $#<
  • variabeln setzen für jcl
  • kind setzen für input
  • output setzen in editMacro
  • verarbeitung für Input bestimmen in editMacro

wshCall = ( '$#' directive | wsh )* directive = ( 'omit' | 'end' | 'out' | ( kind | ... )

toDo

  • remove compExpr 'd' ( => '')
  • syntax directives
  • replace allInFrame with a special toClose (function or keyword)
  • use nested memory for frames or and copy it only at pop for allInFrame or reuse frame memory
  • use nested memory for output buf and cat
  • * for stdIn stdOut
stdIn the standard input for any function - thus it does not need a parameter for its input. The frequent input situations can be handled in wsh and rexx as follows:
  • input one or several string (or obj?), evaluated in advance
    • $; $$ ... $| .... $;
    • $; $=[ $] $| .... $;
    • call pipeBeLa '- eins', 'zwei' ...; ...; call pipeEnd
  • input a file from fileSystem
    • $; $<abc/efg .... $;
    • call pipeBeLa '< abc/de'; ....; call pipeEnd
  • input a file variable
    • $; $<.$abc .... $;
    • input a rexxObj obj (subclass of JRW)
      • $; $<.obj .... $;
    • input a code block evaluated at open/read time
      • $; $<.=[ .... $] .... $;
stdOut die wichtigsten Funktionen:
  • output to filesystem
  • output to a buf in variable pool (with creation if not present) is now in the file: constructor - that is not a good place!
  • output to a rexx variable or stdOut
  • output to a code block
pipe currently we have the following rexx pipe functions
  • pipeBegin: <, push
  • pipe: pop buf/buf push
  • pipeLast: pop buf/> push
  • pipeBeLa < > push
  • pipeEnd: pop
  • possible enhancements
    • opt <-: rest of this and all remaining args strings written to a new inputBuffer (pipeBeLa '<- eins', 'zwei'; ... (if first line == '<-' then empty buffer, '<- ' then buffer with empty string)
    • pipeEndBe und pipeEndBeLa
    • pipeAddIO mit 2. Argument (caller name) -> fehler falls falscher IO
stdSyn we need a syntax for stdIn and stdOut, e.g. when concatenating the input of stdIn instead of an other file
strNat detect strings without leading strEsc
  • if not an object assume it's a string
  • use a common or registered prefix for objects

casting and operators

Status quo

  • 2String: obj => String
    • var: envGet
    • Run: jCatLines(Run, ' ')
  • 2obj: obj => obj
    • var: envGetO
    • string: s2o
    • code: oRunner
  • @ (run)
    • obj: oRun
    • file: pipeWriteAll
  • 2file
    • string: fileNamed
    • obj: o2File
      • Run: jBufRun
      • String: fileNamed

extended kinds

  • b a block with elements (expressions), b1, b2, ...
  • ; c: rexx code, pseudoKind ;
  • . 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

co: 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
opfromcotoresultrexx
-baE-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 --@ro2string(f)
-- s -identys
-. o -depending of class of o select correct cast from aboveo2String(o)
.b . !; b 
.- s .cast string to strWs2o(s)
.; c . ryields an ORun with code c as oRun methodoRunner(c)
.. o .identityo
<b . j<@b 
<; c . jyields jBuf with output of execution of co2file(oRunner(c)))
<- s . jfile with fileSpec sfile(s)
<. j . jidentiyj
<. o . jif String or JRW as above, otherwise <@oo2file(o)
!baE.yields (. b1) if b has exactly on element otherwise fails 
!b . !; b 
!; c .executes c and yields ( o1) for the only output o1, fails if not exactly one output???
!a . !@ a 
?baE.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 stdOutcall out s
;. o ;write o to stdOutcall outO o
;; c ;execute c 
@b ;; b 
@. j ;reads j writes each line read (casted to obj) to stdOutcall jWriteAll j
@. o ;runs ooRun(o)
@; c ;executes c 

vorher

fromtooprexx 
StringString-identity 
FileString-o2Stringreads file and concatenates the lines (separated by one space). Fails if a line is not a String
ORunString-o2StringRuns the Run and concatenates ouput as for File
ObjectString-o2StringObjString yields value. Other classes as defined above, otherwise method o2String or fails
StringFile<fileString is filename (or specification) as implemented in the class File for Operating System used
FileFile<=identity
RunFile<o2FileFile runs Run at open time, subsequent reads will read the output (can append further line inbetween)
ObjectFile<o2Fileas defined for different classes above
StringORun@ fails
FileORun@ by inheritance: File writes its content to stdOutput
ORunORun@ identity
ObjectORun@oRunUses oRun method of object, fails if not existing
StringObject.s2onew ObjClass with value of the String
FileObject.=by inheritance
ORunObject.=by inheritance
ObjectObject.=identity
namesymbolLinuxwshrexx
escape to wsh$ Escape to wsh, variableMarker $var, output $$ 
comment* $**, $*+ or $*(....$*) 
piping
pipe!|stmt1 $| stmt2... call pipe ...
redirectOutput> output redirection $>...call pipeLast '> fileName'
redirectInput< input redirection $<...call pipeBegin '< fileName'
semicolon; Statement separator in $;call pipeBegin ... call pipeEnd
expressions
value- expression in $(, $-[, $-{, $-comp..., o2string
obj. expression in $(, $-[, $-{, $-comp..., s2o, file, etc.
isDefined? in ${?a}: is variable defined?envHasKey
StringDelimiter" $"..." 
StringDelimiter' $'...' 
statements
assignment= $=var= ...envPut, envPutO
run@ run block, call procedure, run object, $@for etc.call ...
blocks
braceBlock{...} for variables ${a} or short blocks $-{1+1} 
bracketBlock[...$]   
slashBlock/name/ .... $/name/   
fileSpecs
external spec&   
user~ ~.work.~dsn2jcl
var# #var 

the class hierarchy classes

String a rexx String, its contents is its value
obj a reference to an object, this is of course also a rexx String, but its contents is interpreted as objectAdress for an object with a class, not as contents
StrW an object, that is a string constant, the current implementation is a prefix by m.class.escW = ']'. In the rexx the class is called m.class.classW = 'w'.
StrV an object, that is a string variable that is directly assigned to m.a if the address is a. In the rexx the class is called m.class.classV = 'v'.
ORun an object that contains a method, that executes (interprets) some rexx code in its method oRun
JRW a class supporting Reads and Writes. the basis for all types of files and pipes. The oRun method reads until endOfFile and writes each object read unchanged to stdOut. If the JRW is not opened yet, it is opened for read and closed afterwards.
JBuf buffers input in a stem (memory) - from where it can later be read
File a File accessing the FileSystem, implementation depends on the operating system and environment, in our case it uses TSO.

systematic operations

  • cat(mid, file): file => string
    • cats all lines, with mid between each two lines, fails if it reads something not a string (or o2string?)
  • singelton: file => obj
    • returns first object of file, fails if file contains no or 2 or more objects
  • commandSubstitution: block => file (output or contents of block)
    • is this necessary
  • run: stmt => file
    • runs the stmt and ouput goes to stdOut (necessary?)
  • fileNamed: string => file
    • returns a file accessing the file with that name in the filesystem: fileSpec features ~. stdIn, stdOut, buf in variablePool? creates file if missing, ....,
  • fileOf: obj* => file
    • a file with contents of the given objects
  • o2file: obj => file
    • for run:
      • open input: run run and its stdOut is returned by read
      • open output: stores all output, at close time run is run with input the stored output
    • string fileNamed ???
strNat detect strings without leading strEsc
  • if not an object assume it's a string
  • use a common or registered prefix for objects

Plans, toDo

  • simple include facility and general compileTime processing and generating permanent named classes
  • Env or EnvMan without typing?
  • Batch interface with statments (assignments) in inputstring
  • Wir arbeiten immer mit obj → value mit spezieller Syntax
  • lokal Variablen, v.a. als Argumente für geschachtelte Blöcke, diese sind deklariert und durch ein statistche localMap auf eine localStack gemappt $@{:eins :zwei call....
  • data Syntax $...[...] und constHereData $/abc/ .......$/abc/
  • Prozedur aufruf [$@name $@name](primWord, primWord, ....) oder $-name(... (um objReferenz zurückzubekommen) name muss eine (evt. Lokel) Variable sein, kindOf Run
  • noOpenClose automatisch, falls schon offen oder besser explizit
  • compile time
  • fileMarker < statt |
  • assignment und output statements gehen bis endOfLine nicht nur shWord wie sonst – sinnvoll oder nicht?
  • Statt CodeBlöcke immer Singletons von Run zu machen, ist das schlau?
  • BufVar # eliminieren $>#eins können wir durch $>$eins oder $=eins.@{..$} ersetzen
  • Problem: $var in language bringt jetzt immer String zurück – aber $.$xx sollte obj bringen (Verschachtelungen??? - besser $-$xx zwingt auch Value!