| 2 skipped lines |
| 3 | | 3 | | ** Lexer for POV-Ray SDL (Persistance of Vision Raytracer, Scene Description Language). |
|
| 4 | | 4 | | ** Written by Philippe Lhoste but this is mostly a derivative of LexCPP... |
|
|
| 6 | | // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org> | | 6 | | // Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org> |
| 7 | | 7 | | // The License.txt file describes the conditions under which this software may be distributed. |
|
|
| 9 | | 9 | | // Some points that distinguish from a simple C lexer: |
|
| 19 skipped lines |
| 29 | | 29 | | #include "Scintilla.h" |
|
| 30 | | 30 | | #include "SciLexer.h" |
|
|
| 32 | | static inline bool IsAWordChar(const int ch) { | | 32 | | static inline bool IsAWordChar(int ch) { |
| 33 | | 33 | | return ch < 0x80 && (isalnum(ch) || ch == '_'); |
|
|
|
| 36 | | static inline bool IsAWordStart(const int ch) { | | 36 | | static inline bool IsAWordStart(int ch) { |
| 37 | | 37 | | return ch < 0x80 && isalpha(ch); |
|
|
|
| 40 | | static inline bool IsANumberChar(const int ch) { | | 40 | | static inline bool IsANumberChar(int ch) { |
| 41 | | 41 | | // Not exactly following number definition (several dots are seen as OK, etc.) |
|
| 42 | | 42 | | // but probably enough in most cases. |
|
| 43 | | 43 | | return (ch < 0x80) && |
|
| 25 skipped lines |
|
|
| 71 | | 71 | | // Do not leak onto next line |
|
| 72 | | if (initStyle == SCE_POV_STRINGEOL) { | | 72 | | if (initStyle == SCE_POV_STRINGEOL || initStyle == SCE_POV_COMMENTLINE) { |
| 73 | | 73 | | initStyle = SCE_POV_DEFAULT; |
|
|
|
| 76 | | StyleContext sc(startPos, length, initStyle, styler); | | |
| 77 | | 76 | | short stringLen = 0; |
|
|
| | | 78 | | StyleContext sc(startPos, length, initStyle, styler); |
| | | 79 | | |
| 79 | | 80 | | for (; sc.More(); sc.Forward()) { |
|
| 80 | | 81 | | if (sc.atLineEnd) { |
|
| 81 | | 82 | | // Update the line state, so it can be seen by next line |
|
| 43 skipped lines |
|
| 126 | | 127 | | } else if (sc.state == SCE_POV_DIRECTIVE) { |
|
| 127 | | 128 | | if (!IsAWordChar(sc.ch)) { |
|
| 128 | | char s[100], *p; | | 129 | | char s[100]; |
| | | 130 | | char *p; |
| 129 | | 131 | | sc.GetCurrent(s, sizeof(s)); |
|
|
| 131 | | 133 | | // Skip # and whitespace between # and directive word |
|
| 18 skipped lines |
|
| 151 | | 153 | | } else if (sc.state == SCE_POV_COMMENTLINE) { |
|
| 152 | | 154 | | if (sc.atLineEnd) { |
|
| 153 | | sc.SetState(SCE_POV_DEFAULT); | | 155 | | sc.ForwardSetState(SCE_POV_DEFAULT); |
|
| 155 | | 157 | | } else if (sc.state == SCE_POV_STRING) { |
|
| 156 | | 158 | | if (sc.ch == '\\') { |
|
| 155 skipped lines |