public override void EnterId([NotNull] ANTLRv4Parser.IdContext context) { if (context.Parent is ANTLRv4Parser.LexerCommandExprContext && context.Parent.Parent is ANTLRv4Parser.LexerCommandContext) { ANTLRv4Parser.LexerCommandContext lc = context.Parent.Parent as ANTLRv4Parser.LexerCommandContext; if (lc.GetChild(0)?.GetChild(0)?.GetText() == "pushMode") { TerminalNodeImpl term = context.GetChild(0) as TerminalNodeImpl; string id = term.GetText(); IList <ISymbol> sym_list = _pd.RootScope.LookupType(id); if (!sym_list.Any()) { ISymbol sym = new ModeSymbol(id, null); _pd.RootScope.define(ref sym); } List <CombinedScopeSymbol> ref_list = new List <CombinedScopeSymbol>(); foreach (ISymbol sym in sym_list) { CombinedScopeSymbol s = new RefSymbol(term.Symbol, sym); ref_list.Add(s); } _pd.Attributes[context] = ref_list; _pd.Attributes[context.GetChild(0)] = ref_list; } else if (lc.GetChild(0)?.GetChild(0)?.GetText() == "channel") { TerminalNodeImpl term = context.GetChild(0) as TerminalNodeImpl; string id = term.GetText(); IList <ISymbol> sym_list = _pd.RootScope.LookupType(id); if (!sym_list.Any()) { ISymbol sym = new ChannelSymbol(id, null); _pd.RootScope.define(ref sym); } List <CombinedScopeSymbol> ref_list = new List <CombinedScopeSymbol>(); foreach (ISymbol sym in sym_list) { CombinedScopeSymbol s = new RefSymbol(term.Symbol, sym); ref_list.Add(s); } _pd.Attributes[context] = ref_list; _pd.Attributes[context.GetChild(0)] = ref_list; } } }
/// <summary> /// Exit a parse tree produced by <see cref="ANTLRv4Parser.lexerCommand"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitLexerCommand([NotNull] ANTLRv4Parser.LexerCommandContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="ANTLRv4Parser.lexerCommand"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitLexerCommand([NotNull] ANTLRv4Parser.LexerCommandContext context) { return(VisitChildren(context)); }