public Start getStartSymbol(Nonterminal nt) { Start start = Start.from(nt); if (definitions.keySet().contains(start)) return start; Rule startRule; if (layout != null) startRule = Rule.withHead(start) .setLabel("Start") .addSymbol(layout) .addSymbol(nt) .addSymbol(layout) .setRecursion(Recursion.NON_REC) .setAssociativity(Associativity.UNDEFINED) .setPrecedence(-1) .setPrecedenceLevel(PrecedenceLevel.getFirstAndDone()) .build(); else startRule = Rule.withHead(start) .addSymbol(nt) .setRecursion(Recursion.NON_REC) .setAssociativity(Associativity.UNDEFINED) .setPrecedence(-1) .setPrecedenceLevel(PrecedenceLevel.getFirstAndDone()) .build(); definitions.put(start, CollectionsUtil.list(startRule)); rules.add(startRule); return start; }
public Builder addRule(Rule rule) { List<Rule> rules = definitions.get(rule.getHead()); if (rules == null) { rules = new ArrayList<>(); definitions.put(rule.getHead(), rules); } rules.add(rule); this.rules.add(rule); return this; }
public Builder addExceptPattern(ExceptPattern pattern) { exceptPatterns.add(pattern); return this; }
public Builder addPrecedencePattern(PrecedencePattern pattern) { precedencePatterns.add(pattern); return this; }