public override void VisitTerminal([ValidatedNotNull] ITerminalNode node) { node.ValidateNotNull(nameof(node)); if (ActiveNode is null) { throw new InvalidOperationException("ActiveNode is null!"); } ActiveNode.Add(new XElement("Terminal", new XAttribute("Value", node.GetText( )))); }
public override void EnterUnaryOpExpression([ValidatedNotNull] KaleidoscopeParser.UnaryOpExpressionContext context) { context.ValidateNotNull(nameof(context)); if (ActiveNode is null) { throw new InvalidOperationException("ActiveNode is null!"); } ActiveNode.Add(new XAttribute("Op", context.Op)); }
private void Push(XElement element) { if (ActiveNode == null) { Document.Add(element); } else { ActiveNode.Add(element); } ActiveNode = element; }
public override void ExitEveryRule([NotNull] ParserRuleContext context) { base.ExitEveryRule(context); ActiveNode.Add(new XAttribute("Text", context.GetSourceText(Recognizer))); ActiveNode.Add(new XAttribute("RuleIndex", context.RuleIndex)); ActiveNode.Add(new XAttribute("SourceInterval", context.SourceInterval.ToString( ))); if (context.exception != null) { ActiveNode.Add(new XAttribute("Exception", context.exception)); } Pop( ); }
public override void ExitEveryRule([NotNull] ParserRuleContext context) { base.ExitEveryRule(context); var span = context.GetCharInterval( ); var charStream = (( ITokenStream )Recognizer.InputStream).TokenSource.InputStream; ActiveNode.Add(new XAttribute("Text", charStream.GetText(span))); ActiveNode.Add(new XAttribute("RuleIndex", context.RuleIndex)); ActiveNode.Add(new XAttribute("SourceInterval", context.SourceInterval.ToString( ))); if (context.exception != null) { ActiveNode.Add(new XAttribute("Exception", context.exception)); } Pop( ); }
public override void ExitEveryRule([ValidatedNotNull] ParserRuleContext context) { context.ValidateNotNull(nameof(context)); base.ExitEveryRule(context); if (ActiveNode is null) { throw new InvalidOperationException("ActiveNode is null!"); } ActiveNode.Add(new XAttribute("Text", context.GetSourceText(Recognizer))); ActiveNode.Add(new XAttribute("RuleIndex", context.RuleIndex)); ActiveNode.Add(new XAttribute("SourceInterval", context.SourceInterval.ToString( ))); if (context.exception != null) { ActiveNode.Add(new XAttribute("Exception", context.exception)); } Pop( ); }
public override void VisitTerminal([NotNull] ITerminalNode node) { ActiveNode.Add(new XElement("Terminal", new XAttribute("Value", node.GetText( )))); }
public override void EnterUnaryOpExpression([NotNull] KaleidoscopeParser.UnaryOpExpressionContext context) { ActiveNode.Add(new XAttribute("Op", context.Op)); }
public override void VisitTerminal([NotNull] ITerminalNode node) { string nodeName = KaleidoscopeLexer.DefaultVocabulary.GetDisplayName(node.Symbol.Type); ActiveNode.Add(new XElement("Terminal", new XAttribute("Value", node.GetText( )))); }
public override void EnterIdentifier([NotNull] KaleidoscopeParser.IdentifierContext context) { ActiveNode.Add(new XAttribute("Name", context.Name)); }