Ejemplo n.º 1
0
        public override void EnterSymbol([NotNull] ClojureObrParser.SymbolContext context)
        {
            //
            //Console.WriteLine("Вошел в символ");
            //Console.WriteLine($"Символ - {context.GetText()}");

            //Add keyword check

            string symbText = context.GetText();

            if (!currentSymbolTable.Symbols.ContainsKey(symbText) &&
                ExprSymTypes.Get(context.Parent) != SymType.Key &&
                ExprSymTypes.Get(context.Parent) != SymType.Fun)
            {
                throw new Exception($"Symbol does not defined, {context.Start.Line}: {context.Start.Column}");
            }
            //
        }
Ejemplo n.º 2
0
        public override void ExitSymbol([NotNull] ClojureObrParser.SymbolContext context)
        {
            //
            //Console.WriteLine("Вышел из символа");
            string symbText = context.GetText();
            Symbol symb     = null;

            if (ExprSymTypes.Get(context.Parent) != SymType.Key &&
                ExprSymTypes.Get(context.Parent) != SymType.Fun)
            {
                symb = currentSymbolTable.Symbols[symbText];
                ExprSymTypes.Put(context, SymType.Sym);
                ExprSyms.Put(context, symb);
            }
            //

            SymNode node = new SymNode(symbText, symb?.Value);

            TypedNodes.Put(context, node);
        }