LEOgram to Map
A function that transforms a "LEOgram" to a map representation. Basically a function version of what the AdoScript command LEO
does, except not returning only certain parts but everything as a map and not a command but a function. LEOgrams seems to follow the KEYWORD attribute:value attribute:value ...
structure for the most part, so white spaces can be used to distinguish the tokens. However one problem can arise when values are strings that use white spaces. There might also be more context between the tokens. Maybe have a solution similar to how we process JSON?
From the ADOxx documentation on the LEO
command:
LEO ParseCmd { AccessCmd } .
ParseCmd : parse: strExpr .
AccessCmd :
get-elem-count: varName |
set-cur-elem-index: intExpr |
get-keyword: varName |
is-contained: varName [ : strExpr ] |
get-str-value: varName [ : strExpr ] |
get-int-value: varName [ : strExpr ] |
get-real-value: varName [ : strExpr ] |
get-tmm-value: varName [ : strExpr ] |
get-time-value: varName [ : strExpr ] |
get-modifier: varName : strExpr .
With LEO a LEOgram can be parsed which is given as a string. This can be useful if an external call delivers structured data in LEO format. The string containing the LEOgram is passed with parse. With get-elem-count the number of elements can be assigned to a variable. With set-cur-elem-index a current element can be set (element numbers run from 0 to n-1). The following read statements are related to the current element:
- get-keyword Get the element's keyword.
- is-contained Check if an attribute is specified.
- get-T-value Get an attribute value of type T . If no attribute name (= strExpr) is specified with get-T-value, the element's own value is taken. For T , one of the following types can be inserted: string, integer, real, measure, time.
- get-modifier Get the modifier of an attribute.