Language
Type parsing
Strict parsers return a value, or they make a scene. Try-parsers write into slots you already prepared and tell you whether it worked.
Strict parsers
| Call | Result type |
|---|---|
| parsestr | str |
| parsenum | num |
| parsedecimal | decimal |
| parseschar | schar |
| parseboolean | boolean |
define num x is parsenum(readln); define str processCountText is parsestr(processCount);
If a strict parse cannot convert the value, that is an error. She will not pretend.
Try-parsers
Three arguments: source, destination, success flag. Both destinations must already exist — usually born with new.
| Call | Fills |
|---|---|
| tryparsenum | num + boolean |
| tryparsedecimal | decimal + boolean |
| tryparseschar | schar + boolean |
| tryparseboolean | boolean + boolean |
define num parsing is new; define boolean success is new; tryparsenum(goodParse, parsing, success); showln success; showln parsing;