core/src/main/java/org/jruby/lexer/LexingCommon.java
public int peekVariableName(int tSTRING_DVAR, int tSTRING_DBEG) throws IOException {
        int c = nextc(); // byte right after #
        int significant = -1;
        switch (c) {
            case '$': {  // we unread back to before the $ so next lex can read $foo
                int c2 = nextc();

                if (c2 == '-') {
                    int c3 = nextc();

                    if (c3 == EOF) {
                        pushback(c3); pushback(c2);
                        return 0;
                    }

                    significant = c3;                              // $-0 potentially
                    pushback(c3); pushback(c2);
                    break;
                } else if (isGlobalCharPunct(c2)) {          // $_ potentially
                    setValue("#" + (char) c2);

                    pushback(c2); pushback(c);
                    return tSTRING_DVAR;
                }

                significant = c2;                                  // $FOO potentially
                pushback(c2);
                break;
            }
            case '@': {  // we unread back to before the @ so next lex can read @foo
                int c2 = nextc();

                if (c2 == '@') {
                    int c3 = nextc();

                    if (c3 == EOF) {
                        pushback(c3); pushback(c2);
                        return 0;
                    }

                    significant = c3;                                // #@@foo potentially
                    pushback(c3); pushback(c2);
                    break;
                }

                significant = c2;                                    // #@foo potentially
                pushback(c2);
                break;
            }
            case '{':
                //setBraceNest(getBraceNest() + 1);
                setValue("#" + (char) c);
                commandStart = true;
                return tSTRING_DBEG;
            default:
                return 0;
        }

        // We found #@, #$, #@@ but we don't know what at this point (check for valid chars).
        if (significant != -1 && Character.isAlphabetic(significant) || significant == '_') {
            pushback(c);
            setValue("#" + significant);
            return tSTRING_DVAR;
        }

        return 0;
    }
// Return of 0 means failed to find anything.  Non-zero means return that from lexer.
Return of 0 means failed to find anything.  Non-zero means return that from lexer.
Return of 0 means failed to find anything . Non - zero means return that from lexer .
public int peekVariableName(int tSTRING_DVAR, int tSTRING_DBEG) throws IOException {
        int c = nextc(); 
        int significant = -1;
        switch (c) {
            case '$': {  
                int c2 = nextc();
                if (c2 == '-') {
                    int c3 = nextc();
                    if (c3 == EOF) {
                        pushback(c3); pushback(c2);
                        return 0;
                    }
                    significant = c3;                              
                    pushback(c3); pushback(c2);
                    break;
                } else if (isGlobalCharPunct(c2)) {          
                    setValue("#" + (char) c2);
                    pushback(c2); pushback(c);
                    return tSTRING_DVAR;
                }
                significant = c2;                                  
                pushback(c2);
                break;
            }
            case '@': {  
                int c2 = nextc();
                if (c2 == '@') {
                    int c3 = nextc();
                    if (c3 == EOF) {
                        pushback(c3); pushback(c2);
                        return 0;
                    }
                    significant = c3;                                
                    pushback(c3); pushback(c2);
                    break;
                }
                significant = c2;                                    
                pushback(c2);
                break;
            }
            case '{':
                setValue("#" + (char) c);
                commandStart = true;
                return tSTRING_DBEG;
            default:
                return 0;
        }
        if (significant != -1 && Character.isAlphabetic(significant) || significant == '_') {
            pushback(c);
            setValue("#" + significant);
            return tSTRING_DVAR;
        }
        return 0;
    }
public int peekVariableName ( int tSTRING_DVAR , int tSTRING_DBEG ) throws IOException { int c = nextc ( ) ; int significant = - 1 ; switch ( c ) { case '$' : { int c2 = nextc ( ) ; if ( c2 == '-' ) { int c3 = nextc ( ) ; if ( c3 == EOF ) { pushback ( c3 ) ; pushback ( c2 ) ; return 0 ; } significant = c3 ; pushback ( c3 ) ; pushback ( c2 ) ; break ; } else if ( isGlobalCharPunct ( c2 ) ) { setValue ( "#" + ( char ) c2 ) ; pushback ( c2 ) ; pushback ( c ) ; return tSTRING_DVAR ; } significant = c2 ; pushback ( c2 ) ; break ; } case '@' : { int c2 = nextc ( ) ; if ( c2 == '@' ) { int c3 = nextc ( ) ; if ( c3 == EOF ) { pushback ( c3 ) ; pushback ( c2 ) ; return 0 ; } significant = c3 ; pushback ( c3 ) ; pushback ( c2 ) ; break ; } significant = c2 ; pushback ( c2 ) ; break ; } case '{' : setValue ( "#" + ( char ) c ) ; commandStart = true ; return tSTRING_DBEG ; default : return 0 ; } if ( significant != - 1 && Character . isAlphabetic ( significant ) || significant == '_' ) { pushback ( c ) ; setValue ( "#" + significant ) ; return tSTRING_DVAR ; } return 0 ; }
Return of 0 means failed to find anything.
Return of 0 means failed to find anything .
// byte right after # // we unread back to before the $ so next lex can read $foo // $-0 potentially // $_ potentially // $FOO potentially // we unread back to before the @ so next lex can read @foo // #@@foo potentially // #@foo potentially //setBraceNest(getBraceNest() + 1); // We found #@, #$, #@@ but we don't know what at this point (check for valid chars).