Line directives need to use the fileName stored in the InputLoc stuctures from
[external/ragel.git] / examples / rlscan.rl
index 18cad56..d4d4bf9 100644 (file)
@@ -77,7 +77,7 @@ inline void write( char *data, int len )
                @{ fret; };
 
        action emit {
-               escapeXML( tokstart, tokend-tokstart );
+               escapeXML( ts, te-ts );
        }
 
        #
@@ -109,7 +109,7 @@ inline void write( char *data, int len )
                        }
                };
 
-               default => { escapeXML( *tokstart ); };
+               default => { escapeXML( *ts ); };
        *|;
 
        #
@@ -134,21 +134,21 @@ inline void write( char *data, int len )
                # Word
                word {
                        write( "<word>" );
-                       write( tokstart, tokend-tokstart );
+                       write( ts, te-ts );
                        write( "</word>\n" );
                };
 
                # Decimal integer.
                integer {
                        write( "<int>" );
-                       write( tokstart, tokend-tokstart );
+                       write( ts, te-ts );
                        write( "</int>\n" );
                };
 
                # Hexidecimal integer.
                hex {
                        write( "<hex>" );
-                       write( tokstart, tokend-tokstart );
+                       write( ts, te-ts );
                        write( "</hex>\n" );
                };
 
@@ -158,28 +158,28 @@ inline void write( char *data, int len )
                # Single literal string.
                "'" ( [^'\\] | /\\./ )* "'" {
                        write( "<single_lit>" );
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        write( "</single_lit>\n" );
                };
 
                # Double literal string.
                '"' ( [^"\\] | /\\./ )* '"' {
                        write( "<double_lit>" );
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        write( "</double_lit>\n" );
                };
 
                # Or literal.
                '[' ( [^\]\\] | /\\./ )* ']' {
                        write( "<or_lit>" );
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        write( "</or_lit>\n" );
                };
 
                # Regex Literal.
                '/' ( [^/\\] | /\\./ ) * '/' {
                        write( "<re_lit>" );
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        write( "</re_lit>\n" );
                };
 
@@ -209,7 +209,7 @@ inline void write( char *data, int len )
                '"' ( [^"\\] | /\\./ )* '"' => emit;
 
                '/*' {
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        fcall c_comment;
                };
 
@@ -228,7 +228,7 @@ inline void write( char *data, int len )
                };
 
                default { 
-                       escapeXML( *tokstart );
+                       escapeXML( *ts );
                };
 
                # EOF.
@@ -245,7 +245,7 @@ int main()
        std::ios::sync_with_stdio(false);
 
        int cs, act;
-       char *tokstart, *tokend;
+       char *ts, *te;
        int stack[1], top;
 
        static char inbuf[BUFSIZE];
@@ -286,14 +286,14 @@ int main()
                        exit(1);
                }
 
-               if ( tokstart == 0 )
+               if ( ts == 0 )
                        have = 0;
                else {
                        /* There is a prefix to preserve, shift it over. */
-                       have = pe - tokstart;
-                       memmove( inbuf, tokstart, have );
-                       tokend = inbuf + (tokend-tokstart);
-                       tokstart = inbuf;
+                       have = pe - ts;
+                       memmove( inbuf, ts, have );
+                       te = inbuf + (te-ts);
+                       ts = inbuf;
                }
        }
        return 0;