Libraries
Scanstri Source Code
 previous   up   next 

Function Summary
void
skipComment (inout string: stri)
Skips a possibly nested comment from a string.
string
getComment (inout string: stri)
Reads a possibly nested comment from a string.
void
skipClassicComment (inout string: stri)
Skips a classic C comment from a string.
void
skipLineComment (inout string: stri)
Skips a line comment from a string.
string
getLineComment (inout string: stri)
Reads a line comment from a string.
string
getDigits (inout string: stri)
Reads a sequence of digits from a string.
string
getHexDigits (inout string: stri)
Reads a sequence of hexadecimal digits from a string.
string
getInteger (inout string: stri)
Reads a decimal integer with optional sign from a string.
string
getNumber (inout string: stri)
Reads a numeric literal from a string.
string
getNonDigits (inout string: stri)
Reads a sequence of non digits from a string.
string
getQuotedText (inout string: stri)
Reads a text quoted with characters like " and ' from a string.
string
getCommandLineWord (inout string: stri)
Read a space terminated command line word, from a string.
string
getSimpleStringLiteral (inout string: stri)
Read a simple string literal from a string.
void
getEscapeSequence (in string: stri, inout integer: pos, inout string: symbol)
Reads an escape sequence from stri and appends it to symbol.
string
getCharLiteral (inout string: stri)
Reads a character literal from a string.
string
getStringLiteral (inout string: stri)
Reads a string literal from a string.
string
getCStringLiteralText (inout string: stri)
Reads the text of a string literal from a string.
string
getLetters (inout string: stri)
Reads a sequence of letters from a string.
string
getName (inout string: stri)
Reads an alphanumeric name from a string.
void
skipSpace (inout string: stri)
Skips space characters from a string.
void
skipSpaceOrTab (inout string: stri)
Skips space and tab characters from a string.
void
skipWhiteSpace (inout string: stri)
Skips whitespace characters from a string.
string
getWhiteSpace (inout string: stri)
Reads whitespace characters from a string.
string
getWord (inout string: stri)
Reads a white space delimited word from a string.
string
getWord (inout string: stri, in set of char: wordChars)
Reads a word consisting of wordChars from a string.
void
skipLine (inout string: stri)
Skips a line from a string.
string
getLine (inout string: stri)
Reads a line from a string.
string
getSymbolOrComment (inout string: stri)
Reads a symbol or a comment from a string.
string
getSymbol (inout string: stri)
Reads a symbol from a string.
void
skipXmlComment (inout string: stri)
Skips an XML comment from a string.
string
getXmlTagOrContent (inout string: stri)
Reads an XML/HTML tag or the XML/HTML content text from a string.
string
getXmlCdataContent (inout string: stri)
Read the content text of a CDATA section.
string
getXmlTagHeadOrContent (inout string: stri)
Reads an XML/HTML tag head or an XML/HTML content from a string.
string
getSymbolInXmlTag (inout string: stri)
Reads a symbol which can appear inside an XML/HTML tag from string.
void
skipXmlTag (inout string: stri)
Skips beyond an XML Tag in a string.
void
skipXmlTag (inout string: stri, in var string: symbol)
Skips beyond an XML Tag in a string.
void
getNextXmlAttribute (inout string: stri, inout string: attributeName, inout string: attributeValue)
Reads name and value of an attribute inside an XML tag from a string.
string
getHtmlAttributeValue (inout string: stri)
Reads a HTML tag attribute value from a string.
void
getNextHtmlAttribute (inout string: stri, inout string: attributeName, inout string: attributeValue)
Reads name and value of an attribute inside a HTML tag from a string.
string
getHttpSymbol (inout string: stri)
Reads a symbol which appears in a HTTP header from a string.

Function Detail

skipComment

const proc: skipComment (inout string: stri)

Skips a possibly nested comment from a string. The comment starts with (* and ends with *) . When the function is called it is assumed that stri[1] contains the '*' of the comment start. When the function is left stri is empty or stri[1] contains the character after the ')'.


getComment

const func string: getComment (inout string: stri)

Reads a possibly nested comment from a string. The comment starts with (* and ends with *) . When the function is called it is assumed that stri[1] contains the '*' of the comment start. When the function is left stri is empty or stri[1] contains the character after the ')'.

Returns:
the content of the comment, including the introducing (* and the ending *) .

skipClassicComment

const proc: skipClassicComment (inout string: stri)

Skips a classic C comment from a string. The comment starts with /* and ends with */ . In a classic C comment no nesting of comments is allowed. When the function is called it is assumed that stri[1] contains the '*' of the comment start. When the function is left stri is empty or stri[1] contains the character after the '/'.


skipLineComment

const proc: skipLineComment (inout string: stri)

Skips a line comment from a string. A line comment starts with an introducing character (like '#') and ends with the end of the line. When the function is called it is assumed that stri is empty or stri[1] contains the introducing character (e.g. '#'). When the function is left stri is empty or stri[1] contains the line end character ('\n').


getLineComment

const func string: getLineComment (inout string: stri)

Reads a line comment from a string. A line comment starts with an introducing character (like '#') and ends with the end of the line. When the function is called it is assumed that stri is empty or stri[1] contains the introducing character (e.g. '#'). When the function is left stri is empty or stri[1] contains the line end character ('\n').

Returns:
the content of the comment, including the start marker (e.g. '#') but without line end character ('\n').

getDigits

const func string: getDigits (inout string: stri)

Reads a sequence of digits from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the digits.

stri := "12";    getDigits(stri)  returns  "12"  and stri = ""
stri := "12ab";  getDigits(stri)  returns  "12"  and stri = "ab"
stri := "ab";    getDigits(stri)  returns  ""    and stri = "ab"
stri := " 12";   getDigits(stri)  returns  ""    and stri = " 12"
Returns:
the digit sequence, and "" if no digit was found.

getHexDigits

const func string: getHexDigits (inout string: stri)

Reads a sequence of hexadecimal digits from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the hexadecimal digits.

stri := "1f";   getHexDigits(stri)  returns  "1f"  and stri = ""
stri := "1ag";  getHexDigits(stri)  returns  "1a"  and stri = "g"
stri := "gx";   getHexDigits(stri)  returns  ""    and stri = "gx"
stri := " 1a";  getHexDigits(stri)  returns  ""    and stri = " 1a"
Returns:
the digit sequence, and "" if no digit was found.

getInteger

const func string: getInteger (inout string: stri)

Reads a decimal integer with optional sign from a string. A decimal integer accepted by getInteger consists of an optional + or - sign followed by a possibly empty sequence of digits. Because of the LL(1) approach, a sign without following digits is accepted. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the integer.

stri := "123*2";  getInteger(stri)  returns  "123"  and stri = "*2"
stri := "+1-2";   getInteger(stri)  returns  "+1"   and stri = "-2"
stri := "-2+3";   getInteger(stri)  returns  "-2"   and stri = "+3"
stri := "+-0";    getInteger(stri)  returns  "+"    and stri = "-0"
stri := "pi";     getInteger(stri)  returns  ""     and stri = "pi"
Returns:
the decimal integer string, and "" if no integer was found.

getNumber

const func string: getNumber (inout string: stri)

Reads a numeric literal from a string. When the function is called it is assumed that stri is empty or stri[1] contains the introducing digit. When the function is left stri is empty or stri[1] contains the character after the literal.

stri := "1x";      getNumber(stri)  returns  "1"       and stri = "x"
stri := "1.0+";    getNumber(stri)  returns  "1.0"     and stri = "+"
stri := "1.0E1-";  getNumber(stri)  returns  "1.0E1"   and stri = "-"
stri := "1.0e-1";  getNumber(stri)  returns  "1.0e-1"  and stri = ""
stri := "2#101*";  getNumber(stri)  returns  "2#101"   and stri = "*"
stri := "1e2y";    getNumber(stri)  returns  "1e2"     and stri = "y"
stri := "1E+3z";   getNumber(stri)  returns  "1E+3"    and stri = "z"
stri := "1234_/";  getNumber(stri)  returns  "1234_"   and stri = "/"
Returns:
The function returns the numeric literal.

getNonDigits

const func string: getNonDigits (inout string: stri)

Reads a sequence of non digits from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains a digit.

stri := "1+2";   getNonDigits(stri)  returns  ""    and stri = "1+2"
stri := " 1+2";  getNonDigits(stri)  returns  " "   and stri = "1+2"
stri := "-1+2";  getNonDigits(stri)  returns  "-"   and stri = "1+2"
stri := "a+2";   getNonDigits(stri)  returns  "a+"  and stri = "2"
Returns:
the non digit sequence, and "" if a digit was found.

getQuotedText

const func string: getQuotedText (inout string: stri)

Reads a text quoted with characters like " and ' from a string. The introducing and the closing quoting character must be identical. When the function is called it is assumed that stri[1] contains the introducing quoting character (which can be any character). When the function is left stri is empty or stri[1] contains the character after the closing quoting character.

stri := "'ab'+";  getQuotedText(stri)  returns  "ab"  and stri = "+"
stri := "''=a";   getQuotedText(stri)  returns  ""    and stri = "=a"
stri := "\"A\"";  getQuotedText(stri)  returns  "A"   and stri = ""
stri := "\"\"?";  getQuotedText(stri)  returns  ""    and stri = "?"
stri := ":ab:5";  getQuotedText(stri)  returns  "ab"  and stri = "5"
stri := "+XY";    getQuotedText(stri)  returns  "XY"  and stri = ""
Returns:
the string literal without introducing or closing characters ( " or ' ).

getCommandLineWord

const func string: getCommandLineWord (inout string: stri)

Read a space terminated command line word, from a string. Before reading the word it skips whitespace characters. A command line word can consist of unquoted and quoted parts. A quoted part is introduced with double quotes (") and ends with unescaped double quotes. A \ (backslash) is used to escape characters that would terminate the word respectively the quoted part. The backslash is ignored and the character after it is added to the word. To represent a backslash it must be doubled. When the function is left stri is empty or stri[1] contains the character after the terminating space. Examples:

stri := "a b c";        getCommandLineWord(stri) returns "a"
stri := "a\\ b c";      getCommandLineWord(stri) returns "a b"
stri := " a b c";       getCommandLineWord(stri) returns "a"
stri := "\\ a b c";     getCommandLineWord(stri) returns " a"
stri := "a\\\"b c";     getCommandLineWord(stri) returns "a\"b"
stri := "a\" b\" c";    getCommandLineWord(stri) returns "a b"
stri := "\"a b\" c";    getCommandLineWord(stri) returns "a b"
stri := " \"a\" b c";   getCommandLineWord(stri) returns "a"
stri := "\" a\" b c";   getCommandLineWord(stri) returns " a"
stri := " \" a\" b c";  getCommandLineWord(stri) returns " a"
stri := "\"a\\\"b\" c"; getCommandLineWord(stri) returns "a\"b"
stri := "a\\\\b c";     getCommandLineWord(stri) returns "a\\b"
Returns:
the space terminated word (without terminating space).

getSimpleStringLiteral

const func string: getSimpleStringLiteral (inout string: stri)

Read a simple string literal from a string. A simple string literal is enclosed in delimiter characters (e.g. " or ' ). Delimiter characters within the simple string literal must be doubled. A simple string literal does not support an escape character. All characters, including control characters (e.g. linefeed) are allowed inside a simple string literal. When the function is called it is assumed that stri[1] contains the introducing delimiter character. When the function is left stri is empty or stri[1] contains the character after the closing delimiter.

stri := "\"\"";        getSimpleStringLiteral(stri) returns "\"\""
stri := "\"\"x";       getSimpleStringLiteral(stri) returns "\"\""
stri := "\"\"\"";      getSimpleStringLiteral(stri) returns "\"\"\""
stri := "\"\"\"\"";    getSimpleStringLiteral(stri) returns "\"\"\""
stri := "\"a\"\"\"";   getSimpleStringLiteral(stri) returns "\"a\"\""
stri := "\"\"\"b\"";   getSimpleStringLiteral(stri) returns "\"\"b\""
stri := "\"a\"\"b\"";  getSimpleStringLiteral(stri) returns "\"a\"b\""
stri := "\"\"\"\"x";   getSimpleStringLiteral(stri) returns "\"\"\""
stri := "\"a\"\"\"x";  getSimpleStringLiteral(stri) returns "\"a\"\""
stri := "\"\"\"b\"x";  getSimpleStringLiteral(stri) returns "\"\"b\""
stri := "\"a\"\"b\"x"; getSimpleStringLiteral(stri) returns "\"a\"b\""
Returns:
the string literal including the introducing and closing delimiter character. Double delimiter chars in the literal are converted to single delimiter chars.

getEscapeSequence

const proc: getEscapeSequence (in string: stri, inout integer: pos, inout string: symbol)

Reads an escape sequence from stri and appends it to symbol. The function accepts escape sequences from character and string literals. When the function is called it is assumed that stri[1] contains the introducing \ . When the function is left stri[1] contains the character after the escape sequence. The complete escape sequence including the introducing \ is appended to symbol.


getCharLiteral

const func string: getCharLiteral (inout string: stri)

Reads a character literal from a string. When the function is called it is assumed that stri[1] contains the introducing ' . When the function is left stri is empty or stri[1] contains the character after the closing ' .

Returns:
the character literal including the introducing ' and the closing ' .

getStringLiteral

const func string: getStringLiteral (inout string: stri)

Reads a string literal from a string. When the function is called it is assumed that stri[1] contains the introducing " . When the function is left stri is empty or stri[1] contains the character after the closing " .

Returns:
the string literal including the introducing " and the closing " .

getCStringLiteralText

const func string: getCStringLiteralText (inout string: stri)

Reads the text of a string literal from a string. When the function is called it is assumed that stri[1] contains the introducing " . When the function is left stri is empty or stri[1] contains the character after the closing " .

Returns:
the text of the string literal without introducing or closing " .

getLetters

const func string: getLetters (inout string: stri)

Reads a sequence of letters from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the letters.

stri := "test";    getLetters(stri)  returns  "test"  and stri = ""
stri := "test1";   getLetters(stri)  returns  "test"  and stri = "1";
stri := "test+1";  getLetters(stri)  returns  "test"  and stri = "+1"
stri := "+1";      getLetters(stri)  returns  ""      and stri = "+1"
Returns:
the letter sequence, and "" if no letter was found.

getName

const func string: getName (inout string: stri)

Reads an alphanumeric name from a string. A name consists of a letter or underscore followed by letters, digits or underscores. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the name.

stri := "test";    getName(stri)  returns  "test"   and stri = ""
stri := "test1";   getName(stri)  returns  "test1"  and stri = "";
stri := "test+1";  getName(stri)  returns  "test"   and stri = "+1"
stri := "+1";      getName(stri)  returns  ""       and stri = "+1"
Returns:
the name, and "" if no letter or underscore was found.

skipSpace

const proc: skipSpace (inout string: stri)

Skips space characters from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the space characters.

stri := "  ok";  skipSpace(stri);  afterwards  stri = "ok"
stri := "   ";   skipSpace(stri);  afterwards  stri = ""
stri := "ok ";   skipSpace(stri);  afterwards  stri = "ok "

skipSpaceOrTab

const proc: skipSpaceOrTab (inout string: stri)

Skips space and tab characters from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the sequence of space and tab characters.

stri := "\t x";  skipSpaceOrTab(stri);  afterwards  stri = "x"
stri := "\t  ";  skipSpaceOrTab(stri);  afterwards  stri = ""
stri := "abc ";  skipSpaceOrTab(stri);  afterwards  stri = "abc "

skipWhiteSpace

const proc: skipWhiteSpace (inout string: stri)

Skips whitespace characters from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the whitespace characters.

stri := "\t\n\r X";  skipWhiteSpace(stri);  afterwards  stri = "X"
stri := "\t\n\r ";   skipWhiteSpace(stri);  afterwards  stri = ""
stri := "X ";        skipWhiteSpace(stri);  afterwards  stri = "X "

getWhiteSpace

const func string: getWhiteSpace (inout string: stri)

Reads whitespace characters from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the whitespace characters.

stri := "\t X";  getWhiteSpace(stri)  returns  "\t "   and stri = "X"
stri := "\r\n";  getWhiteSpace(stri)  returns  "\r\n"  and stri = ""
stri := "X ";    getWhiteSpace(stri)  returns  ""      and stri = "X "
Returns:
the string of whitespace characters, and "" if no whitespace character was found.

getWord

const func string: getWord (inout string: stri)

Reads a white space delimited word from a string. Before reading the word it skips whitespace characters. A word is a sequence of characters which does not contain a whitespace character. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the word.

stri := " abc";   getWord(stri)  returns  "abc"  and stri = ""
stri := " abc ";  getWord(stri)  returns  "abc"  and stri = " "
stri := "abc\t";  getWord(stri)  returns  "abc"  and stri = "\t"
Returns:
the word, and "" if no word was found.

getWord

const func string: getWord (inout string: stri, in set of char: wordChars)

Reads a word consisting of wordChars from a string. Before reading the word it skips non-wordChars characters. A word is a sequence of wordChars characters. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains the character after the word.

stri := " a1";   getWord(stri, alphanum_char)  returns  "a1"  and stri = ""
stri := "-a2.";  getWord(stri, alphanum_char)  returns  "a2"  and stri = "."
stri := "=a3,";  getWord(stri, alphanum_char)  returns  "a3"  and stri = ","
stri := "a4\t";  getWord(stri, alphanum_char)  returns  "a4"  and stri = "\t"
stri := ", a5";  getWord(stri, alphanum_char)  returns  "a5"  and stri = ""
Returns:
the word, and "" if no word was found.

skipLine

const proc: skipLine (inout string: stri)

Skips a line from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains '\n'. If stri[1] already contains '\n' nothing is done.

stri := "ab\nc";  skipLine(stri);  afterwards  stri = "\nc"
stri := "abc";    skipLine(stri);  afterwards  stri = ""

getLine

const func string: getLine (inout string: stri)

Reads a line from a string. When the function is called it is assumed that stri is empty or stri[1] contains the first character to be handled. When the function is left stri is empty or stri[1] contains '\n'. If stri[1] already contains '\n' nothing is done and the function returns "" .

stri := "ab\nc";  getLine(stri)  returns  "ab"   and stri = "\nc"
stri := "abc";    getLine(stri)  returns  "abc"  and stri = ""
Returns:
the line read, and "" if stri is empty or stri[1] contains '\n'.

getSymbolOrComment

const func string: getSymbolOrComment (inout string: stri)

Reads a symbol or a comment from a string. Before reading the symbol or comment it skips whitespace characters. A symbol can be a literal (numeric, character or string), a name, a special symbol (sequence of special characters) or a parenthesis. A comment can be a normal comment or a line comment. When the function is called it is assumed that stri is empty or stri[1] contains a whitespace character or the first character of a symbol or comment. When the function is left stri is empty or stri[1] contains the character after the symbol or comment.

Returns:
the symbol or comment, and "" if the end of stri was reached.

getSymbol

const func string: getSymbol (inout string: stri)

Reads a symbol from a string. Before reading the symbol it skips whitespace characters and comments (normal comments and line comments). A symbol can be a literal (numeric, character or string), a name, a special symbol (sequence of special characters) or a parenthesis. When the function is called it is assumed that stri is empty or stri[1] contains a whitespace character or the first character of a symbol or comment. When the function is left stri is empty or stri[1] contains the character after the symbol.

Returns:
the symbol, and "" if end of stri was reached.

skipXmlComment

const proc: skipXmlComment (inout string: stri)

Skips an XML comment from a string. The XML comment starts with <!-- and ends with --> . When the function is called it is assumed that stri[1] contains the last '-' of the introducing <!-- . When the function is left stri is empty or stri[1] contains the character after --> .


getXmlTagOrContent

const func string: getXmlTagOrContent (inout string: stri)

Reads an XML/HTML tag or the XML/HTML content text from a string. An XML/HTML tag starts with < and ends with > . The content text starts with everything else and ends just before a < or with the end of stri. When the function is called it is assumed that stri[1] contains the introducing < of an XML/HTML tag or the first character of the content text. When the function is left the character after the XML/HTML tag or the content text is in stri[1].

Returns:
the XML/HTML tag or XML/HTML content text, and "" if the end of stri was reached.

getXmlCdataContent

const func string: getXmlCdataContent (inout string: stri)

Read the content text of a CDATA section. In a CDATA section the text between <![CDATA[ and ]]> is considered content text. Inside a CDATA section the characters < and & have no special meaning. All occurances of < and & inside CDATA are returned as &lt; and &amp; respectively. When the function is called it is assumed that stri is empty or stri[1] contains the first character after the introducing <![CDATA[ sequence. When the function is left stri is empty or stri[1] contains the character after final ]]> sequence.

Parameters:
stri - Input string from which the consumed characters are removed.
Returns:
the content text of the CDATA section that has been read.

getXmlTagHeadOrContent

const func string: getXmlTagHeadOrContent (inout string: stri)

Reads an XML/HTML tag head or an XML/HTML content from a string. Examples of XML/HTML tag heads are:

<html
<meta
<table
</span

Before reading a tag head or content, it skips whitespace characters and XML comments. An XML/HTML tag head starts with < and ends before a > or a / or a whitespace character or the end of stri. The content text starts with a non whitespace character and ends just before a < or with the end of stri. Content text can be also in a CDATA section. In a CDATA section the text between <![CDATA[ and ]]> is considered content text. Inside a CDATA section the characters < and & have no special meaning. All occurances of < and & inside CDATA are returned as &lt; and &amp; respectively. When the function is called it is assumed that stri is empty or stri[1] contains either a whitespace character, the introducing < of an XML/HTML tag or the first character of the content text. When the function is left, stri is empty or stri[1] contains the character after the XML/HTML tag head or the content text. Text between <!-- and --> is considered an XML comment. An XML comment is ignored and getXmlTagHeadOrContent() is called recursive. The function can be used as follows:

symbol := getXmlTagHeadOrContent(stri);
if startsWith(symbol, "</") then
  ... handle the XML/HTML end-tag ...
elsif startsWith(symbol, "<") then
  ... handle the attributes of the XML/HTML start-tag ...
else
  ... handle the content text ...
end if;
Parameters:
stri - Input string from which the consumed characters are removed.
Returns:
the XML/HTML tag head or XML/HTML content text, and "" if the end of stri was reached.

getSymbolInXmlTag

const func string: getSymbolInXmlTag (inout string: stri)

Reads a symbol which can appear inside an XML/HTML tag from string. Before reading the symbol it skips whitespace characters. A symbol inside an XML/HTML tag can be a name, a string literal (quoted with " or ' ), the equals sign (=), the end of tag character (>), the slash character (/) or a special symbol (a sequence of characters that does not include the character > or a whitespace character). Special symbols can only appear in HTML tags. When the function is called it is assumed that stri is empty or stri[1] contains a whitespace character or the first character of a symbol. When the function is left stri is empty or stri[1] contains the character after the symbol.

Parameters:
stri - Input string from which the consumed characters are removed.
Returns:
the symbol, and "" if the end of stri was reached.

skipXmlTag

const proc: skipXmlTag (inout string: stri)

Skips beyond an XML Tag in a string. When the function is left stri is empty or stri[1] contains the character after '>'.


skipXmlTag

const proc: skipXmlTag (inout string: stri, in var string: symbol)

Skips beyond an XML Tag in a string. The parameter symbol is used to provide the current symbol which possibly can be ">" or "". When the function is left stri is empty or stri[1] contains the character after '>'.


getNextXmlAttribute

const proc: getNextXmlAttribute (inout string: stri, inout string: attributeName, inout string: attributeValue)

Reads name and value of an attribute inside an XML tag from a string. The function skips possible leading whitespace characters. Attribute name and value are returned in attributeName and attributeValue respectively. Attribute assignments can have the following forms:

aName="aValue"
aName='aValue'

Surrounding single or double quotes of the attribute value are omitted. It is a syntax error if an attribute value is not quoted. White space characters before and after the = are ignored. XML entities in attributeValue are left as is. If no more attributes are present in the XML tag attributeName is set to "". In this case attributeValue contains the end of the XML tag (">" or "/>") and stri is empty or stri[1] contains the character after '>'. If a syntax error occurs the function skips beyond the end of the XML tag (stri is empty or stri[1] contains the character after '>'). To indicate the syntax error attributeName is set to "" and attributeValue is set to a symbol shortly before the error (this will never be ">" or "/>"). The attributes of an XML start-tag or empty-element tag can be processed with:

getNextXmlAttribute(stri, attributeName, attributeValue);
while attributeName <> "" do
  ... process the current attribute ...
  getNextXmlAttribute(stri, attributeName, attributeValue);
end while;
if attributeValue = "/>" then
  ... this is an empty-element tag ...
elsif attributeValue = ">" then
  ... this is a start-tag ...
else
  ... there is a syntax error ...
end if;
Parameters:
stri - Input string from which the consumed characters are removed.
attributeName - Destination for the attribute name.
attributeValue - Destination for the attribute value:

getHtmlAttributeValue

const func string: getHtmlAttributeValue (inout string: stri)

Reads a HTML tag attribute value from a string. Before reading the value it skips whitespace characters. A HTML tag attribute value can be quoted with " or ' or it is terminated with the character > or a whitespace character. When the function is called it is assumed that stri is empty or stri[1] contains a whitespace character or the first character of a value. When the function is left stri is empty or stri[1] contains the character after the attribute value.

Parameters:
stri - Input string from which the consumed characters are removed.
Returns:
the attribute value, and "" if the end of the HTML tag or the end of stri is directly after the skipped whitespace characters.

getNextHtmlAttribute

const proc: getNextHtmlAttribute (inout string: stri, inout string: attributeName, inout string: attributeValue)

Reads name and value of an attribute inside a HTML tag from a string. The function skips possible leading whitespace characters. Attribute name and value are returned in attributeName and attributeValue respectively. Attribute assignments can have the following forms:

aName="aValue"
aName='aValue'
aName=aValue
aName

Possible surrounding single or double quotes of the attribute value are omitted. White space characters before and after the = are ignored. HTML entities in attributeValue are left as is. If no more attributes are present in the XML tag attributeName is set to "". In this case attributeValue contains the end of the HTML tag (">" or "/>") and stri is empty or stri[1] contains the character after '>'. The attributes of a HTML start-tag or empty-element tag can be processed with:

getNextHtmlAttribute(stri, attributeName, attributeValue);
while attributeName <> "" do
  ... process the current attribute ...
  getNextHtmlAttribute(stri, attributeName, attributeValue);
end while;
if attributeValue = "/>" then
  ... this is an empty-element tag ...
else  # attributeValue = ">"
  ... this is a start-tag ...
end if;
Parameters:
stri - Input string from which the consumed characters are removed.
attributeName - Destination for the attribute name.
attributeValue - Destination for the attribute value:

getHttpSymbol

const func string: getHttpSymbol (inout string: stri)

Reads a symbol which appears in a HTTP header from a string. Before reading the symbol it skips whitespace characters. A symbol from a HTTP header can be a token a string literal or a separator. When the function is called it is assumed that stri is empty or stri[1] contains a whitespace character or the first character of a symbol. When the function is left stri is empty or stri[1] contains the character after the symbol.

Returns:
the symbol, and "" if the end of stri was reached.


 previous   up   next