MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / Lex

Method Lex

scintilla/lexers/LexBasic.cxx:300–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void SCI_METHOD LexerBasic::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
301 LexAccessor styler(pAccess);
302
303 bool wasfirst = true, isfirst = true; // true if first token in a line
304 styler.StartAt(startPos);
305
306 StyleContext sc(startPos, length, initStyle, styler);
307
308 // Can't use sc.More() here else we miss the last character
309 for (; ; sc.Forward()) {
310 if (sc.state == SCE_B_IDENTIFIER) {
311 if (!IsIdentifier(sc.ch)) {
312 // Labels
313 if (wasfirst && sc.Match(':')) {
314 sc.ChangeState(SCE_B_LABEL);
315 sc.ForwardSetState(SCE_B_DEFAULT);
316 } else {
317 char s[100];
318 int kstates[4] = {
319 SCE_B_KEYWORD,
320 SCE_B_KEYWORD2,
321 SCE_B_KEYWORD3,
322 SCE_B_KEYWORD4,
323 };
324 sc.GetCurrentLowered(s, sizeof(s));
325 for (int i = 0; i < 4; i++) {
326 if (keywordlists[i].InList(s)) {
327 sc.ChangeState(kstates[i]);
328 }
329 }
330 // Types, must set them as operator else they will be
331 // matched as number/constant
332 if (sc.Match('.') || sc.Match('$') || sc.Match('%') ||
333 sc.Match('#')) {
334 sc.SetState(SCE_B_OPERATOR);
335 } else {
336 sc.SetState(SCE_B_DEFAULT);
337 }
338 }
339 }
340 } else if (sc.state == SCE_B_OPERATOR) {
341 if (!IsOperator(sc.ch) || sc.Match('#'))
342 sc.SetState(SCE_B_DEFAULT);
343 } else if (sc.state == SCE_B_LABEL) {
344 if (!IsIdentifier(sc.ch))
345 sc.SetState(SCE_B_DEFAULT);
346 } else if (sc.state == SCE_B_CONSTANT) {
347 if (!IsIdentifier(sc.ch))
348 sc.SetState(SCE_B_DEFAULT);
349 } else if (sc.state == SCE_B_NUMBER) {
350 if (!IsDigit(sc.ch))
351 sc.SetState(SCE_B_DEFAULT);
352 } else if (sc.state == SCE_B_HEXNUMBER) {
353 if (!IsHexDigit(sc.ch))
354 sc.SetState(SCE_B_DEFAULT);
355 } else if (sc.state == SCE_B_BINNUMBER) {
356 if (!IsBinDigit(sc.ch))
357 sc.SetState(SCE_B_DEFAULT);

Callers

nothing calls this directly

Calls 15

IsDigitFunction · 0.85
IsHexDigitFunction · 0.85
IsBinDigitFunction · 0.85
StartAtMethod · 0.80
ForwardMethod · 0.80
ChangeStateMethod · 0.80
ForwardSetStateMethod · 0.80
GetCurrentLoweredMethod · 0.80
InListMethod · 0.80
SetStateMethod · 0.80
MoreMethod · 0.80
CompleteMethod · 0.80

Tested by

no test coverage detected