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

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

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

<beginfold id='2'>/*</beginfold id='2'> This one is a lex comment ! <endfold id='2'>*/</endfold id='2'>

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

<beginfold id='2'>/*</beginfold id='2'> Some definitions <endfold id='2'>*/</endfold id='2'>
DIGIT    [0-9]
LETTER   [_a-zA-Z]

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

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

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

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

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

 <beginfold id='3'>/*</beginfold id='3'> Big rule <endfold id='3'>*/</endfold id='3'>
\"([^"\\]|\\.)*\" <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='3'>/*</beginfold id='3'> Dot (match all) <endfold id='3'>*/</endfold id='3'>
.             <beginfold id='6'>{</beginfold id='6'>return yylval.int_val = yytext[0];<endfold id='6'>}</endfold id='6'>

<endfold id='5'></endfold id='5'><beginfold id='8'>%%</beginfold id='8'>

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

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