NameWithModifier implements Cloneable { public static NameWithModifier parseNameAndModifier(ParseCtxt ctxt) { NameWithModifier n = new NameWithModifier(); ctxt.skipBlanks(); if (ctxt.isOnChar('(')) { ctxt.readChar('('); boolean done = false; do { Modifier.parse(ctxt, n); ctxt.skipBlanks(); switch (ctxt.currentChar()) { case ')': ctxt.readChar(')'); done = true; break; case ',': ctxt.readChar(','); break; default: throw new ParseException(ctxt, "Can't interpret character '" + ctxt.currentChar() + "' in modifier list."); } } while(!done); ctxt.skipBlanks(); } if (ctxt.readOptionalChar('#')) { n.setVariable(true); } n.name = ctxt.skipBlanksAndReadNameString(); if (n.name == null) { throw new ParseException(ctxt, "Missing name string."); } return n; }  Set<Modifier> getModifiers(); boolean isOptional(); boolean isVariable(); void setVariable(boolean variable); String getName(); String getAlias(); @Override NameWithModifier clone(); @Override String toString(); static NameWithModifier parseNameAndModifier(ParseCtxt ctxt);  }
@Test public void incompleteAsModifierErrorMessage() { try { NameWithModifier.parseNameAndModifier(new ParseCtxt("(as:")); fail("Incomplete expression should fail."); } catch (ParseException e) { assertEquals("Unable to parse '(as:':\n" + "Unexpected end of expression. One of the following characters expected: {',', ')'}\n" + "Parse position: 4", e.getMessage()); } }