private EbnfDefinition VisitDefinitionNode(IInternalTreeNode node) { EbnfBlock block = null; EbnfDefinition definition = null; for (int c = 0; c < node.Children.Count; c++) { var child = node.Children[c]; switch (child.NodeType) { case TreeNodeType.Internal: var internalNode = child as IInternalTreeNode; var symbolValue = internalNode.Symbol.Value; if (EbnfGrammar.Block == symbolValue) { block = VisitBlockNode(internalNode); } else if (EbnfGrammar.Definition == symbolValue) { definition = VisitDefinitionNode(internalNode); } break; } } if (definition != null) { return(new EbnfDefinitionConcatenation(block, definition)); } return(new EbnfDefinition(block)); }
public EbnfDefinitionConcatenation(EbnfBlock block, EbnfDefinition definition) : base(block) { Assert.IsNotNull(definition, nameof(definition)); Definition = definition; _hashCode = ComputeHashCode(); }
void Block(EbnfBlock block, GrammarModel grammarModel) { switch (block.NodeType) { case EbnfNodeType.EbnfBlockLexerRule: break; case EbnfNodeType.EbnfBlockRule: var blockRule = block as EbnfBlockRule; foreach (var production in Rule(blockRule.Rule)) grammarModel.Productions.Add(production); break; case EbnfNodeType.EbnfBlockSetting: break; } }
void Block(EbnfBlock block, GrammarModel grammarModel) { switch (block.NodeType) { case EbnfNodeType.EbnfBlockLexerRule: var blockLexerRule = block as EbnfBlockLexerRule; grammarModel.LexerRules.Add(LexerRule(blockLexerRule)); break; case EbnfNodeType.EbnfBlockRule: var blockRule = block as EbnfBlockRule; foreach (var production in Rule(blockRule.Rule)) { grammarModel.Productions.Add(production); } break; case EbnfNodeType.EbnfBlockSetting: var blockSetting = block as EbnfBlockSetting; switch (blockSetting.Setting.SettingIdentifier.Value) { case StartProductionSettingModel.SettingKey: grammarModel.StartSetting = StartSetting(blockSetting); break; case IgnoreSettingModel.SettingKey: var ignoreSettings = IgnoreSettings(blockSetting); for (var i = 0; i < ignoreSettings.Count; i++) { grammarModel.IgnoreSettings.Add(ignoreSettings[i]); } break; case TriviaSettingModel.SettingKey: var triviaSettings = TriviaSettings(blockSetting); for (var i = 0; i < triviaSettings.Count; i++) { grammarModel.TriviaSettings.Add(triviaSettings[i]); } break; } break; } }
void Block(EbnfBlock block, GrammarModel grammarModel) { switch (block.NodeType) { case EbnfNodeType.EbnfBlockLexerRule: break; case EbnfNodeType.EbnfBlockRule: var blockRule = block as EbnfBlockRule; foreach (var production in Rule(blockRule.Rule)) { grammarModel.Productions.Add(production); } break; case EbnfNodeType.EbnfBlockSetting: break; } }
public EbnfDefinition(EbnfBlock block) { Assert.IsNotNull(block, nameof(block)); Block = block; _hashCode = ComputeHashCode(); }