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