@Override public RuleBasedScanner createItemParser() { List<IRule> rules = new ArrayList<IRule>(); for (Directive directive : Directive.values()) { if (!directive.isEndDirective()) { rules.add(new DirectiveRule(directive)); } } RuleBasedScanner result = new SyntaxModeListenerRuleBasedScanner(); result.setRules(rules.toArray(new IRule[rules.size()])); return result; }
public static Boolean isNestable(String cont, Directive type) throws ParseException { ParserUtils parser = new ParserUtils(cont); /* the directive name */ parser.match(type.getKeyword().toString()); parser.consumeWhiteSpace(); /* first variable name */ parser.consumeIdentifierOrStringLiteral(); parser.consumeWhiteSpace(); /* A directive end at this position means that this is a nesting form of assign */ return Boolean.valueOf( parser.isAtEndOfInput() || parser.matches(LexicalConstants.DIRECTIVE_END_AB[0], false) || parser.matches(LexicalConstants.DIRECTIVE_END_SB[0], false)); }