Problem with syntax

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with syntax

vigna
I'm come into a situation in which the parser gives a spurious error:

        import it.unimi.dsi.fastutil.io.*;
        import it.unimi.dsi.webgraph.*;
        format = new java.text.DecimalFormat( "0.############" );
        sizes = BinIO.loadInts( "dest.sccsizes" );
        weakly0 = BinIO.loadInts( "dest-scc-sym-nl.scc" );
        graph = ImmutableGraph.loadOffline( "dest-scc" );
        n = ImmutableGraph.loadOffline( "dest" ).numNodes();
        ps = new PrintStream(new FileOutputStream("web-scc.dot"));
        ps.println( "digraph G { overlap=false; splines=true; root=n0; size=\"4,4\";" );
        numNodes = graph.numNodes();
        k = 0;
        max = 0;
        for( i = 0; i < weakly0.length; i++ ) if ( weakly0[ i ] == 0 && k++ < 100 ) max = i;

At this points, the parser chokes with

Error: Parser Error: Parse error at line 15, column 12.  Encountered: (

But if I turn the last line into a block:

        for( i = 0; i < weakly0.length; i++ ) {
           if ( weakly0[ i ] == 0 && k++ < 100 ) max = i;
        }

works like a charm.