| 1 skipped line |
| 2 | U | 2 | U | /** @file LexBash.cxx |
|
|
|
| 5 | C | // Copyright 2004 by Neil Hodgson <neilh@scintilla.org> | | 5 | C | // Copyright 2004-2005 by Neil Hodgson <neilh@scintilla.org> |
| 6 | U | 6 | U | // Adapted from LexPerl by Kein-Hong Man <mkh@pl.jaring.my> 2004 |
|
| 7 | U | 7 | U | // The License.txt file describes the conditions under which this software may be distributed. |
|
|
| 135 skipped lines |
| 144 | U | 144 | U | char *Delimiter;// the Delimiter, 256: sizeof PL_tokenbuf |
|
|
|
| | | 147 | A | Quote = 0; |
| | | 148 | A | Quoted = false; |
| | | 149 | A | Indent = 0; |
| 147 | U | 150 | U | DelimiterLength = 0; |
|
| 148 | U | 151 | U | Delimiter = new char[HERE_DELIM_MAX]; |
|
| 149 | U | 152 | U | Delimiter[0] = '\0'; |
|
| 292 skipped lines |
| 442 | U | 445 | U | HereDoc.Quoted = false; |
|
| 443 | U | 446 | U | HereDoc.DelimiterLength = 0; |
|
| 444 | U | 447 | U | HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; |
|
| 445 | C | if (chNext == '\'') { // a quoted here-doc delimiter (' only) | | 448 | C | if (chNext == '\'' || chNext == '\"') { // a quoted here-doc delimiter (' or ") |
|
|
| 448 | U | 451 | U | chNext = chNext2; |
|
| 2 skipped lines |
| 451 | U | 454 | U | HereDoc.Indent = true; |
|
| 452 | U | 455 | U | HereDoc.State = 0; |
|
| 453 | U | 456 | U | } else if (isalpha(chNext) || chNext == '_' || chNext == '\\' |
|
| 454 | C | || chNext == '-' || chNext == '+') { | | 457 | C | || chNext == '-' || chNext == '+' || chNext == '!') { |
| 455 | U | 458 | U | // an unquoted here-doc delimiter, no special handling |
|
| | | 459 | A | // TODO check what exactly bash considers part of the delim |
| 456 | U | 460 | U | } else if (chNext == '<') { // HERE string <<< |
|
|
|
| 27 skipped lines |
| 486 | U | 490 | U | HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; |
|
|
| 488 | U | 492 | U | } else { // an unquoted here-doc delimiter |
|
| 489 | C | if (isalnum(ch) || ch == '_' || ch == '-' || ch == '+') { | | 493 | C | if (isalnum(ch) || ch == '_' || ch == '-' || ch == '+' || ch == '!') { |
| 490 | U | 494 | U | HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch; |
|
| 491 | U | 495 | U | HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; |
|
| 492 | U | 496 | U | } else if (ch == '\\') { |
|
| 89 skipped lines |
| 582 | U | 586 | U | styler.ColourTo(lengthDoc - 1, state); |
|
|
|
| | | 589 | A | static bool IsCommentLine(int line, Accessor &styler) { |
| | | 590 | A | int pos = styler.LineStart(line); |
| | | 591 | A | int eol_pos = styler.LineStart(line + 1) - 1; |
| | | 592 | A | for (int i = pos; i < eol_pos; i++) { |
| | | 593 | A | char ch = styler[i]; |
| 3 skipped lines |
| | | 597 | A | return false; |
| | | 598 | A | } |
| | | 599 | A | return false; |
| | | 600 | A | } |
| | | 601 | A | |
| 585 | U | 602 | U | static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], |
|
| 586 | U | 603 | U | Accessor &styler) { |
|
| 587 | U | 604 | U | bool foldComment = styler.GetPropertyInt("fold.comment") != 0; |
|
| 11 skipped lines |
| 599 | U | 616 | U | int style = styleNext; |
|
| 600 | U | 617 | U | styleNext = styler.StyleAt(i + 1); |
|
| 601 | U | 618 | U | bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); |
|
| | | 619 | C | // Comment folding |
| 602 | C | if (foldComment && (style == SCE_SH_COMMENTLINE)) { | | 620 | C | if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) |
| | | 621 | C | { |
| 603 | C | if ((ch == '/') && (chNext == '/')) { | | 622 | C | if (!IsCommentLine(lineCurrent - 1, styler) |
| 604 | C | char chNext2 = styler.SafeGetCharAt(i + 2); | | 623 | C | && IsCommentLine(lineCurrent + 1, styler)) |
| 605 | C | if (chNext2 == '{') { | | |
| 606 | C | levelCurrent++; | | 624 | C | levelCurrent++; |
| 607 | C | } else if (chNext2 == '}') { | | 625 | C | else if (IsCommentLine(lineCurrent - 1, styler) |
| | | 626 | C | && !IsCommentLine(lineCurrent+1, styler)) |
| 608 | C | levelCurrent--; | | 627 | C | levelCurrent--; |
| 609 | C | } | | |
| 610 | C | } | | |
| 611 | C | } | | 628 | C | } |
| 612 | U | 629 | U | if (style == SCE_C_OPERATOR) { |
|
| 613 | U | 630 | U | if (ch == '{') { |
|
|
| 32 skipped lines |