/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.incubator.util;

import java.util.List;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @since !__version__!
 * @version !__version__!
 */
public class Grammar {

	public sealed interface Symbol {
		String name();
	}

	public static record Terminal(String name) implements Symbol {
	}

	public static record NonTerminal(String name) implements Symbol {
	}

	public static final class Rule {
		private NonTerminal start;
		private List<Symbol> alternatives;
	}

	private NonTerminal start;
	private List<NonTerminal> nonTerminals;
	private List<Terminal> terminals;
	private List<Rule> rules;


	public static Grammar parse(final String bnf) {

		return null;
	}

}

@@ -948,16 +948,22 @@
 %0Apublic 
+final 
 class Gr
@@ -1184,79 +1184,240 @@
 tic 
-final class Rule %7B%0A%09%09private NonTerminal start;%0A%09%09private List%3CSymbol%3E 
+record Expression(List%3CSymbol%3E symbols) %7B%0A%09%09public Expression %7B%0A%09%09%09symbols = List.copyOf(symbols);%0A%09%09%7D%0A%09%7D%0A%0A%09public static record Rule(NonTerminal start, List%3CExpression%3E alternatives) %7B%0A%09%09public Rule %7B%0A%09%09%09alternatives = List.copyOf(
 alte
@@ -1424,23 +1424,30 @@
 rnatives
+)
 ;%0A
+%09%09%7D%0A
 %09%7D%0A%0A%09
+//
 private 
@@ -1466,16 +1466,18 @@
 start;%0A%09
+//
 private 
@@ -1501,32 +1501,34 @@
  nonTerminals;%0A%09
+//
 private List%3CTer
@@ -1545,16 +1545,17 @@
 minals;%0A
+%0A
 %09private
@@ -1551,24 +1551,30 @@
 ;%0A%0A%09private 
+final 
 List%3CRule%3E r
@@ -1580,16 +1580,145 @@
 rules;%0A%0A
+%09public Grammar(final List%3CRule%3E rules) %7B%0A%09%09this.rules = List.copyOf(rules);%0A%09%7D%0A%0A%09public List%3CRule%3E rules() %7B%0A%09%09return rules;%0A%09%7D%0A
 %0A%09public

Implement Grammar class.