diff options
Diffstat (limited to 'tests/lexers/ragel-cpp/example.txt')
| -rw-r--r-- | tests/lexers/ragel-cpp/example.txt | 2277 |
1 files changed, 2277 insertions, 0 deletions
diff --git a/tests/lexers/ragel-cpp/example.txt b/tests/lexers/ragel-cpp/example.txt new file mode 100644 index 00000000..eee4db6e --- /dev/null +++ b/tests/lexers/ragel-cpp/example.txt @@ -0,0 +1,2277 @@ +---input--- +/* + * Lexes Ragel input files. + * + * @LANG: c++ + * + * Test works with split code gen. + */ + +#include <iostream> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +using namespace std; + +void escapeXML( const char *data ) +{ + while ( *data != 0 ) { + switch ( *data ) { + case '<': cout << "<"; break; + case '>': cout << ">"; break; + case '&': cout << "&"; break; + default: cout << *data; break; + } + data += 1; + } +} + +void escapeXML( char c ) +{ + switch ( c ) { + case '<': cout << "<"; break; + case '>': cout << ">"; break; + case '&': cout << "&"; break; + default: cout << c; break; + } +} + +void escapeXML( const char *data, int len ) +{ + for ( const char *end = data + len; data != end; data++ ) { + switch ( *data ) { + case '<': cout << "<"; break; + case '>': cout << ">"; break; + case '&': cout << "&"; break; + default: cout << *data; break; + } + } +} + +inline void write( const char *data ) +{ + cout << data; +} + +inline void write( char c ) +{ + cout << c; +} + +inline void write( const char *data, int len ) +{ + cout.write( data, len ); +} + + +%%{ + machine RagelScan; + + word = [a-zA-Z_][a-zA-Z_0-9]*; + integer = [0-9]+; + hex = '0x' [0-9a-fA-F] [0-9a-fA-F]*; + + default = ^0; + EOF = 0; + + # Handles comments in outside code and inline blocks. + c_comment := + ( default* :>> '*/' ) + ${ escapeXML( fc ); } + @{ fret; }; + + action emit { + escapeXML( ts, te-ts ); + } + + # + # Inline action code + # + + ilscan := |* + + "'" ( [^'\\] | /\\./ )* "'" => emit; + '"' ( [^"\\] | /\\./ )* '"' => emit; + '/*' { + write( "/*" ); + fcall c_comment; + }; + '//' [^\n]* '\n' => emit; + + '{' { + write( '{' ); + inline_depth += 1; + }; + + '}' { + write( '}' ); + /* If dropping down to the last } then return + * to ragel code. */ + if ( --inline_depth == 0 ) { + write( "</inline>\n" ); + fgoto rlscan; + } + }; + + default => { escapeXML( *ts ); }; + *|; + + # + # Ragel Tokens + # + + rlscan := |* + '}%%' { + if ( !single_line ) { + write( "</section>\n" ); + fgoto main; + } + }; + + '\n' { + if ( single_line ) { + write( "</section>\n" ); + fgoto main; + } + }; + + # Word + word { + write( "<word>" ); + write( ts, te-ts ); + write( "</word>\n" ); + }; + + # Decimal integer. + integer { + write( "<int>" ); + write( ts, te-ts ); + write( "</int>\n" ); + }; + + # Hexidecimal integer. + hex { + write( "<hex>" ); + write( ts, te-ts ); + write( "</hex>\n" ); + }; + + # Consume comments. + '#' [^\n]* '\n'; + + # Single literal string. + "'" ( [^'\\] | /\\./ )* "'" { + write( "<single_lit>" ); + escapeXML( ts, te-ts ); + write( "</single_lit>\n" ); + }; + + # Double literal string. + '"' ( [^"\\] | /\\./ )* '"' { + write( "<double_lit>" ); + escapeXML( ts, te-ts ); + write( "</double_lit>\n" ); + }; + + # Or literal. + '[' ( [^\]\\] | /\\./ )* ']' { + write( "<or_lit>" ); + escapeXML( ts, te-ts ); + write( "</or_lit>\n" ); + }; + + # Regex Literal. + '/' ( [^/\\] | /\\./ ) * '/' { + write( "<re_lit>" ); + escapeXML( ts, te-ts ); + write( "</re_lit>\n" ); + }; + + # Open an inline block + '{' { + inline_depth = 1; + write( "<inline>{" ); + fgoto ilscan; + }; + + punct { + write( "<symbol>" ); + escapeXML( fc ); + write( "</symbol>\n" ); + }; + + default; + *|; + + # + # Outside code. + # + + main := |* + + "'" ( [^'\\] | /\\./ )* "'" => emit; + '"' ( [^"\\] | /\\./ )* '"' => emit; + + '/*' { + escapeXML( ts, te-ts ); + fcall c_comment; + }; + + '//' [^\n]* '\n' => emit; + + '%%{' { + write( "<section>\n" ); + single_line = false; + fgoto rlscan; + }; + + '%%' { + write( "<section>\n" ); + single_line = true; + fgoto rlscan; + }; + + default { + escapeXML( *ts ); + }; + + # EOF. + EOF; + *|; +}%% + +%% write data nofinal; + +void test( const char *data ) +{ + std::ios::sync_with_stdio(false); + + int cs, act; + const char *ts, *te; + int stack[1], top; + + bool single_line = false; + int inline_depth = 0; + + %% write init; + + /* Read in a block. */ + const char *p = data; + const char *pe = data + strlen( data ); + const char *eof = pe; + %% write exec; + + if ( cs == RagelScan_error ) { + /* Machine failed before finding a token. */ + cerr << "PARSE ERROR" << endl; + exit(1); + } +} + +#define BUFSIZE 2048 + +int main() +{ + std::ios::sync_with_stdio(false); + + test("hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"); + + return 0; +} + +---tokens--- +'/*\n * Lexes Ragel input files.\n *\n * @LANG: c++\n *\n * Test works with split code gen.\n */' Comment.Multiline +'\n' Text + +'\n' Text + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<iostream>' Comment.PreprocFile +'\n' Comment.Preproc + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<stdlib.h>' Comment.PreprocFile +'\n' Comment.Preproc + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<stdio.h>' Comment.PreprocFile +'\n' Comment.Preproc + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<string.h>' Comment.PreprocFile +'\n' Comment.Preproc + +'\n' Text + +'using' Keyword +' ' Text +'namespace' Keyword +' ' Text +'std' Name +';' Punctuation +'\n' Text + +'\n' Text + +'void' Keyword.Type +' ' Text +'escapeXML' Name.Function +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'data' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'while' Keyword +' ' Text +'(' Punctuation +' ' Text +'*' Operator +'data' Name +' ' Text +'!' Operator +'=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t' Text +'switch' Keyword +' ' Text +'(' Punctuation +' ' Text +'*' Operator +'data' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'<' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'<' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'>' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'>' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'&' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'&' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'default' Keyword +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'*' Operator +'data' Name +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +'\n' Text + +'\t\t' Text +'data' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'\t' Text +'}' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'void' Keyword.Type +' ' Text +'escapeXML' Name.Function +'(' Punctuation +' ' Text +'char' Keyword.Type +' ' Text +'c' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'switch' Keyword +' ' Text +'(' Punctuation +' ' Text +'c' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'<' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'<' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'>' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'>' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'&' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'&' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t' Text +'default' Keyword +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'c' Name +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t' Text +'}' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'void' Keyword.Type +' ' Text +'escapeXML' Name.Function +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'data' Name +',' Punctuation +' ' Text +'int' Keyword.Type +' ' Text +'len' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'for' Keyword +' ' Text +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'end' Name +' ' Text +'=' Operator +' ' Text +'data' Name +' ' Text +'+' Operator +' ' Text +'len' Name +';' Punctuation +' ' Text +'data' Name +' ' Text +'!' Operator +'=' Operator +' ' Text +'end' Name +';' Punctuation +' ' Text +'data' Name +'+' Operator +'+' Operator +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t' Text +'switch' Keyword +' ' Text +'(' Punctuation +' ' Text +'*' Operator +'data' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'<' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'<' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'>' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'>' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'case' Keyword +' ' Text +"'" Literal.String.Char +'&' Literal.String.Char +"'" Literal.String.Char +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'&' Literal.String +'"' Literal.String +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t\t' Text +'default' Keyword +':' Operator +' ' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'*' Operator +'data' Name +';' Punctuation +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +'\n' Text + +'\t' Text +'}' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'inline' Keyword.Reserved +' ' Text +'void' Keyword.Type +' ' Text +'write' Name +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'data' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'data' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'inline' Keyword.Reserved +' ' Text +'void' Keyword.Type +' ' Text +'write' Name +'(' Punctuation +' ' Text +'char' Keyword.Type +' ' Text +'c' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'cout' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'c' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'inline' Keyword.Reserved +' ' Text +'void' Keyword.Type +' ' Text +'write' Name +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'data' Name +',' Punctuation +' ' Text +'int' Keyword.Type +' ' Text +'len' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'cout' Name +'.' Punctuation +'write' Name +'(' Punctuation +' ' Text +'data' Name +',' Punctuation +' ' Text +'len' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'\n' Text + +'%%{' Punctuation +'\n\t' Text.Whitespace +'machine' Keyword +' ' Text.Whitespace +'RagelScan' Name.Variable +';' Punctuation +'\n\n\t' Text.Whitespace +'word' Name.Variable +' ' Text.Whitespace +'=' Operator +' ' Text.Whitespace +'[a-zA-Z_]' Literal.String +'[a-zA-Z_0-9]' Literal.String +'*' Operator +';' Punctuation +'\n\t' Text.Whitespace +'integer' Name.Variable +' ' Text.Whitespace +'=' Operator +' ' Text.Whitespace +'[0-9]' Literal.String +'+' Operator +';' Punctuation +'\n\t' Text.Whitespace +'hex' Name.Variable +' ' Text.Whitespace +'=' Operator +' ' Text.Whitespace +"'0x'" Literal.String.Single +' ' Text.Whitespace +'[0-9a-fA-F]' Literal.String +' ' Text.Whitespace +'[0-9a-fA-F]' Literal.String +'*' Operator +';' Punctuation +'\n\n\t' Text.Whitespace +'default' Name.Variable +' ' Text.Whitespace +'=' Operator +' ' Text.Whitespace +'^' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n\t' Text.Whitespace +'EOF' Name.Variable +' ' Text.Whitespace +'=' Operator +' ' Text.Whitespace +'0' Literal.Number.Integer +';' Punctuation +'\n\n\t' Text.Whitespace +'# Handles comments in outside code and inline blocks.' Comment +'\n\t' Text.Whitespace +'c_comment' Name.Variable +' ' Text.Whitespace +':' Operator +'=' Operator +' \n\t\t' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'default' Name.Variable +'*' Operator +' ' Text.Whitespace +':>>' Operator +' ' Text.Whitespace +"'*/'" Literal.String.Single +' ' Text.Whitespace +')' Operator +'\n\t\t' Text.Whitespace +'$' Operator +'{' Punctuation +' ' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'fc' Name +' ' Text +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n\t\t' Text.Whitespace +'@' Operator +'{' Punctuation +' ' Text +'fret' Name +';' Punctuation +' ' Text +'}' Punctuation +';' Punctuation +'\n\n\t' Text.Whitespace +'action' Keyword +' ' Text.Whitespace +'emit' Name.Variable +' ' Text.Whitespace +'{' Punctuation +'\n\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t' Text +'}' Punctuation +'\n\n\t' Text.Whitespace +'#' Comment +'\n\t' Text.Whitespace +'# Inline action code' Comment +'\n\t' Text.Whitespace +'#' Comment +'\n\n\t' Text.Whitespace +'ilscan' Name.Variable +' ' Text.Whitespace +':' Operator +'=' Operator +' ' Text.Whitespace +'|' Operator +'*' Operator +'\n\n\t\t' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +"[^'\\\\]" Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\t\t' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'[^"\\\\]' Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\t\t' Text.Whitespace +"'/*'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'/*' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'fcall' Name +' ' Text +'c_comment' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\t\t' Text.Whitespace +"'//'" Literal.String.Single +' ' Text.Whitespace +'[^\\n]' Literal.String +'*' Operator +' ' Text.Whitespace +"'\\n'" Literal.String.Single +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'{'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +"'" Literal.String.Char +'{' Literal.String.Char +"'" Literal.String.Char +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'inline_depth' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +' \n\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'}'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +"'" Literal.String.Char +'}' Literal.String.Char +"'" Literal.String.Char +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'/* If dropping down to the last } then return \n\t\t\t * to ragel code. */' Comment.Multiline +'\n' Text + +'\t\t\t' Text +'if' Keyword +' ' Text +'(' Punctuation +' ' Text +'-' Operator +'-' Operator +'inline_depth' Name +' ' Text +'=' Operator +'=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n\t\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</inline>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t\t' Text +'fgoto' Name +' ' Text +'rlscan' Name +';' Punctuation +'\n' Text + +'\t\t\t' Text +'}' Punctuation +'\n\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'default' Name.Variable +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'{' Punctuation +' ' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'*' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +';' Punctuation +'\n\t' Text.Whitespace +'*' Operator +'|' Operator +';' Punctuation +'\n\n\t' Text.Whitespace +'#' Comment +'\n\t' Text.Whitespace +'# Ragel Tokens' Comment +'\n\t' Text.Whitespace +'#' Comment +'\n\n\t' Text.Whitespace +'rlscan' Name.Variable +' ' Text.Whitespace +':' Operator +'=' Operator +' ' Text.Whitespace +'|' Operator +'*' Operator +'\n\t\t' Text.Whitespace +"'}%%'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'if' Keyword +' ' Text +'(' Punctuation +' ' Text +'!' Operator +'single_line' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n\t\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</section>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t\t' Text +'fgoto' Name +' ' Text +'main' Name +';' Punctuation +'\n' Text + +'\t\t\t' Text +'}' Punctuation +'\n\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'\\n'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'if' Keyword +' ' Text +'(' Punctuation +' ' Text +'single_line' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n\t\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</section>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t\t' Text +'fgoto' Name +' ' Text +'main' Name +';' Punctuation +'\n' Text + +'\t\t\t' Text +'}' Punctuation +'\n\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Word' Comment +'\n\t\t' Text.Whitespace +'word' Name.Variable +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<word>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</word>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Decimal integer.' Comment +'\n\t\t' Text.Whitespace +'integer' Name.Variable +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<int>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</int>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Hexidecimal integer.' Comment +'\n\t\t' Text.Whitespace +'hex' Name.Variable +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<hex>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</hex>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Consume comments.' Comment +'\n\t\t' Text.Whitespace +"'#'" Literal.String.Single +' ' Text.Whitespace +'[^\\n]' Literal.String +'*' Operator +' ' Text.Whitespace +"'\\n'" Literal.String.Single +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Single literal string.' Comment +'\n\t\t' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +"[^'\\\\]" Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<single_lit>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</single_lit>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Double literal string.' Comment +'\n\t\t' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'[^"\\\\]' Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<double_lit>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</double_lit>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Or literal.' Comment +'\n\t\t' Text.Whitespace +"'['" Literal.String.Single +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'[^\\]\\\\]' Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +"']'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<or_lit>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</or_lit>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Regex Literal.' Comment +'\n\t\t' Text.Whitespace +"'/'" Literal.String.Single +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'[^/\\\\]' Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +' ' Text.Whitespace +'*' Operator +' ' Text.Whitespace +"'/'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<re_lit>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</re_lit>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# Open an inline block' Comment +'\n\t\t' Text.Whitespace +"'{'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'inline_depth' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<inline>{' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'fgoto' Name +' ' Text +'ilscan' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'punct' Keyword +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<symbol>' Literal.String +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'fc' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'</symbol>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\t\t\n\t\t' Text.Whitespace +'default' Name.Variable +';' Punctuation +'\n\t' Text.Whitespace +'*' Operator +'|' Operator +';' Punctuation +'\n\n\t' Text.Whitespace +'#' Comment +'\n\t' Text.Whitespace +'# Outside code.' Comment +'\n\t' Text.Whitespace +'#' Comment +'\n\n\t' Text.Whitespace +'main' Name.Variable +' ' Text.Whitespace +':' Operator +'=' Operator +' ' Text.Whitespace +'|' Operator +'*' Operator +'\n\n\t\t' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +"[^'\\\\]" Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'"\'"' Literal.String.Double +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\t\t' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'(' Operator +' ' Text.Whitespace +'[^"\\\\]' Literal.String +' ' Text.Whitespace +'|' Operator +' ' Text.Whitespace +'/\\\\./' Literal.String.Regex +' ' Text.Whitespace +')' Operator +'*' Operator +' ' Text.Whitespace +'\'"\'' Literal.String.Single +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'/*'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'ts' Name +',' Punctuation +' ' Text +'te' Name +'-' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'fcall' Name +' ' Text +'c_comment' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'//'" Literal.String.Single +' ' Text.Whitespace +'[^\\n]' Literal.String +'*' Operator +' ' Text.Whitespace +"'\\n'" Literal.String.Single +' ' Text.Whitespace +'=' Operator +'>' Operator +' ' Text.Whitespace +'emit' Name.Variable +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'%%{'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +' \n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<section>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t\t' Text +'single_line' Name +' ' Text +'=' Operator +' ' Text +'false' Name.Builtin +';' Punctuation +'\n' Text + +'\t\t\t' Text +'fgoto' Name +' ' Text +'rlscan' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +"'%%'" Literal.String.Single +' ' Text.Whitespace +'{' Punctuation +'\n\t\t\t' Text +'write' Name +'(' Punctuation +' ' Text +'"' Literal.String +'<section>' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +' ' Text +')' Punctuation +';' Punctuation +' \n\t\t\t' Text +'single_line' Name +' ' Text +'=' Operator +' ' Text +'true' Name.Builtin +';' Punctuation +' \n\t\t\t' Text +'fgoto' Name +' ' Text +'rlscan' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'default' Name.Variable +' ' Text.Whitespace +'{' Punctuation +' \n\t\t\t' Text +'escapeXML' Name +'(' Punctuation +' ' Text +'*' Operator +'ts' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t\t' Text +'}' Punctuation +';' Punctuation +'\n\n\t\t' Text.Whitespace +'# EOF.' Comment +'\n\t\t' Text.Whitespace +'EOF' Name.Variable +';' Punctuation +'\n\t' Text.Whitespace +'*' Operator +'|' Operator +';' Punctuation +'\n' Text.Whitespace + +'}%%' Punctuation +'\n\n' Text + +'%%' Punctuation +' ' Text.Whitespace +'write' Keyword +' ' Text.Whitespace +'data' Name.Variable +' ' Text.Whitespace +'nofinal' Name.Variable +';' Punctuation +'\n' Text + +'\n' Text + +'void' Keyword.Type +' ' Text +'test' Name.Function +'(' Punctuation +' ' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'data' Name +' ' Text +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'std' Name +':' Operator +':' Operator +'ios' Name +':' Operator +':' Operator +'sync_with_stdio' Name +'(' Punctuation +'false' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'\t' Text +'int' Keyword.Type +' ' Text +'cs' Name +',' Punctuation +' ' Text +'act' Name +';' Punctuation +'\n' Text + +'\t' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'ts' Name +',' Punctuation +' ' Text +'*' Operator +'te' Name +';' Punctuation +'\n' Text + +'\t' Text +'int' Keyword.Type +' ' Text +'stack' Name +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +',' Punctuation +' ' Text +'top' Name +';' Punctuation +'\n' Text + +'\n' Text + +'\t' Text +'bool' Keyword.Type +' ' Text +'single_line' Name +' ' Text +'=' Operator +' ' Text +'false' Name.Builtin +';' Punctuation +'\n' Text + +'\t' Text +'int' Keyword.Type +' ' Text +'inline_depth' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +'\n' Text + +'\t' Text +'%%' Punctuation +' ' Text.Whitespace +'write' Keyword +' ' Text.Whitespace +'init' Name.Variable +';' Punctuation +'\n' Text + +'\n\t' Text +'/* Read in a block. */' Comment.Multiline +'\n' Text + +'\t' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'p' Name +' ' Text +'=' Operator +' ' Text +'data' Name +';' Punctuation +'\n' Text + +'\t' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'pe' Name +' ' Text +'=' Operator +' ' Text +'data' Name +' ' Text +'+' Operator +' ' Text +'strlen' Name +'(' Punctuation +' ' Text +'data' Name +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'\t' Text +'const' Keyword +' ' Text +'char' Keyword.Type +' ' Text +'*' Operator +'eof' Name +' ' Text +'=' Operator +' ' Text +'pe' Name +';' Punctuation +'\n' Text + +'\t' Text +'%%' Punctuation +' ' Text.Whitespace +'write' Keyword +' ' Text.Whitespace +'exec' Name.Variable +';' Punctuation +'\n' Text + +'\n\t' Text +'if' Keyword +' ' Text +'(' Punctuation +' ' Text +'cs' Name +' ' Text +'=' Operator +'=' Operator +' ' Text +'RagelScan_error' Name +' ' Text +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +'\t\t' Text +'/* Machine failed before finding a token. */' Comment.Multiline +'\n' Text + +'\t\t' Text +'cerr' Name +' ' Text +'<' Operator +'<' Operator +' ' Text +'"' Literal.String +'PARSE ERROR' Literal.String +'"' Literal.String +' ' Text +'<' Operator +'<' Operator +' ' Text +'endl' Name +';' Punctuation +'\n' Text + +'\t\t' Text +'exit' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +'\t' Text +'}' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'#' Comment.Preproc +'define BUFSIZE 2048' Comment.Preproc +'\n' Comment.Preproc + +'\n' Text + +'int' Keyword.Type +' ' Text +'main' Name.Function +'(' Punctuation +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +'\t' Text +'std' Name +':' Operator +':' Operator +'ios' Name +':' Operator +':' Operator +'sync_with_stdio' Name +'(' Punctuation +'false' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'\t' Text +'test' Name +'(' Punctuation +'"' Literal.String +"hi %%{ /'}%%'/ { /*{*/ {} } + '" Literal.String +'\\\\' Literal.String.Escape +"'' }%%there" Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'\t' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text |
