The "tokstart" and "tokend" variables were changed to "ts" and "te".
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Fri, 11 Jan 2008 20:18:27 +0000 (20:18 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Fri, 11 Jan 2008 20:18:27 +0000 (20:18 +0000)
git-svn-id: http://svn.complang.org/ragel/trunk@399 052ea7fc-9027-0410-9066-f65837a77df0

24 files changed:
ChangeLog
examples/clang.rl
examples/cppscan.rl
examples/pullscan.rl
examples/rlscan.rl
ragel/parsedata.cpp
rlgen-cd/fsmcodegen.cpp
rlgen-java/javacodegen.cpp
rlgen-ruby/ruby-codegen.cpp
test/clang4.rl
test/cppscan2.rl
test/cppscan3.rl
test/cppscan5.rl
test/cppscan6.rl
test/gotocallret2.rl
test/langtrans_c.txl
test/langtrans_d.txl
test/langtrans_java.txl
test/langtrans_ruby.txl
test/lmgoto.rl
test/patact.rl
test/rlscan.rl
test/scan1.rl
test/tokstart1.rl

index 86cf5f7..08a424c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -64,6 +64,7 @@ Ragel 6.0 - TBR
  -Made a number of fixes that eliminate warnings in GCC 4.3. Mostly concern
   the now depreciate automatic conversion of string contsants to "char*" type.
   Other fixes include adding parenthesis around && within ||.
+ -The "tokstart" and "tokend" variables were changed to "ts" and "te".
 
 Ragel 5.25 - Dec 24, 2007
 =========================
index 09b109e..60491e5 100644 (file)
        # Symbols. Upon entering clear the buffer. On all transitions
        # buffer a character. Upon leaving dump the symbol.
        ( punct - [_'"] ) {
-               printf( "symbol(%i): %c\n", curline, tokstart[0] );
+               printf( "symbol(%i): %c\n", curline, ts[0] );
        };
 
        # Identifier. Upon entering clear the buffer. On all transitions
        # buffer a character. Upon leaving, dump the identifier.
        alpha_u alnum_u* {
                printf( "ident(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -41,7 +41,7 @@
        sliteralChar = [^'\\] | newline | ( '\\' . any_count_line );
        '\'' . sliteralChar* . '\'' {
                printf( "single_lit(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -49,7 +49,7 @@
        dliteralChar = [^"\\] | newline | ( '\\' any_count_line );
        '"' . dliteralChar* . '"' {
                printf( "double_lit(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -67,7 +67,7 @@
        # The float machine overlaps with int and it will do it.
        digit+ {
                printf( "int(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -75,7 +75,7 @@
        # characters on every trans and dump the float upon leaving.
        digit+ '.' digit+ {
                printf( "float(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -83,7 +83,7 @@
        # on every trans and dump the hex on leaving transitions.
        '0x' xdigit+ {
                printf( "hex(%i): ", curline );
-               fwrite( tokstart, 1, tokend-tokstart, stdout );
+               fwrite( ts, 1, te-ts, stdout );
                printf("\n");
        };
 
@@ -98,7 +98,7 @@ void scanner()
 {
        static char buf[BUFSIZE];
        int cs, act, have = 0, curline = 1;
-       char *tokstart, *tokend = 0;
+       char *ts, *te = 0;
        int done = 0;
 
        %% write init;
@@ -130,14 +130,14 @@ void scanner()
                        break;
                }
 
-               if ( tokstart == 0 )
+               if ( ts == 0 )
                        have = 0;
                else {
                        /* There is a prefix to preserve, shift it over. */
-                       have = pe - tokstart;
-                       memmove( buf, tokstart, have );
-                       tokend = buf + (tokend-tokstart);
-                       tokstart = buf;
+                       have = pe - ts;
+                       memmove( buf, ts, have );
+                       te = buf + (te-ts);
+                       ts = buf;
                }
        }
 }
index d1a3130..1ead5aa 100644 (file)
@@ -52,7 +52,7 @@ using std::endl;
 
 static char buf[BUFSIZE];
 static int line = 1, col = 1;
-static char *tokstart, *tokend;
+static char *ts, *te;
 static int act, have = 0;
 static int cs;
 
@@ -121,7 +121,7 @@ static int cs;
        '...' {token( TK_DotDotDot );};
 
        # Single char symbols.
-       ( punct - [_"'] ) {token( tokstart[0] );};
+       ( punct - [_"'] ) {token( ts[0] );};
 
        # Comments and whitespace.
        '/*' { fgoto c_comment; };
@@ -133,8 +133,8 @@ static int cs;
 
 void token( int tok )
 {
-       char *data = tokstart;
-       int len = tokend - tokstart;
+       char *data = ts;
+       int len = te - ts;
 
        cout << '<' << tok << "> ";
        cout.write( data, len );
@@ -193,14 +193,14 @@ int main()
                }
 
                /* Now set up the prefix. */
-               if ( tokstart == 0 )
+               if ( ts == 0 )
                        have = 0;
                else {
                        /* There is data that needs to be shifted over. */
-                       have = pe - tokstart;
-                       memmove( buf, tokstart, have );
-                       tokend -= (tokstart-buf);
-                       tokstart = buf;
+                       have = pe - ts;
+                       memmove( buf, ts, have );
+                       te -= (ts-buf);
+                       ts = buf;
                }
        }
 
index bac4609..f009dd2 100644 (file)
@@ -10,8 +10,8 @@ typedef struct _Scanner {
     int act;
     int have;
     int curline;
-    char *tokstart;
-    char *tokend;
+    char *ts;
+    char *te;
     char *p;
     char *pe;
     char *eof;
@@ -48,7 +48,7 @@ void scan_init( Scanner *s, FILE *file )
 #define TK_Number 131
 #define TK_String 132
 
-#define ret_tok( _tok ) token = _tok; s->data = s->tokstart
+#define ret_tok( _tok ) token = _tok; s->data = s->ts
 
 int scan( Scanner *s )
 {
@@ -59,15 +59,15 @@ int scan( Scanner *s )
                if ( s->p == s->pe ) {
                        printf("scanner: need more data\n");
 
-                       if ( s->tokstart == 0 )
+                       if ( s->ts == 0 )
                                s->have = 0;
                        else {
                                /* There is data that needs to be shifted over. */
                                printf("scanner: buffer broken mid token\n");
-                               s->have = s->pe - s->tokstart;
-                               memmove( s->buf, s->tokstart, s->have );
-                               s->tokend -= (s->tokstart-s->buf);
-                               s->tokstart = s->buf;
+                               s->have = s->pe - s->ts;
+                               memmove( s->buf, s->ts, s->have );
+                               s->te -= (s->ts-s->buf);
+                               s->ts = s->buf;
                        }
 
                        s->p = s->buf + s->have;
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;
index 3fae998..225dbea 100644 (file)
@@ -889,9 +889,9 @@ bool ParseData::setVariable( char *var, InlineList *inlineList )
                stackExpr = inlineList;
        else if ( strcmp( var, "act" ) == 0 )
                actExpr = inlineList;
-       else if ( strcmp( var, "tokstart" ) == 0 )
+       else if ( strcmp( var, "ts" ) == 0 )
                tokstartExpr = inlineList;
-       else if ( strcmp( var, "tokend" ) == 0 )
+       else if ( strcmp( var, "te" ) == 0 )
                tokendExpr = inlineList;
        else
                set = false;
@@ -991,13 +991,13 @@ void ParseData::initLongestMatchData()
                /* The setTokStart action sets tokstart. */
                InlineList *il5 = new InlineList;
                il5->append( new InlineItem( InputLoc(), InlineItem::LmSetTokStart ) );
-               setTokStart = newAction( "tokstart", il5 );
+               setTokStart = newAction( "ts", il5 );
                setTokStart->isLmAction = true;
 
                /* The setTokEnd action sets tokend. */
                InlineList *il3 = new InlineList;
                il3->append( new InlineItem( InputLoc(), InlineItem::LmSetTokEnd ) );
-               setTokEnd = newAction( "tokend", il3 );
+               setTokEnd = newAction( "te", il3 );
                setTokEnd->isLmAction = true;
 
                /* The action will also need an ordering: ahead of all user action
index 317c08d..78faafb 100644 (file)
@@ -241,7 +241,7 @@ string FsmCodeGen::TOKSTART()
 {
        ostringstream ret;
        if ( tokstartExpr == 0 )
-               ret << ACCESS() + "tokstart";
+               ret << ACCESS() + "ts";
        else {
                ret << "(";
                INLINE_LIST( ret, tokstartExpr, 0, false );
@@ -254,7 +254,7 @@ string FsmCodeGen::TOKEND()
 {
        ostringstream ret;
        if ( tokendExpr == 0 )
-               ret << ACCESS() + "tokend";
+               ret << ACCESS() + "te";
        else {
                ret << "(";
                INLINE_LIST( ret, tokendExpr, 0, false );
index 5da38a2..e70a7b7 100644 (file)
@@ -1385,7 +1385,7 @@ string JavaTabCodeGen::TOKSTART()
 {
        ostringstream ret;
        if ( tokstartExpr == 0 )
-               ret << ACCESS() + "tokstart";
+               ret << ACCESS() + "ts";
        else {
                ret << "(";
                INLINE_LIST( ret, tokstartExpr, 0, false );
@@ -1398,7 +1398,7 @@ string JavaTabCodeGen::TOKEND()
 {
        ostringstream ret;
        if ( tokendExpr == 0 )
-               ret << ACCESS() + "tokend";
+               ret << ACCESS() + "te";
        else {
                ret << "(";
                INLINE_LIST( ret, tokendExpr, 0, false );
index 29146cb..94c9568 100644 (file)
@@ -196,7 +196,7 @@ string RubyCodeGen::TOKSTART()
 {
        ostringstream ret;
        if ( tokstartExpr == 0 )
-               ret << ACCESS() + "tokstart";
+               ret << ACCESS() + "ts";
        else {
                //ret << "(";
                INLINE_LIST( ret, tokstartExpr, 0, false );
@@ -209,7 +209,7 @@ string RubyCodeGen::TOKEND()
 {
        ostringstream ret;
        if ( tokendExpr == 0 )
-               ret << ACCESS() + "tokend";
+               ret << ACCESS() + "te";
        else {
                //ret << "(";
                INLINE_LIST( ret, tokendExpr, 0, false );
index 9644b8e..c3bb399 100644 (file)
@@ -3,8 +3,6 @@
  * @NEEDS_EOF: yes
  */
 
-ptr tokstart;
-ptr tokend;
 char array[32];
 int pos;
 int line;
index d719830..a609bba 100644 (file)
@@ -41,7 +41,7 @@ using namespace std;
 
 int tok;
 char buf[BUFSIZE];
-const char *tokstart, *tokend;
+const char *ts, *te;
 void token( const char *data, int len );
 bool discard = false;
 
@@ -155,19 +155,19 @@ struct Scanner
                        }
                        else {
                                /* Send the token. */
-                               token( tokstart, tokend - tokstart + 1 );
+                               token( ts, te - ts + 1 );
 
                                /* Restart right after the token. */
-                               rst_data = tokend+1;
+                               rst_data = te+1;
                        }
 
-                       tokstart = 0;
+                       ts = 0;
                        fexec rst_data;
                        fgoto main;
                }
        }
 
-       main := tokens >{tokstart=fpc;} @{tokend=fpc;} $!onError;
+       main := tokens >{ts=fpc;} @{te=fpc;} $!onError;
 }%%
 
 %% write data;
@@ -175,8 +175,8 @@ struct Scanner
 int Scanner::init( )
 {
        tok = 0;
-       tokstart = 0;
-       tokend = 0;
+       ts = 0;
+       te = 0;
 
        %% write init;
        return 1;
@@ -222,7 +222,7 @@ void test( const char * data )
        scanner.execute( data, strlen(data) );
        scanner.finish();
        if ( tok != 0 && tok != TK_Comment && tok != TK_Whitespace )
-               token( tokstart, tokend - tokstart + 1 );
+               token( ts, te - ts + 1 );
 }
 
 int main()
index 15a80ac..67b8624 100644 (file)
@@ -44,7 +44,7 @@ char buf[BUFSIZE];
 struct Scanner
 {
        int cs, act;
-       const char *tokstart, *tokend;
+       const char *ts, *te;
 
        void token( int tok );
        void run();
@@ -114,7 +114,7 @@ struct Scanner
        '...' => { token( TK_DotDotDot );};
 
        # Single char symbols.
-       ( punct - [_"'] ) => { token( tokstart[0] );};
+       ( punct - [_"'] ) => { token( ts[0] );};
 
        action comment {
                token( TK_Comment );
@@ -160,8 +160,8 @@ int Scanner::finish( )
 
 void Scanner::token( int tok )
 {
-       const char *data = tokstart;
-       int len = tokend - tokstart;
+       const char *data = ts;
+       int len = te - ts;
        cout << "<" << tok << "> ";
        for ( int i = 0; i < len; i++ )
                cout << data[i];
index b7378f1..057725a 100644 (file)
@@ -43,12 +43,12 @@ static const int TK_Comment = 242;
 class Scanner 
 {
        int cs, act;
-       char *tokstart, tokend;
+       char *ts, te;
 
        void token( int tok )
        {
-               char *data = tokstart;
-               int len = tokend - tokstart;
+               char *data = ts;
+               int len = te - ts;
                printf( "<%i> ", tok );
                for ( int i = 0; i < len; i++ )
                        printf( "%c", data[i] );
@@ -116,7 +116,7 @@ class Scanner
        '...' => { token( TK_DotDotDot );};
 
        # Single char symbols.
-       ( punct - [_"'] ) => { token( tokstart[0] );};
+       ( punct - [_"'] ) => { token( ts[0] );};
 
        action comment {
                token( TK_Comment );
index f699ca0..ed82fe6 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * @LANG: indep
  *
- * const char *data = tokstart;
- * int len = tokend - tokstart;
+ * const char *data = ts;
+ * int len = te - ts;
  * cout << "<" << tok << "> ";
  * for ( int i = 0; i < len; i++ )
  *     cout << data[i];
  * cout << '\n';
  */
-ptr tokstart;
-ptr tokend;
+ptr ts;
+ptr te;
 int act;
 int token;
 %%
index 4a3bc0e..5b4f740 100644 (file)
@@ -5,8 +5,8 @@
 char comm;
 int top;
 int stack[32];
-ptr tokstart;
-ptr tokend;
+ptr ts;
+ptr te;
 int act;
 int val;
 %%
index b292c41..e80e508 100644 (file)
@@ -126,7 +126,7 @@ function alTermToC
        replace [al_term]
                'first_token_char
        by
-               'tokstart '[0]
+               'ts '[0]
 end function
 
 function alExprExtendToC AlExprExtend [repeat al_expr_extend]
@@ -232,7 +232,7 @@ function alStmtToC4d AlStmt [action_lang_stmt]
                'print_token ';
        replace [repeat c_lang_stmt]
        by
-               'fwrite '( 'tokstart ', '1 ', 'tokend '- 'tokstart ', 'stdout ');
+               'fwrite '( 'ts ', '1 ', 'te '- 'ts ', 'stdout ');
 end function
 
 function alStmtToC5 AlStmt [action_lang_stmt]
index bff4a08..3d8b8a7 100644 (file)
@@ -99,7 +99,7 @@ function alTermToD
        replace [al_term]
                'first_token_char
        by
-               'tokstart '[0]
+               'ts '[0]
 end function
 
 function alExprExtendToD AlExprExtend [repeat al_expr_extend]
@@ -206,7 +206,7 @@ function alStmtToD4d AlStmt [action_lang_stmt]
                'print_token ';
        replace [repeat d_lang_stmt]
        by
-               '_s '= tokstart '[0..(tokend-tokstart)] ';
+               '_s '= ts '[0..(te-ts)] ';
                'writef '( '"%s" ', '_s ') ';
 end function
 
index f13bcd5..8016ab2 100644 (file)
@@ -136,7 +136,7 @@ function alTermToJava
        replace [al_term]
                'first_token_char
        by
-               'data '[tokstart]
+               'data '[ts]
 end function
 
 function alExprExtendToJava AlExprExtend [repeat al_expr_extend]
@@ -243,7 +243,7 @@ function alStmtToJava4d AlStmt [action_lang_stmt]
                'print_token ';
        replace [repeat java_lang_stmt]
        by
-               '_s '= 'new 'String '( 'data ', 'tokstart ', 'tokend '- 'tokstart ') ';
+               '_s '= 'new 'String '( 'data ', 'ts ', 'te '- 'ts ') ';
                'System '. 'out '. 'print '( '_s ');
 end function
 
index 6acfb5a..265426f 100644 (file)
@@ -144,7 +144,7 @@ function alTermToRuby
        replace [al_term]
                'first_token_char
        by
-               'data '[tokstart]
+               'data '[ts]
 end function
 
 function alExprExtendToRuby AlExprExtend [repeat al_expr_extend]
@@ -258,7 +258,7 @@ function alStmtToRuby4d AlStmt [action_lang_stmt]
                'print_token ';
        replace [repeat ruby_lang_stmt]
        by
-               '_m = 'data '[tokstart..tokend-1] ';
+               '_m = 'data '[ts..te-1] ';
                'print '( '_m '. 'pack '( '"c*" ') ') ';
 end function
 
index 48f3fb7..e8e82a8 100644 (file)
@@ -40,7 +40,7 @@ using namespace std;
 struct Scanner
 {
        int cs, act;
-       const char *tokstart, *tokend;
+       const char *ts, *te;
        bool isCxx;
 
        void token( int tok );
@@ -57,8 +57,8 @@ struct Scanner
                        if ( ! isCxx )
                                fgoto main;
                        else {
-                               cout << "comm char: " << tokstart[0] << endl;
-                               cout << "comm char: " << tokstart[1] << endl;
+                               cout << "comm char: " << ts[0] << endl;
+                               cout << "comm char: " << ts[1] << endl;
                        }
                };
 
@@ -66,11 +66,11 @@ struct Scanner
                        if ( isCxx )
                                fgoto main;
                        else
-                               cout << "comm char: " << tokstart[0] << endl;
+                               cout << "comm char: " << ts[0] << endl;
                };
                
                any {
-                       cout << "comm char: " << tokstart[0] << endl;
+                       cout << "comm char: " << ts[0] << endl;
                };
        *|;
        
@@ -124,7 +124,7 @@ struct Scanner
        '...' { token( TK_DotDotDot );};
 
        # Single char symbols.
-       ( punct - [_"'] ) { token( tokstart[0] );};
+       ( punct - [_"'] ) { token( ts[0] );};
 
        # Comments and whitespace. Handle these outside of the machine so that se
        # don't end up buffering the comments.
@@ -140,8 +140,8 @@ struct Scanner
 
 void Scanner::token( int tok )
 {
-       const char *data = tokstart;
-       int len = tokend - tokstart;
+       const char *data = ts;
+       int len = te - ts;
        cout << "<" << tok << "> ";
        if ( data != 0 ) {
                for ( int i = 0; i < len; i++ )
index d523fa5..864299d 100644 (file)
@@ -5,8 +5,8 @@
 char comm;
 int top;
 int stack[32];
-ptr tokstart;
-ptr tokend;
+ptr ts;
+ptr te;
 int act;
 int val;
 %%
@@ -20,11 +20,11 @@ int val;
        *|;
 
        exec_test := |* 
-               [a-z]+ => { prints "word (w/lbh)\n"; fexec tokend-1; fgoto other; };
+               [a-z]+ => { prints "word (w/lbh)\n"; fexec te-1; fgoto other; };
                [a-z]+ ' foil' => { prints "word (c/lbh)\n"; };
                [\n ] => { prints "space\n"; };
                '22' => { prints "num (w/switch)\n"; };
-               [0-9]+ => { prints "num (w/switch)\n"; fexec tokend-1; fgoto other;};
+               [0-9]+ => { prints "num (w/switch)\n"; fexec te-1; fgoto other;};
                [0-9]+ ' foil' => {prints "num (c/switch)\n"; };
                '!';# => { prints "immdiate\n"; fgoto exec_test; };
        *|;
index 1bc683b..448b979 100644 (file)
@@ -81,7 +81,7 @@ inline void write( const char *data, int len )
                @{ fret; };
 
        action emit {
-               escapeXML( tokstart, tokend-tokstart );
+               escapeXML( ts, te-ts );
        }
 
        #
@@ -113,7 +113,7 @@ inline void write( const char *data, int len )
                        }
                };
 
-               default => { escapeXML( *tokstart ); };
+               default => { escapeXML( *ts ); };
        *|;
 
        #
@@ -138,21 +138,21 @@ inline void write( const 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" );
                };
 
@@ -162,28 +162,28 @@ inline void write( const 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" );
                };
 
@@ -213,7 +213,7 @@ inline void write( const char *data, int len )
                '"' ( [^"\\] | /\\./ )* '"' => emit;
 
                '/*' {
-                       escapeXML( tokstart, tokend-tokstart );
+                       escapeXML( ts, te-ts );
                        fcall c_comment;
                };
 
@@ -232,7 +232,7 @@ inline void write( const char *data, int len )
                };
 
                default { 
-                       escapeXML( *tokstart );
+                       escapeXML( *ts );
                };
 
                # EOF.
@@ -247,7 +247,7 @@ void test( const char *data )
        std::ios::sync_with_stdio(false);
 
        int cs, act;
-       const char *tokstart, *tokend;
+       const char *ts, *te;
        int stack[1], top;
 
        bool single_line = false;
index 5b32e89..df0971a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @LANG: indep
  */
-ptr tokstart;
-ptr tokend;
+ptr ts;
+ptr te;
 int act;
 int token;
 %%
@@ -14,34 +14,34 @@ int token;
        main := |*
                'a' => { 
                        prints "on last     ";
-                       if ( p+1 == tokend )
+                       if ( p+1 == te )
                                prints "yes";
                        prints "\n";
                };
 
                'b'+ => {
                        prints "on next     ";
-                       if ( p+1 == tokend )
+                       if ( p+1 == te )
                                prints "yes";
                        prints "\n";
                };
 
                'c1' 'dxxx'? => {
                        prints "on lag      ";
-                       if ( p+1 == tokend )
+                       if ( p+1 == te )
                                prints "yes";
                        prints "\n";
                };
 
                'd1' => {
                        prints "lm switch1  ";
-                       if ( p+1 == tokend )
+                       if ( p+1 == te )
                                prints "yes";
                        prints "\n";
                };
                'd2' => {
                        prints "lm switch2  ";
-                       if ( p+1 == tokend )
+                       if ( p+1 == te )
                                prints "yes";
                        prints "\n";
                };
index 52e9544..e8c1552 100644 (file)
@@ -11,7 +11,7 @@ extern char buf[];
 struct Scanner
 {
        int cs, act;
-       char *tokstart, *tokend;
+       char *ts, *te;
 
        // Initialize the machine. Invokes any init statement blocks. Returns 0
        // if the machine begins in a non-accepting state and 1 if the machine
@@ -40,7 +40,7 @@ struct Scanner
                        cout << (int)fc;
                else
                        cout << fc;
-               cout << " tokstart = " << ( tokstart == 0 ? -1 : tokstart-buf ) << endl;
+               cout << " ts = " << ( ts == 0 ? -1 : ts-buf ) << endl;
        } 
        action from_act {
                cout << "from: fc = ";
@@ -48,7 +48,7 @@ struct Scanner
                        cout << (int)fc;
                else
                        cout << fc;
-               cout << " tokstart = " << ( tokstart == 0 ? -1 : tokstart-buf ) << endl;
+               cout << " ts = " << ( ts == 0 ? -1 : ts-buf ) << endl;
        }
 
        c_comm := ( any* $0 '*/' @1 @{ fgoto main; } ) $~to_act $*from_act;
@@ -150,89 +150,89 @@ int main()
 }
 
 #ifdef _____OUTPUT_____
-from: fc = a tokstart = 0
-to:   fc = a tokstart = 0
-from: fc =   tokstart = 0
-to:   fc = a tokstart = -1
-from: fc =   tokstart = 1
-to:   fc =   tokstart = 1
-from: fc = b tokstart = 1
-to:   fc =   tokstart = -1
-from: fc = b tokstart = 2
-to:   fc = b tokstart = 2
-from: fc =   tokstart = 2
-to:   fc = b tokstart = -1
-from: fc =   tokstart = 3
-to:   fc =   tokstart = 3
-from: fc = 0 tokstart = 3
-to:   fc =   tokstart = -1
-from: fc = 0 tokstart = 4
-to:   fc = 0 tokstart = 4
-from: fc = . tokstart = 4
-to:   fc = . tokstart = 4
-from: fc = 9 tokstart = 4
-to:   fc = 9 tokstart = 4
-from: fc = 8 tokstart = 4
-to:   fc = 8 tokstart = 4
-from: fc =   tokstart = 4
-to:   fc = 8 tokstart = -1
-from: fc =   tokstart = 8
-to:   fc =   tokstart = 8
-from: fc = / tokstart = 8
-to:   fc =   tokstart = -1
-from: fc = / tokstart = 9
-to:   fc = / tokstart = 9
-from: fc = * tokstart = 9
-to:   fc = * tokstart = -1
+from: fc = a ts = 0
+to:   fc = a ts = 0
+from: fc =   ts = 0
+to:   fc = a ts = -1
+from: fc =   ts = 1
+to:   fc =   ts = 1
+from: fc = b ts = 1
+to:   fc =   ts = -1
+from: fc = b ts = 2
+to:   fc = b ts = 2
+from: fc =   ts = 2
+to:   fc = b ts = -1
+from: fc =   ts = 3
+to:   fc =   ts = 3
+from: fc = 0 ts = 3
+to:   fc =   ts = -1
+from: fc = 0 ts = 4
+to:   fc = 0 ts = 4
+from: fc = . ts = 4
+to:   fc = . ts = 4
+from: fc = 9 ts = 4
+to:   fc = 9 ts = 4
+from: fc = 8 ts = 4
+to:   fc = 8 ts = 4
+from: fc =   ts = 4
+to:   fc = 8 ts = -1
+from: fc =   ts = 8
+to:   fc =   ts = 8
+from: fc = / ts = 8
+to:   fc =   ts = -1
+from: fc = / ts = 9
+to:   fc = / ts = 9
+from: fc = * ts = 9
+to:   fc = * ts = -1
 from: fc = 
- tokstart = -1
+ ts = -1
 to:   fc = 
- tokstart = -1
-from: fc = 9 tokstart = -1
-to:   fc = 9 tokstart = -1
-from: fc =   tokstart = -1
-to:   fc =   tokstart = -1
-from: fc = * tokstart = -1
-to:   fc = * tokstart = -1
-from: fc = / tokstart = -1
-to:   fc = / tokstart = -1
-from: fc = 39 tokstart = 16
-to:   fc = 39 tokstart = 16
-from: fc = \ tokstart = 16
-to:   fc = \ tokstart = 16
-from: fc = 39 tokstart = 16
-to:   fc = 39 tokstart = 16
-from: fc = 39 tokstart = 16
-to:   fc = 39 tokstart = -1
-from: fc = / tokstart = 20
-to:   fc = / tokstart = 20
-from: fc = / tokstart = 20
-to:   fc = / tokstart = -1
-from: fc = h tokstart = -1
-to:   fc = h tokstart = -1
-from: fc = i tokstart = -1
-to:   fc = i tokstart = -1
+ ts = -1
+from: fc = 9 ts = -1
+to:   fc = 9 ts = -1
+from: fc =   ts = -1
+to:   fc =   ts = -1
+from: fc = * ts = -1
+to:   fc = * ts = -1
+from: fc = / ts = -1
+to:   fc = / ts = -1
+from: fc = 39 ts = 16
+to:   fc = 39 ts = 16
+from: fc = \ ts = 16
+to:   fc = \ ts = 16
+from: fc = 39 ts = 16
+to:   fc = 39 ts = 16
+from: fc = 39 ts = 16
+to:   fc = 39 ts = -1
+from: fc = / ts = 20
+to:   fc = / ts = 20
+from: fc = / ts = 20
+to:   fc = / ts = -1
+from: fc = h ts = -1
+to:   fc = h ts = -1
+from: fc = i ts = -1
+to:   fc = i ts = -1
 from: fc = 
- tokstart = -1
+ ts = -1
 to:   fc = 
- tokstart = -1
-from: fc = t tokstart = 25
-to:   fc = t tokstart = 25
-from: fc = h tokstart = 25
-to:   fc = h tokstart = 25
-from: fc = e tokstart = 25
-to:   fc = e tokstart = 25
-from: fc = r tokstart = 25
-to:   fc = r tokstart = 25
-from: fc = e tokstart = 25
-to:   fc = e tokstart = 25
+ ts = -1
+from: fc = t ts = 25
+to:   fc = t ts = 25
+from: fc = h ts = 25
+to:   fc = h ts = 25
+from: fc = e ts = 25
+to:   fc = e ts = 25
+from: fc = r ts = 25
+to:   fc = r ts = 25
+from: fc = e ts = 25
+to:   fc = e ts = 25
 from: fc = 
- tokstart = 25
-to:   fc = e tokstart = -1
+ ts = 25
+to:   fc = e ts = -1
 from: fc = 
- tokstart = 30
+ ts = 30
 to:   fc = 
- tokstart = 30
+ ts = 30
 to:   fc = 
- tokstart = -1
+ ts = -1
 #endif