Возможность восстановления состояния при инициализации парсера
This commit is contained in:
parent
aeb74635f9
commit
c112dbea7f
@ -16,8 +16,9 @@ public final class Parser {
|
||||
|
||||
private static Parser instance;
|
||||
|
||||
public static Parser parse(List<Token> tokens) {
|
||||
instance = new Parser(tokens);
|
||||
public static Parser parse(List<Token> tokens, SaveInfo save) {
|
||||
if (save == null) instance = new Parser(tokens);
|
||||
else instance = new Parser(tokens, save);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -42,9 +43,18 @@ public final class Parser {
|
||||
private boolean hasEndMenu, hasEndIf;
|
||||
|
||||
public Parser(List<Token> tokens) {
|
||||
this(tokens, 0);
|
||||
}
|
||||
|
||||
public Parser(List<Token> tokens, SaveInfo info) {
|
||||
this(tokens, info.getPosition());
|
||||
Variables.setVariables(info.getVariables());
|
||||
}
|
||||
|
||||
private Parser(List<Token> tokens, int position) {
|
||||
this.tokens = tokens;
|
||||
tokensCount = tokens.size();
|
||||
position = 0;
|
||||
this.position = position;
|
||||
labels = new HashMap<String, Integer>();
|
||||
hasEndMenu = false;
|
||||
hasEndIf = false;
|
||||
|
@ -94,7 +94,7 @@ public final class ViewActivity extends Activity implements TouchGesture.OnTouch
|
||||
finish();
|
||||
}
|
||||
|
||||
Parser.parse(Lexer.tokenize( IOUtil.readContents(stream) ));
|
||||
Parser.parse(Lexer.tokenize( IOUtil.readContents(stream) ), save);
|
||||
Parser.getInstance().next();
|
||||
stream = null;
|
||||
} catch (Exception ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user