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

LexerCallCommand() public method

public LexerCallCommand ( GrammarAST ID, GrammarAST arg ) : Handle
ID Antlr4.Tool.Ast.GrammarAST
arg Antlr4.Tool.Ast.GrammarAST
return Handle
        public override Handle LexerCallCommand(GrammarAST ID, GrammarAST arg)
        {
            ILexerAction lexerAction = CreateLexerAction(ID, arg);
            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.UNWANTED_LEXER_COMMAND_ARGUMENT, g.fileName, ID.Token, ID.Text);
                return Epsilon(ID);
            }

            cmdST.Add("arg", arg.Text);
            cmdST.Add("grammar", arg.g);
            return Action(cmdST.Render());
        }