public void setText(String text) throws InvalidTokenException {
this.text = text;
// Determine if it is optional
optional = Pattern.matches("^\\[.*\\]$", text);
if (Pattern.matches("^\\[.*$", text))
throw new InvalidTokenException("Bad optional token: missing ']' char at end.");
if (Pattern.matches("^.*\\]$", text))
throw new InvalidTokenException("Bad optional token: missing '[' char at begin.");
// Fill text_without_optional
if (this.isOptional())
text_without_optional = text.substring(1, text.length()-2);
else
text_without_optional = text;