This class holds the character classes used by an Engine. More...
#include <elamcharclass.h>
Public Member Functions | |
| QString | operatorClass () const |
| class of operator characters | |
| void | setOperatorClass (QString) |
| sets the class of operator characters | |
| QPair< QString, QString > | nameClass () const |
| returns the two name sub-classes nameClass().first refers to start characters, nameClass().second refers to all characters that can turn up anywhere in names | |
| void | setNameClass (QString startchars, QString allchars) |
| sets the two sub-classes of names | |
| void | setNameClass (const QPair< QString, QString > &chars) |
| convenience overload: sets the two sub-classes of names | |
| QString | whitespaceClass () const |
| returns all characters that are regarded as whitespace | |
| void | setWhitespaceClass (QString) |
| sets all characters that are regarded as whitespace | |
| QString | literalStartClass () const |
| returns all characters that start a literal, normally digits ' and " | |
| void | setLiteralStartClass (QString) |
| sets characters that can start a literal | |
| QPair< QChar, QChar > | parenthesesChars () const |
| returns the opening (first) and closing (second) character of parentheses | |
| void | setParentheses (QChar open, QChar close) |
| sets the characters used for parentheses | |
| QPair< QChar, QChar > | assignmentChars () const |
| returns the characters that designate an assignment | |
| void | setAssignmentChars (QChar start, QChar end) |
| sets the characters used for assignment operators | |
| QChar | commaChar () const |
| returns the character used as a comma (separator of function arguments) | |
| void | setCommaChar (QChar) |
| sets the character used as comma | |
| bool | isConsistent () const |
| true if the settings are internally consistent | |
| Token::Type | charType (QChar ch, Token::Type oldtype) const |
| returns the type of token the character belongs to | |
| bool | isAssignment (QString) const |
| returns true if the string contains any assignment operator | |
| bool | isSimpleAssignment (QString) const |
| returns true if the string contains exactly the simple assignment operator | |
| bool | isName (QString) const |
| returns true if the string can be interpreted as name | |
| bool | isOperator (QString) const |
| returns true if the string can be interpreted as operator | |
| QString | toOperator (QString) const |
| removes assignment chars from the token and returns the pure operator or an empty string if it was a pure assignment | |
This class holds the character classes used by an Engine.
There are three major classes of chracters:
None of these three classes may overlap. There are several more minor classes:
| QPair<QChar,QChar> ELAM::CharacterClassSettings::assignmentChars | ( | ) | const |
returns the characters that designate an assignment
| Token::Type ELAM::CharacterClassSettings::charType | ( | QChar | ch, | |
| Token::Type | oldtype | |||
| ) | const |
returns the type of token the character belongs to
| ch | the character to be checked | |
| oldtype | the type the previous character belongs to (set to Invalid if this is the first character) |
Compares the character with the known settings for character classes and returns its probable token type. The old type of the previous character is necessary to check for context sensitive rules.
| QChar ELAM::CharacterClassSettings::commaChar | ( | ) | const |
returns the character used as a comma (separator of function arguments)
| bool ELAM::CharacterClassSettings::isAssignment | ( | QString | ) | const |
returns true if the string contains any assignment operator
| bool ELAM::CharacterClassSettings::isConsistent | ( | ) | const |
true if the settings are internally consistent
The character class settings are consistent if all constraints of class inclusion and exclusion are fullfilled.
| bool ELAM::CharacterClassSettings::isName | ( | QString | ) | const |
returns true if the string can be interpreted as name
| bool ELAM::CharacterClassSettings::isOperator | ( | QString | ) | const |
returns true if the string can be interpreted as operator
| bool ELAM::CharacterClassSettings::isSimpleAssignment | ( | QString | ) | const |
returns true if the string contains exactly the simple assignment operator
| QString ELAM::CharacterClassSettings::literalStartClass | ( | ) | const |
returns all characters that start a literal, normally digits ' and "
| QPair<QString,QString> ELAM::CharacterClassSettings::nameClass | ( | ) | const |
returns the two name sub-classes nameClass().first refers to start characters, nameClass().second refers to all characters that can turn up anywhere in names
| QString ELAM::CharacterClassSettings::operatorClass | ( | ) | const |
class of operator characters
| QPair<QChar,QChar> ELAM::CharacterClassSettings::parenthesesChars | ( | ) | const |
returns the opening (first) and closing (second) character of parentheses
| void ELAM::CharacterClassSettings::setAssignmentChars | ( | QChar | start, | |
| QChar | end | |||
| ) |
sets the characters used for assignment operators
| start | if not '' the character that marks the start of an assignment | |
| end | if not '' the character that marks the end of an assignment |
The combination of both characters along (without whitespace) is the direct assignment operator. In automatic assignment operator mode any operator that starts with the start character and ends with end character is regarded as an implicit assignment.
In the default configuration the start character is not set ('') and the end character is '=', so "a=1" will assign the value "1" to the variable "a" and "a += 1" is equivalent to "a = a + 1".
You can turn this automatism around by defining a start character only (e.g. start='=' and end=''). Then the assignment would still be "a = 1", but the combination of assignment and "+" would become "a =+ 1".
If you define both characters then both must be present in assignments. For example with start=':' and end='=' then assignment becomes "a:=1" and assignment with "+" becomes "a :+= 1".
If set, both characters must be part of the operator class.
If both start and end are '' it will be impossible to make assignments
| void ELAM::CharacterClassSettings::setCommaChar | ( | QChar | ) |
sets the character used as comma
The character must not be part of any other class.
| void ELAM::CharacterClassSettings::setLiteralStartClass | ( | QString | ) |
sets characters that can start a literal
| void ELAM::CharacterClassSettings::setNameClass | ( | const QPair< QString, QString > & | chars | ) | [inline] |
convenience overload: sets the two sub-classes of names
| chars.first | are characters that can start a name | |
| chars.second | are characters that can turn up anywhere in names, second must include all characters from first |
| void ELAM::CharacterClassSettings::setNameClass | ( | QString | startchars, | |
| QString | allchars | |||
| ) |
sets the two sub-classes of names
| startchars | are characters that can start a name | |
| allchars | are characters that can turn up anywhere in names, allchars must include all characters from startchars |
| void ELAM::CharacterClassSettings::setOperatorClass | ( | QString | ) |
sets the class of operator characters
| void ELAM::CharacterClassSettings::setParentheses | ( | QChar | open, | |
| QChar | close | |||
| ) |
sets the characters used for parentheses
| open | the character that opens/begins a parentheses structure, normally "(" | |
| close | the character that closes/ends a parentheses structure, normally ")" |
The parentheses characters must not be included in any other class.
| void ELAM::CharacterClassSettings::setWhitespaceClass | ( | QString | ) |
sets all characters that are regarded as whitespace
| QString ELAM::CharacterClassSettings::toOperator | ( | QString | ) | const |
removes assignment chars from the token and returns the pure operator or an empty string if it was a pure assignment
| QString ELAM::CharacterClassSettings::whitespaceClass | ( | ) | const |
returns all characters that are regarded as whitespace
1.7.1