- and fix some bug : max is within range ( perhaps not as many as those added ...) - quick hack in CharProvider to skip spaces ... ( bad it applies to strings too ...)
41 lines
733 B
Java
41 lines
733 B
Java
package org.artisanlogiciel.lua;
|
|
|
|
public class CharProvider {
|
|
|
|
String input;
|
|
int current;
|
|
int last;
|
|
|
|
public CharProvider(String input) {
|
|
this.input = input;
|
|
current = 0;
|
|
}
|
|
|
|
public char getNextchar()
|
|
{
|
|
int i = current;
|
|
int max = input.length();
|
|
if ( max > current) {
|
|
char c = 0;
|
|
last = current;
|
|
while ( ( max > i ) && ( c = input.charAt(i) ) == ' ' )
|
|
{
|
|
i++;
|
|
}
|
|
current = i + 1;
|
|
return c;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public void pushBackChar(char c)
|
|
{
|
|
System.out.print('*');
|
|
current = last;
|
|
}
|
|
|
|
}
|