Antlr4.Automata.LexerATNFactory.LexerCommand C# (CSharp) Method

LexerCommand() public method

public LexerCommand ( GrammarAST ID ) : Handle
ID Antlr4.Tool.Ast.GrammarAST
return Handle
        public override Handle LexerCommand(GrammarAST ID)
        {
            ILexerAction lexerAction = CreateLexerAction(ID, null);
            if (lexerAction != null)
            {
                return Action(ID, lexerAction);
            }

            if (codegenTemplates == null)
            {
                // suppress reporting a single missing template when the target couldn't be loaded
                return Epsilon(ID);
            }

            // fall back to standard action generation for the command
            Template cmdST = codegenTemplates.GetInstanceOf("Lexer" +
                    CharSupport.Capitalize(ID.Text) +
                    "Command");
            if (cmdST == null)
            {
                g.tool.errMgr.GrammarError(ErrorType.INVALID_LEXER_COMMAND, g.fileName, ID.Token, ID.Text);
                return Epsilon(ID);
            }

            if (cmdST.impl.FormalArguments != null && cmdST.impl.FormalArguments.Any(x => x.Name == "arg"))
            {
                g.tool.errMgr.GrammarError(ErrorType.MISSING_LEXER_COMMAND_ARGUMENT, g.fileName, ID.Token, ID.Text);
                return Epsilon(ID);
            }

            return Action(cmdST.Render());
        }