protected BnfiTermConversion(Type domainType, BnfTerm bnfTerm, ValueIntroducer <object> valueIntroducer, ValueConverter <object, object> inverseValueConverterForUnparse, object defaultValue, bool isOptionalValue, string name, bool astForChild) : base(domainType, name) { this.IsContractible = true; this.bnfTerm = bnfTerm; this.isOptionalValue = isOptionalValue; this.defaultValue = defaultValue; if (!astForChild) { bnfTerm.SetFlag(TermFlags.NoAstNode); } this.RuleRawWithMove = isOptionalValue ? GrammarHelper.PreferShiftHere() + bnfTerm | Irony.Parsing.Grammar.CurrentGrammar.Empty : bnfTerm.ToBnfExpression(); this.AstConfig.NodeCreator = (context, parseTreeNode) => { try { parseTreeNode.AstNode = GrammarHelper.ValueToAstNode(valueIntroducer(context, new ParseTreeNodeWithoutAst(parseTreeNode)), context, parseTreeNode); } catch (AstException e) { context.AddMessage(AstException.ErrorLevel, parseTreeNode.Span.Location, e.Message); } catch (FatalAstException e) { context.AddMessage(FatalAstException.ErrorLevel, parseTreeNode.Span.Location, e.Message); // although it will be abandoned anyway e.Location = parseTreeNode.Span.Location; throw; // handle in MultiParser } }; this.inverseValueConverterForUnparse = inverseValueConverterForUnparse; }