Library content
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:
- Scanning starts at character position "startIndex" of "string"
(startIndex has a default of 1).
- First, white space is skipped, such as blanks (" "), tabs
("\t"), or newline ("\n")
- Afterwards, the required token is scanned.
- If successful, on return nextIndex = index of character
directly after the found token and the token value is returned as
second output argument.
If not successful, on return nextIndex = startIndex.
The following additional rules apply for the scanning:
- Function scanReal:
Scans a full number including one optional leading "+" or "-" (if
unsigned=false) according to the Modelica grammar. For example,
"+1.23e-5", "0.123" are Real numbers, but ".1" is not. Note, an
Integer number, such as "123" is also treated as a Real
number.
- Function scanInteger:
Scans an Integer number including one optional leading "+" or "-"
(if unsigned=false) according to the Modelica (and C/C++) grammar.
For example, "+123", "20" are Integer numbers. Note, a Real number,
such as "123.4" is not an Integer and scanInteger returns nextIndex
= startIndex.
- Function scanString:
Scans a String according to the Modelica (and C/C++) grammar, e.g.,
"This is a "string"" is a valid string token.
- Function scanIdentifier:
Scans a Modelica identifier, i.e., the identifier starts either
with a letter, followed by letters, digits or "_". For example,
"w_rel", "T12".
- Function skipLineComments
Skips white space and Modelica (C/C++) line comments iteratively. A
line comment starts with "//" and ends either with an end-of-line
("\n") or the end of the "string".
Contents
Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f