private void AddExtraStartProduction(SyntacticConfigurationFile config) { // Insert the S' -> S production to guarentee one /single/ rule in the start production. string start = config.GetRule(SyntacticConfigurationFile.RULE_START_KEY).ToString(); string realStart = start + START_PRIME; char prefix = config.GetRule(SyntacticConfigurationFile.RULE_PRODUCTION_PREFIX_KEY); var section = new ConfigSection( $"#{SyntacticConfigurationFile.SECTION_TAG_PRODUCTION} {realStart}", new string[] { $"{prefix}{start}" }, $"({nameof(ProductionTable)}.cs)", -1 ); ProcessSection(section, config); }
public Production(ConfigSection section, SyntacticConfigurationFile config) { this.Key = new Symbol(config.GetRule(SyntacticConfigurationFile.RULE_PRODUCTION_PREFIX_KEY) + section.Header.First(), config); this.Rules = new List <Rule>(); foreach (var entry in section.Header) { if (entry.StartsWith(SyntacticConfigurationFile.HEADER_EPSILON_PREFIX)) { string value = entry.Remove(0, SyntacticConfigurationFile.HEADER_EPSILON_PREFIX.Length); if (bool.TryParse(value, out bool canBeEpsilon)) { this.CanBeEpsilon = canBeEpsilon; } else { Log.WriteLineWarning($"Unable to determine if {this.Key.ID} production can be epsilon or not from: '{value}'."); } } } foreach (var line in section.Body.Where(line => !string.IsNullOrWhiteSpace(line))) { var rule = new Rule(this.Key, line, config); this.Rules.Add(rule); } }