<beginfold id='1'>/</beginfold id='1'>* This test file tests kates Lex/Flex highlighting */

%option c++
%option yyclass="KateTester"
%option yylineno

 <beginfold id='9'>/*</beginfold id='9'> This is a C(++) comment <endfold id='9'>*/</endfold id='9'>

/* This one is a lex comment ! */

<beginfold id='5'>%{</beginfold id='5'>
#include <iostream>
#include "realparser.hpp"
using namespace std;
<endfold id='5'>%}</endfold id='5'>

/* Some definitions */
DIGIT    [0-9]
LETTER   [_a-zA-Z]

<endfold id='1'>%%</endfold id='1'><beginfold id='2'>%%</beginfold id='2'>

 <beginfold id='9'>/*</beginfold id='9'> Comment *shall be indented here* <endfold id='9'>*/</endfold id='9'>
[ \t\n\r]+          

 <beginfold id='9'>/*</beginfold id='9'> Note: there is a bad } just here     vvv <endfold id='9'>*/</endfold id='9'>
\/\*([^\*]|\*[^/])*\*\/ <beginfold id='6'>{</beginfold id='6'> foo(a, b, c); <endfold id='6'>}</endfold id='6'> }

 <beginfold id='9'>/*</beginfold id='9'> A start condition scope... <endfold id='9'>*/</endfold id='9'>
<ESC><beginfold id='4'>{</beginfold id='4'>
  "a" <beginfold id='6'>{</beginfold id='6'>
  
  <beginfold id='9'>/*</beginfold id='9'> C mode ! <endfold id='9'>*/</endfold id='9'>
  return 0;
<endfold id='6'>}</endfold id='6'>

  "b" <beginfold id='5'>%{</beginfold id='5'>
  
  <beginfold id='9'>/*</beginfold id='9'> C mode, too ! <endfold id='9'>*/</endfold id='9'>
  return 0;
<endfold id='5'>%}</endfold id='5'>
  
  "c" return 0; // C++ comment
<endfold id='4'>}</endfold id='4'>

 <beginfold id='9'>/*</beginfold id='9'> Big rule <endfold id='9'>*/</endfold id='9'>
\"([^"\\]|\\.)*\" <beginfold id='6'>{</beginfold id='6'>

   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])
         <beginfold id='6'>{</beginfold id='6'>
         case 'n':
            yylval.string_val[j++] = '\n'; i += 2;
            break;
         default:
            yylval.string_val[j++] << yytext[i + 1], i += 2;
         <endfold id='6'>}</endfold id='6'>
    
    yylval.string_val[j] = 0;   
    return TOK_STRING;

<endfold id='6'>}</endfold id='6'>

 <beginfold id='9'>/*</beginfold id='9'> Dot (match all) <endfold id='9'>*/</endfold id='9'>
.             <beginfold id='6'>{</beginfold id='6'>return yylval.int_val = yytext[0];<endfold id='6'>}</endfold id='6'>

<endfold id='2'>%%</endfold id='2'><beginfold id='3'>%%</beginfold id='3'>

// Here is pure C(++)
#include <iostream>

int main(void)
<beginfold id='10'>{</beginfold id='10'>
  std::cout << "Hello, World\n";
  return 0;
<endfold id='10'>}</endfold id='10'>
