Package Strings.Advanced contains basic scanning functions. These functions should be not called directly, because it is much simpler to utilize the higher level functions "Strings.scanXXX". The functions of the "Strings.Advanced" library provide the basic interface in order to implement the higher level functions in package "Strings".
Library "Advanced" provides the following functions:
(nextIndex, realNumber) = scanReal (string, startIndex, unsigned=false); (nextIndex, integerNumber) = scanInteger (string, startIndex, unsigned=false); (nextIndex, string2) = scanString (string, startIndex); (nextIndex, identifier) = scanIdentifier (string, startIndex); nextIndex = skipWhiteSpace (string, startIndex); nextIndex = skipLineComments(string, startIndex);
All functions perform the following actions:
The following additional rules apply for the scanning:
Extends from Modelica.Icons.FunctionsPackage
(Icon for packages containing functions).
Name | Description |
---|---|
scanIdentifier | Scan simple identifiers |
scanInteger | Scan signed integer number |
scanReal | Scan a signed real number |
scanString | Scan string |
skipLineComments | Scan comments and white space |
skipWhiteSpace | Scan white space |
(nextIndex, realNumber) = scanReal(string, startIndex=1, unsigned=false);
Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a number of type Real with an optional sign according to the Modelica grammar:
real ::= [sign] unsigned [fraction] [exponent] sign ::= '+' | '-' unsigned ::= digit [unsigned] fraction ::= '.' [unsigned] exponent ::= ('e' | 'E') [sign] unsigned digit ::= '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
If successful, the function returns nextIndex = index of character directly after the found real number, as well as the value in the second output argument.
If not successful, on return nextIndex = startIndex and the second output argument is zero.
If the optional argument "unsigned" is true, the number shall not start with '+' or '-'. The default of "unsigned" is false.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex | Index where scanning starts |
Boolean | unsigned | = true, if number shall not start with '+' or '-' |
Type | Name | Description |
---|---|---|
Integer | nextIndex | Index after the found token (success=true) or index at which scanning failed (success=false) |
Real | number | Value of Real number |
(nextIndex, integerNumber) = scanInteger(string, startIndex=1, unsigned=false);
Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a signed number of type Integer. An Integer starts with an optional '+' or '-', immediately followed by a non-empty sequence of digits.
If successful, the function returns nextIndex = index of character directly after the found Integer number, as well as the Integer value in the second output argument.
If not successful, on return nextIndex = startIndex and the second output argument is zero.
Note, a Real number, such as "123.4", is not treated as an Integer number and scanInteger will return nextIndex = startIndex in this case.
If the optional argument "unsigned" is true, the number shall not start with '+' or '-'. The default of "unsigned" is false.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex |   |
Boolean | unsigned | = true, if number shall not start with '+' or '-' |
Type | Name | Description |
---|---|---|
Integer | nextIndex | Index after the found token (success=true) or index at which scanning failed (success=false) |
Integer | number | Value of Integer number |
(nextIndex, string2) = scanString(string, startIndex=1);
Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a string according to the Modelica grammar, i.e., a string enclosed in double quotes.
If successful, the function returns nextIndex = index of character directly after the found string, as well as the string value in the second output argument.
If not successful, on return nextIndex = startIndex and the second output argument is an empty string.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex | Index where scanning starts |
Type | Name | Description |
---|---|---|
Integer | nextIndex | Index after the found token (success=true) or index at which scanning failed (success=false) |
String | string2 | Value of String token |
(nextIndex, identifier) = scanIdentifier(string, startIndex=1);
Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a Modelica identifier, i.e., a sequence of characters starting with a letter ("a".."z" or "A".."Z") followed by letters, digits or underscores ("_").
If successful, the function returns nextIndex = index of character directly after the found identifier, as well as the identifier as string in the second output argument.
If not successful, on return nextIndex = startIndex and the second output argument is an empty string.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex | Index where scanning starts |
Type | Name | Description |
---|---|---|
Integer | nextIndex | Index after the found token (success=true) or index at which scanning failed (success=false) |
String | identifier | Value of identifier token |
nextIndex = skipWhiteSpace(string, startIndex);
Starts scanning of "string" at position "startIndex" and skips white space. The function returns nextIndex = index of character of the first non white space character.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex |   |
Type | Name | Description |
---|---|---|
Integer | nextIndex |   |
nextIndex = skipLineComments(string, startIndex);
Starts scanning of "string" at position "startIndex". First skips white space and scans afterwards a Modelica (C/C++) line comment, i.e., a sequence of characters that starts with "//" and ends with an end-of-line "\n" or with the end of the string. If end-of-line is reached, the function continues to skip white space and scanning of line comments until end-of-string is reached, or another token is detected.
If successful, the function returns nextIndex = index of character directly after the found line comment.
If not successful, on return nextIndex = startIndex.
Extends from Modelica.Icons.Function
(Icon for functions).
Type | Name | Description |
---|---|---|
String | string |   |
Integer | startIndex |   |
Type | Name | Description |
---|---|---|
Integer | nextIndex |   |
Generated 2018-12-12 12:14:36 EST by MapleSim.