/// <summary> /// Check correctness of resolve identifier. /// Throw exception if result isn't term tree. /// </summary> /// <param name="node">Root node of result</param> /// <exception cref="CannotResolveIdentifierException">Throw if trnslation tree contains non-term nodes</exception> public void CheckResult(ISyntacticNode node) => node.Rewrite(new SyntaxRewriter( nd => !((node as TermSyntacticNode)?.Term is IResolvedTerm), (nd, ch) => { throw new TranslateException(); }));
/// <summary> /// Check correctness of translation result. /// Throw exception if result isn't term tree. /// </summary> /// <param name="node">Root node of result</param> public void CheckResult(ISyntacticNode node) => node.Rewrite(new SyntaxRewriter( nd => !(nd is TermSyntacticNode), (nd, ch) => { throw new TranslateException(); }));
/// <summary> /// Resolve constant and function in translated sysntactic tree /// </summary> /// <param name="node">Root of translated tree</param> /// <returns>Resolving tree</returns> public ISyntacticNode Resolve(ISyntacticNode node) => node.Rewrite(Rules);
/// <summary> /// Translate syntax tree using rules /// </summary> /// <param name="node">Root node</param> /// <returns>Rewritten root node</returns> public ISyntacticNode Translate(ISyntacticNode node) => node.Rewrite(Rules);