public static List<Symbol> scan(String input, boolean includeCommentsAndWhitespace) throws Exception {
        GdlScanner scanner = new GdlScanner(new StringReader(input));
        scanner.setIncludeCommentsAndWhitespace(includeCommentsAndWhitespace);
        List<Symbol> tokens = new ArrayList<Symbol>();
        while (true) {
            Symbol token = scanner.next_token();
            tokens.add(token);
            if (token.sym == Symbols.EOF) {
                break;
            }
        }
        return tokens;
    }
public static List < Symbol > scan ( String input , boolean includeCommentsAndWhitespace ) throws Exception { GdlScanner scanner = new GdlScanner ( new StringReader ( input ) ) ; scanner . setIncludeCommentsAndWhitespace ( includeCommentsAndWhitespace ) ; List < Symbol > tokens = new ArrayList < Symbol > ( ) ; while ( true ) { Symbol token = scanner . next_token ( ) ; tokens . add ( token ) ; if ( token . sym == Symbols . EOF ) { break ; } } return tokens ; }
Note: The output is not thread-safe.