Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string Parser::readCharacterLiteral(std::size_t& selection) {
- std::string value = "";
- value += APOSTROPHE;
- selection += 1;
- while (Code[selection] != APOSTROPHE) {
- if (Code[selection] == BACKSLASH) {
- value += BACKSLASH;
- selection += 1;
- bool integerEscapeSequence = false;
- if (isdigit(Code[selection])) {
- value += Code[selection];
- selection += 1;
- unsigned int iterations = 1;
- while (isdigit(Code[selection]) && iterations <= 3) {
- value += Code[selection];
- selection += 1;
- iterations += 1;
- }
- integerEscapeSequence = true;
- }
- // if there is no integer escape sequence try to find a character escape sequence (example: '\e')
- if (!integerEscapeSequence) {
- value += Code[selection];
- selection += 1;
- }
- } else {
- value += Code[selection];
- selection += 1;
- }
- }
- value += APOSTROPHE;
- selection += 1;
- return value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement