@Rule({"rangeList"}) protected RangeSet posRange(RangeSet rs) { return rs; } @Rule({"'\\^'", "rangeList"})
private void findRules(List<? extends ExecutableElement> methods) throws IOException { // rules defined in methods for (ExecutableElement method : methods) { List<Rule> ruleList = getRules(method); for (Rule rule : ruleList) { if (!rule.reducer().isEmpty()) { throw new IllegalArgumentException("reducer string "+rule.reducer()+"with method annotation"); } String name = rule.left(); if (name.isEmpty()) { name = method.getSimpleName().toString(); } try { addRule(method, name, rule.doc(), rule.value()); } catch (SyntaxErrorException ex) { throw new GrammarException(method.toString(), ex); } } } }
@Rule(left="expression", value="symbol") protected String plainSymbol(String symbol) { return symbol; }
@Rule(left="expression", value={"expression", "'"+CIRCLED_PLUS+"'"}) protected TypeMirror plainPlus(TypeMirror type) { return type; }
@Rule(left="expression", value={"expression", "'"+INVERTED_QUESTION_MARK+"'"}) protected TypeMirror plainOpt(TypeMirror type) { return type; }
@Rule("term") protected DEH expression(DEH term) { return term; } @Rule("factor")
@Rule("andExpression") protected DEH conditionalExpression(DEH andExpression) { return andExpression; } @Rule(value={"conditionalExpression", "OR", "andExpression"})
@Rule("conditionalAtom") protected DEH orExpression(DEH conditionalAtom) { return conditionalAtom; } @Rule(left="conditionalAtom", value={"LPAREN", "conditionalExpression", "RPAREN"})
@Rule("e") protected int east() { return 1; }
@Rule({"choices", "or", "part"}) protected List<String> choices(List<String> choices, String symbol) { choices.add(symbol); return choices; } @Rule({"'\\('", "seqs", "'\\)'"})
@Rule({"expression"}) protected List<TypeMirror> seqList(TypeMirror type) { List<TypeMirror> list = new ArrayList<>(); list.add(type); return list; } @Rule({"seqList", "comma", "expression"})
@Rule("expression") protected List<DEH> expressionList(DEH expression) { ArrayList<DEH> list = new ArrayList<>(); list.add(expression); return list; } @Rule({"expressionList", "COMMA", "expression"})
@Rule({"part"}) protected List<String> seqs(String symbol) { List<String> list = new ArrayList<>(); list.add(symbol); return list; } @Rule({"seqs", "part"})
@Rule("cell '[\r\n]+'") protected List<String> line(String cell) { List<String> list = new ArrayList<>(); list.add(cell); return list; }
@Rule("string") protected List<String> stringList(String str) { List<String> list = new ArrayList<>(); list.add(str); return list; }
@Rule("cell '[\r\n]+'") protected List<String> line(String cell) { List<String> list = new ArrayList<>(); list.add(cell); return list; }
@Rule({"'\\{'", "digit", "'\\,'", "digit", "'\\}'"}) protected Quantifier braceQ2(int min, int max) { return new Quantifier(min, max); } @Rules({