From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kate/tests/highlight.lex | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 kate/tests/highlight.lex (limited to 'kate/tests/highlight.lex') diff --git a/kate/tests/highlight.lex b/kate/tests/highlight.lex new file mode 100644 index 000000000..33527bd22 --- /dev/null +++ b/kate/tests/highlight.lex @@ -0,0 +1,82 @@ +/* This test file tests kates Lex/Flex highlighting */ + +%option c++ +%option yyclass="KateTester" +%option yylineno + + /* This is a C(++) comment */ + +/* This one is a lex comment ! */ + +%{ +#include +#include "realparser.hpp" +using namespace std; +%} + +/* Some definitions */ +DIGIT [0-9] +LETTER [_a-zA-Z] + +%% + + /* Comment *shall be indented here* */ +[ \t\n\r]+ + + /* Note: there is a bad } just here vvv */ +\/\*([^\*]|\*[^/])*\*\/ { foo(a, b, c); } } + + /* A start condition scope... */ +{ + "a" { + + /* C mode ! */ + return 0; +} + + "b" %{ + + /* C mode, too ! */ + return 0; +%} + + "c" return 0; // C++ comment +} + + /* Big rule */ +\"([^"\\]|\\.)*\" { + + yylval.string_val = new char[strlen(yytext) + 1]; + int j = 0, i = 1; + + while (yytext[i] != '"') + if (yytext[i] != '\\') + yylval.string_val[j++] = yytext[i++]; + else + switch (yytext[i + 1]) + { + case 'n': + yylval.string_val[j++] = '\n'; i += 2; + break; + default: + yylval.string_val[j++] << yytext[i + 1], i += 2; + } + + yylval.string_val[j] = 0; + return TOK_STRING; + +} + + /* Dot (match all) */ +. {return yylval.int_val = yytext[0];} + +%% + +// Here is pure C(++) +#include + +int main(void) +{ + std::cout << "Hello, World\n"; + return 0; +} -- cgit v1.2.1