Esempio n. 1
0
static void ColouriseTADS3Number(StyleContext &sc) {
        int endState = sc.state;
        bool inHexNumber = false;
        bool seenE = false;
        bool seenDot = sc.ch == '.';
        sc.SetState(SCE_T3_NUMBER);
        if (sc.More()) {
                sc.Forward();
        }
        if (sc.chPrev == '0' && tolower(sc.ch) == 'x') {
                inHexNumber = true;
                sc.Forward();
        }
        while (sc.More()) {
                if (inHexNumber) {
                        if (!IsAHexDigit(sc.ch)) {
                                break;
                        }
                } else if (!isdigit(sc.ch)) {
                        if (!seenE && tolower(sc.ch) == 'e') {
                                seenE = true;
                                seenDot = true;
                                if (sc.chNext == '+' || sc.chNext == '-') {
                                        sc.Forward();
                                }
                        } else if (!seenDot && sc.ch == '.') {
                                seenDot = true;
                        } else {
                                break;
                        }
                }
                sc.Forward();
        }
        sc.SetState(endState);
}
Esempio n. 2
0
static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostropheStartsAttribute) {
	apostropheStartsAttribute = false;

	sc.SetState(SCE_ADA_LABEL);

	// Skip "<<"
	sc.Forward();
	sc.Forward();

	std::string identifier;

	while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
		identifier += static_cast<char>(tolower(sc.ch));
		sc.Forward();
	}

	// Skip ">>"
	if (sc.Match('>', '>')) {
		sc.Forward();
		sc.Forward();
	} else {
		sc.ChangeState(SCE_ADA_ILLEGAL);
	}

	// If the name is an invalid identifier or a keyword, then make it invalid label
	if (!IsValidIdentifier(identifier) || keywords.InList(identifier.c_str())) {
		sc.ChangeState(SCE_ADA_ILLEGAL);
	}

	sc.SetState(SCE_ADA_DEFAULT);

}
Esempio n. 3
0
static void ColouriseTADS3Keyword(StyleContext &sc,
                                                        WordList *keywordlists[],       unsigned int endPos) {
        char s[250];
        WordList &keywords = *keywordlists[0];
        WordList &userwords1 = *keywordlists[1];
        WordList &userwords2 = *keywordlists[2];
        WordList &userwords3 = *keywordlists[3];
        int initState = sc.state;
        sc.SetState(SCE_T3_IDENTIFIER);
        while (sc.More() && (IsAWordChar(sc.ch))) {
                sc.Forward();
        }
        sc.GetCurrent(s, sizeof(s));
        if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) {
                // have to find if "in" is next
                int n = 1;
                while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n)))
                        n++;
                if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') {
                        sc.Forward(n+2);
                        sc.ChangeState(SCE_T3_KEYWORD);
                }
        } else if (keywords.InList(s)) {
                sc.ChangeState(SCE_T3_KEYWORD);
        } else if (userwords3.InList(s)) {
                sc.ChangeState(SCE_T3_USER3);
        } else if (userwords2.InList(s)) {
                sc.ChangeState(SCE_T3_USER2);
        } else if (userwords1.InList(s)) {
                sc.ChangeState(SCE_T3_USER1);
        }
        sc.SetState(initState);
}
Esempio n. 4
0
static void ColouriseNumber(StyleContext& sc, bool& apostropheStartsAttribute) {
	apostropheStartsAttribute = true;

	std::string number;
	sc.SetState(SCE_ADA_NUMBER);

	// Get all characters up to a delimiter or a separator, including points, but excluding
	// double points (ranges).
	while (!IsSeparatorOrDelimiterCharacter(sc.ch) || (sc.ch == '.' && sc.chNext != '.')) {
		number += static_cast<char>(sc.ch);
		sc.Forward();
	}

	// Special case: exponent with sign
	if ((sc.chPrev == 'e' || sc.chPrev == 'E') &&
	        (sc.ch == '+' || sc.ch == '-')) {
		number += static_cast<char>(sc.ch);
		sc.Forward ();

		while (!IsSeparatorOrDelimiterCharacter(sc.ch)) {
			number += static_cast<char>(sc.ch);
			sc.Forward();
		}
	}

	if (!IsValidNumber(number)) {
		sc.ChangeState(SCE_ADA_ILLEGAL);
	}

	sc.SetState(SCE_ADA_DEFAULT);
}
Esempio n. 5
0
static void ColouriseTADSHTMLString(StyleContext &sc, int &lineState) {
        int endState = sc.state;
        int chQuote = sc.ch;
        int chString = (lineState & T3_SINGLE_QUOTE) ? '\'' : '"';
        if (endState == SCE_T3_HTML_STRING) {
                if (lineState&T3_SINGLE_QUOTE) {
                        endState = SCE_T3_S_STRING;
                        chString = '\'';
                } else if (lineState&T3_INT_EXPRESSION) {
                        endState = SCE_T3_X_STRING;
                        chString = '"';
                } else {
                        endState = SCE_T3_HTML_DEFAULT;
                        chString = '"';
                }
                chQuote = (lineState & T3_HTML_SQUOTE) ? '\'' : '"';
        } else {
                sc.SetState(SCE_T3_HTML_STRING);
                sc.Forward();
        }
        if (chQuote == '"')
                lineState &= ~T3_HTML_SQUOTE;
        else
                lineState |= T3_HTML_SQUOTE;

        while (sc.More()) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                if (sc.ch == chQuote) {
                        sc.ForwardSetState(endState);
                        return;
                }
                if (sc.Match('\\', static_cast<char>(chQuote))) {
                        sc.Forward(2);
                        sc.SetState(endState);
                        return;
                }
                if (sc.ch == chString) {
                        sc.SetState(SCE_T3_DEFAULT);
                        return;
                }

                if (sc.Match('<', '<')) {
                        lineState |= T3_INT_EXPRESSION | T3_INT_EXPRESSION_IN_TAG;
                        sc.SetState(SCE_T3_X_DEFAULT);
                        sc.Forward(2);
                        return;
                }

                if (sc.Match('\\', static_cast<char>(chQuote))
                        || sc.Match('\\', static_cast<char>(chString))
                        || sc.Match('\\', '\\')) {
                        sc.Forward(2);
                } else {
                        sc.Forward();
                }
        }
}
Esempio n. 6
0
static void ColouriseTADS3HTMLTagStart(StyleContext &sc) {
        sc.SetState(SCE_T3_HTML_TAG);
        sc.Forward();
        if (sc.ch == '/') {
                sc.Forward();
        }
        while (IsAnHTMLChar(sc.ch)) {
                sc.Forward();
        }
}
Esempio n. 7
0
static void ColouriseTADS3Comment(StyleContext &sc, int endState) {
        sc.SetState(SCE_T3_BLOCK_COMMENT);
        while (sc.More()) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                if (sc.Match('*', '/')) {
                        sc.Forward(2);
                        sc.SetState(endState);
                        return;
                }
                sc.Forward();
        }
}
Esempio n. 8
0
static void ColouriseToEndOfLine(StyleContext &sc, int initState, int endState) {
        sc.SetState(initState);
        while (sc.More()) {
                if (sc.ch == '\\') {
                        sc.Forward();
                        if (IsEOLSkip(sc)) {
                                        return;
                        }
                }
                if (IsEOL(sc.ch, sc.chNext)) {
                        sc.SetState(endState);
                        return;
                }
                sc.Forward();
        }
}
Esempio n. 9
0
static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute) {
    apostropheStartsAttribute = true;
    sc.SetState(SCE_SPICE_IDENTIFIER);
    std::string word;
    while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
        word += static_cast<char>(tolower(sc.ch));
        sc.Forward();
    }
    if (keywords.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    else if (keywords2.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD2);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    else if (keywords3.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD3);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    sc.SetState(SCE_SPICE_DEFAULT);
}
Esempio n. 10
0
// Separator line
static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
    int c, count = 1;
    unsigned int i = 0;
    while (++i) {
        c = sc.GetRelative(i);
        if (c == sc.ch)
            ++count;
        // hit a terminating character
        else if (!IsASpaceOrTab(c) || sc.currentPos + i == endPos) {
            // Are we a valid HRULE
            if ((IsNewline(c) || sc.currentPos + i == endPos) &&
                    count >= 20 && !HasPrevLineContent(sc)) {
                sc.SetState(SCE_TXT2TAGS_HRULE);
                sc.Forward(i);
                sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
                return true;
            }
            else {
                sc.SetState(SCE_TXT2TAGS_DEFAULT);
		return false;
            }
        }
    }
    return false;
}
Esempio n. 11
0
static void ColouriseString(StyleContext& sc, bool& apostropheStartsAttribute) {
	apostropheStartsAttribute = true;

	sc.SetState(SCE_ADA_STRING);
	sc.Forward();

	ColouriseContext(sc, '"', SCE_ADA_STRINGEOL);
}
Esempio n. 12
0
static void ColouriseComment(StyleContext& sc, bool& /*apostropheStartsAttribute*/) {
	// Apostrophe meaning is not changed, but the parameter is present for uniformity

	sc.SetState(SCE_ADA_COMMENTLINE);

	while (!sc.atLineEnd) {
		sc.Forward();
	}
}
Esempio n. 13
0
// Set the state on text section from current to length characters,
// then set the rest until the newline to default, except for any characters matching token
static void SetStateAndZoom(const int state, const int length, const int token, StyleContext &sc) {
    sc.SetState(state);
    sc.Forward(length);
    sc.SetState(SCE_MARKDOWN_DEFAULT);
    sc.Forward();
    bool started = false;
    while (sc.More() && !IsNewline(sc.ch)) {
        if (sc.ch == token && !started) {
            sc.SetState(state);
            started = true;
        }
        else if (sc.ch != token) {
            sc.SetState(SCE_MARKDOWN_DEFAULT);
            started = false;
        }
        sc.Forward();
    }
    sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
}
Esempio n. 14
0
static void ColouriseContext(StyleContext& sc, char chEnd, int stateEOL) {
	while (!sc.atLineEnd && !sc.Match(chEnd)) {
		sc.Forward();
	}

	if (!sc.atLineEnd) {
		sc.ForwardSetState(SCE_ADA_DEFAULT);
	} else {
		sc.ChangeState(stateEOL);
	}
}
Esempio n. 15
0
static void ColouriseCharacter(StyleContext& sc, bool& apostropheStartsAttribute) {
	apostropheStartsAttribute = true;

	sc.SetState(SCE_ADA_CHARACTER);

	// Skip the apostrophe and one more character (so that '' is shown as non-terminated and '''
	// is handled correctly)
	sc.Forward();
	sc.Forward();

	ColouriseContext(sc, '\'', SCE_ADA_CHARACTEREOL);
}
Esempio n. 16
0
static void ColouriseTADS3MsgParam(StyleContext &sc, int &lineState) {
        int endState = sc.state;
        int chQuote = '"';
        switch (endState) {
                case SCE_T3_S_STRING:
                        sc.SetState(SCE_T3_MSG_PARAM);
                        sc.Forward();
                        chQuote = '\'';
                        break;
                case SCE_T3_D_STRING:
                case SCE_T3_X_STRING:
                        sc.SetState(SCE_T3_MSG_PARAM);
                        sc.Forward();
                        break;
                case SCE_T3_MSG_PARAM:
                        if (lineState&T3_SINGLE_QUOTE) {
                                endState = SCE_T3_S_STRING;
                                chQuote = '\'';
                        } else if (lineState&T3_INT_EXPRESSION) {
                                endState = SCE_T3_X_STRING;
                        } else {
                                endState = SCE_T3_D_STRING;
                        }
                        break;
        }
        while (sc.More() && sc.ch != '}' && sc.ch != chQuote) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                if (sc.ch == '\\') {
                        sc.Forward();
                }
                sc.Forward();
        }
        if (sc.ch == chQuote) {
                sc.SetState(endState);
        } else {
                sc.ForwardSetState(endState);
        }
}
Esempio n. 17
0
static void ColouriseTADS3LibDirective(StyleContext &sc, int &lineState) {
        int initState = sc.state;
        int chQuote = '"';
        switch (initState) {
                case SCE_T3_S_STRING:
                        sc.SetState(SCE_T3_LIB_DIRECTIVE);
                        sc.Forward(2);
                        chQuote = '\'';
                        break;
                case SCE_T3_D_STRING:
                        sc.SetState(SCE_T3_LIB_DIRECTIVE);
                        sc.Forward(2);
                        break;
                case SCE_T3_LIB_DIRECTIVE:
                        if (lineState&T3_SINGLE_QUOTE) {
                                initState = SCE_T3_S_STRING;
                                chQuote = '\'';
                        } else {
                                initState = SCE_T3_D_STRING;
                        }
                        break;
        }
        while (sc.More() && IsADirectiveChar(sc.ch)) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                sc.Forward();
        };
        if (sc.ch == '>' || !sc.More()) {
                sc.ForwardSetState(initState);
        } else if (sc.ch == chQuote) {
                sc.SetState(initState);
        } else {
                sc.ChangeState(initState);
                sc.Forward();
        }
}
Esempio n. 18
0
// True if can follow ch down to the end with possibly trailing whitespace
static bool FollowToLineEnd(const int ch, const int state, const unsigned int endPos, StyleContext &sc) {
    unsigned int i = 0;
    while (sc.GetRelative(++i) == ch)
        ;
    // Skip over whitespace
    while (IsASpaceOrTab(sc.GetRelative(i)) && sc.currentPos + i < endPos)
        ++i;
    if (IsNewline(sc.GetRelative(i)) || sc.currentPos + i == endPos) {
        sc.Forward(i);
        sc.ChangeState(state);
        sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
        return true;
    }
    else return false;
}
Esempio n. 19
0
/*
 *   Test the current character to see if it's the START of an EOL sequence;
 *   if so, skip ahead to the last character of the sequence and return true,
 *   and if not just return false.  There are a few places where we want to
 *   check to see if a newline sequence occurs at a particular point, but
 *   where a caller expects a subroutine to stop only upon reaching the END
 *   of a newline sequence (in particular, CR-LF on Windows).  That's why
 *   IsEOL() above only returns true on CR if the CR isn't followed by an LF
 *   - it doesn't want to admit that there's a newline until reaching the END
 *   of the sequence.  We meet both needs by saying that there's a newline
 *   when we see the CR in a CR-LF, but skipping the CR before returning so
 *   that the caller's caller will see that we've stopped at the LF.
 */
static inline bool IsEOLSkip(StyleContext &sc)
{
    /* test for CR-LF */
    if (sc.ch == '\r' && sc.chNext == '\n')
    {
        /* got CR-LF - skip the CR and indicate that we're at a newline */
        sc.Forward();
        return true;
    }

    /*
     *   in other cases, we have at most a 1-character newline, so do the
     *   normal IsEOL test
     */
    return IsEOL(sc.ch, sc.chNext);
}
Esempio n. 20
0
static void ColouriseComment(StyleContext& sc, bool&) {
    sc.SetState(SCE_SPICE_COMMENTLINE);
    while (!sc.atLineEnd) {
        sc.Forward();
    }
}
Esempio n. 21
0
static void ColouriseTADS3HTMLTag(StyleContext &sc, int &lineState) {
        int endState = sc.state;
        int chQuote = '"';
        int chString = '\'';
        switch (endState) {
                case SCE_T3_S_STRING:
                        ColouriseTADS3HTMLTagStart(sc);
                        sc.SetState(SCE_T3_HTML_DEFAULT);
                        chQuote = '\'';
                        chString = '"';
                        break;
                case SCE_T3_D_STRING:
                case SCE_T3_X_STRING:
                        ColouriseTADS3HTMLTagStart(sc);
                        sc.SetState(SCE_T3_HTML_DEFAULT);
                        break;
                case SCE_T3_HTML_DEFAULT:
                        if (lineState&T3_SINGLE_QUOTE) {
                                endState = SCE_T3_S_STRING;
                                chQuote = '\'';
                                chString = '"';
                        } else if (lineState&T3_INT_EXPRESSION) {
                                endState = SCE_T3_X_STRING;
                        } else {
                                endState = SCE_T3_D_STRING;
                        }
                        break;
        }

        while (sc.More()) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                if (sc.Match('/', '>')) {
                        sc.SetState(SCE_T3_HTML_TAG);
                        sc.Forward(2);
                        sc.SetState(endState);
                        return;
                }
                if (sc.ch == '>') {
                        sc.SetState(SCE_T3_HTML_TAG);
                        sc.ForwardSetState(endState);
                        return;
                }
                if (sc.ch == chQuote) {
                        sc.SetState(endState);
                        return;
                }
                if (sc.Match('\\', static_cast<char>(chQuote))) {
                        sc.Forward();
                        ColouriseTADSHTMLString(sc, lineState);
                        if (sc.state == SCE_T3_X_DEFAULT)
                            break;
                } else if (sc.ch == chString) {
                        ColouriseTADSHTMLString(sc, lineState);
                } else if (sc.ch == '=') {
                        ColouriseTADS3Operator(sc);
                } else {
                        sc.Forward();
                }
        }
}
Esempio n. 22
0
static void ColouriseTADS3String(StyleContext &sc, int &lineState) {
        int chQuote = sc.ch;
        int endState = sc.state;
        switch (sc.state) {
                case SCE_T3_DEFAULT:
                case SCE_T3_X_DEFAULT:
                        if (chQuote == '"') {
                                if (sc.state == SCE_T3_DEFAULT) {
                                        sc.SetState(SCE_T3_D_STRING);
                                } else {
                                        sc.SetState(SCE_T3_X_STRING);
                                }
                                lineState &= ~T3_SINGLE_QUOTE;
                        } else {
                                sc.SetState(SCE_T3_S_STRING);
                                lineState |= T3_SINGLE_QUOTE;
                        }
                        sc.Forward();
                        break;
                case SCE_T3_S_STRING:
                        chQuote = '\'';
                        endState = lineState&T3_INT_EXPRESSION ?
                                SCE_T3_X_DEFAULT : SCE_T3_DEFAULT;
                        break;
                case SCE_T3_D_STRING:
                        chQuote = '"';
                        endState = SCE_T3_DEFAULT;
                        break;
                case SCE_T3_X_STRING:
                        chQuote = '"';
                        endState = SCE_T3_X_DEFAULT;
                        break;
        }
        while (sc.More()) {
                if (IsEOL(sc.ch, sc.chNext)) {
                        return;
                }
                if (sc.ch == chQuote) {
                        sc.ForwardSetState(endState);
                        return;
                }
                if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) {
                        lineState |= T3_INT_EXPRESSION;
                        sc.SetState(SCE_T3_X_DEFAULT);
                        sc.Forward(2);
                        return;
                }
                if (sc.Match('\\', static_cast<char>(chQuote))
                    || sc.Match('\\', '\\')) {
                        sc.Forward(2);
                } else if (sc.ch == '{') {
                        ColouriseTADS3MsgParam(sc, lineState);
                } else if (sc.Match('<', '.')) {
                        ColouriseTADS3LibDirective(sc, lineState);
                } else if (sc.ch == '<') {
                        ColouriseTADS3HTMLTag(sc, lineState);
                        if (sc.state == SCE_T3_X_DEFAULT)
                                return;
                } else {
                        sc.Forward();
                }
        }
}