Beispiel #1
0
        public override MacroToken VisitMArg(MacroParser.MArgContext context)
        {
            var argumentTokenList = new MacroListToken();

            foreach (var sourceExpressionContext in context.sourceExpression())
            {
                var token = Visit(sourceExpressionContext);
                HandleMacroListTokens(token, ref argumentTokenList);
            }
            return(argumentTokenList);
        }
Beispiel #2
0
        public override MacroToken VisitMacArgs(MacroParser.MacArgsContext context)
        {
            var arguments = new MacroListToken();

            foreach (var mArgContext in context.mArg())
            {
                var token = Visit(mArgContext);
                arguments.Tokens.Add(token);
            }
            return(arguments);
        }
Beispiel #3
0
        public override MacroToken VisitMacro_text(MacroParser.Macro_textContext context)
        {
            var tokens = new MacroListToken();

            foreach (var sourceTextContext in context.source_text())
            {
                var token = Visit(sourceTextContext);
                HandleMacroListTokens(token, ref tokens);
            }
            return(tokens);
        }
Beispiel #4
0
 private void HandleMacroListTokens(MacroToken token, ref MacroListToken collection)
 {
     if (token is MacroListToken)
     {
         collection.AddRangeTokens(((MacroListToken)token).Tokens);
     }
     else
     {
         collection.AddToken(token);
     }
 }
Beispiel #5
0
        public override MacroToken VisitMacroExpansion(MacroParser.MacroExpansionContext context)
        {
            var identifierName = context.IDENTIFIER().GetText();
            var arguments      = new MacroListToken();

            if (context.macArgs() != null)
            {
                arguments = Visit(context.macArgs()) as MacroListToken;
            }

            return(new FunctionToken(identifierName, arguments));
        }
Beispiel #6
0
        public override MacroToken VisitArguments(MacroParser.ArgumentsContext context)
        {
            var tokens = new MacroListToken();

            tokens.AddToken(new TextToken(context.LPAREN().GetText()));
            var argumentsTokens = Visit(context.args()) as MacroListToken;

            if (argumentsTokens != null)
            {
                tokens.AddRangeTokens(argumentsTokens.Tokens);
            }
            tokens.AddToken(new TextToken(context.RPAREN().GetText()));
            return(tokens);
        }
Beispiel #7
0
        public override MacroToken VisitArgs([NotNull] MacroParser.ArgsContext context)
        {
            var arguments = new MacroListToken();

            var firstArgument = Visit(context.mArg());

            HandleMacroListTokens(firstArgument, ref arguments);

            for (int i = 0; i < context.multipleArg().Length; i++)
            {
                var token = Visit(context.multipleArg(i));
                HandleMacroListTokens(token, ref arguments);
            }
            return(arguments);
        }
Beispiel #8
0
        public override MacroToken VisitMultipleArg([NotNull] MacroParser.MultipleArgContext context)
        {
            var tokens = new MacroListToken();

            if (context.WS(0) != null)
            {
                tokens.AddToken(new TextToken(context.WS(0).GetText()));
            }

            tokens.AddToken(new TextToken(context.COMMA().GetText()));

            var arg = Visit(context.mArg());

            HandleMacroListTokens(arg, ref tokens);

            if (context.WS(1) != null)
            {
                tokens.AddToken(new TextToken(context.WS(1).GetText()));
            }

            return(tokens);
        }