parse()
Parses a string into tokens, where each token is delimited by a blank, tab, or operator. The following interpretations are made:
- Alphabetic characters include underscore (_) and dollar sign ($) as well as uppercase A through Z, lowercase a through z, and numbers 0 through 9.
- Numbers are interpreted as expected without separation into tokens because of sign or exponent notation.
- The characters period and E (or e) are interpreted as expected in the context of a number.
- A number followed by a string is interpreted as two tokens: the first numeric and the second a string.
- A string followed by a number (without an intervening operator or delimiting punctuation) is interpreted as a single string token.
- Operators are interpreted as string tokens and adjacent operators are merged into a single token. The other normal delimiters are blank and tab, which are treated as white space and are ignored except to separate tokens.
Special handling is provided for strings enclosed in double quotes, where the entire string (including the quotes) is interpreted as a single token. However, there is no provision for handling strings with embedded quotes.
If the optional delimiter and operator strings are used, stricter parsing rules are enabled. Only the listed characters will cause separation of the text into tokens, and these will always cause separation into tokens, regardless of the context. Delimiters will be discarded but will cause separation of tokens, while operators will be returned as single character strings, causing the special handling for real numbers, operators and strings to be unavailable when the delimiter or operator strings are specified. Returns: A list constructed from the tokens. A token may be returned as an integer, real, or string member in the list.
See also: list().
Syntax:
parse(text[, delim][, ops][, str]));
where
text is the string of text to be parsed.
delim is optional. String of delimiter characters. Recognizes normal arithmetic operators unless alternate characters are given in delimiter or special character strings. Default delimiters are space and tab.
ops is optional. String of special operator characters, each to be interpreted as an individual token. Default special operators are:
+ - * / = , ~ & ˆ < > ! # % ' () : ; ? @ [] \ ` {} �str is optional. Specifies to only return strings, where:
- FALSE = (default) each element is appropriately converted to int, real, or strings
- TRUE = returns a list of strings, no conversion takes place
Example:
The example returns a list containing "hello", 1, 7.8, "*", and 32.6.
decl mylist;
mylist = parse("hello 1 7.8 * 32.6");
ALSO
parse("123.456", ".", NULL); // returns list(123,456) parse("123.456", ".", NULL, TRUE); // returns list("123","456")
Download Example File:
The following link(s) lead to the Agilent EEsof EDA Knowledge center website. You will need to register at this site with a valid support contract to download an example file.
Get File Permissions
Get File Size
Get File Time Stamp
Where Used:
Measurement Expressions (Data Display equations and Schematic MeasEqns), Schematic, Layout, Simulation, GUI
Privacy
Statement
|
Terms of Use
|
Legal |
Contact Us
|
© Agilent 2000-2008 ![]()