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