/** * Create a new instance of {@link ParseState} which is an independent snapshot * of this instance. */ public ParseState snapshot() { return new ParseState(this); }
/** * Create a new instance of {@link ParseState} which is an independent snapshot * of this instance. */ public ParseState snapshot() { return new ParseState(this); }
/** * Create a new instance of {@link ParseState} which is an independent snapshot * of this instance. */ public ParseState snapshot() { return new ParseState(this); }
@Test public void testSnapshot() throws Exception { MockEntry entry = new MockEntry(); ParseState original = new ParseState(); original.push(entry); ParseState snapshot = original.snapshot(); original.push(new MockEntry()); assertEquals("Snapshot should not have been modified.", entry, snapshot.peek()); }
@Test public void testSimple() throws Exception { MockEntry entry = new MockEntry(); ParseState parseState = new ParseState(); parseState.push(entry); assertEquals("Incorrect peek value.", entry, parseState.peek()); parseState.pop(); assertNull("Should get null on peek()", parseState.peek()); }
@Test public void testNesting() throws Exception { MockEntry one = new MockEntry(); MockEntry two = new MockEntry(); MockEntry three = new MockEntry(); ParseState parseState = new ParseState(); parseState.push(one); assertEquals(one, parseState.peek()); parseState.push(two); assertEquals(two, parseState.peek()); parseState.push(three); assertEquals(three, parseState.peek()); parseState.pop(); assertEquals(two, parseState.peek()); parseState.pop(); assertEquals(one, parseState.peek()); }
/** * Create a new instance of {@link ParseState} which is an independent snapshot * of this instance. */ public ParseState snapshot() { return new ParseState(this); }
public BlueprintParser(ParseState parseState, Collection<String> usedNames) { this.parseState = (parseState != null ? parseState : new ParseState()); this.usedNames = (usedNames != null ? usedNames : new LinkedHashSet<String>()); }
private final ParseState parseState = new ParseState();