Ejemplo n.º 1
0
        public static IComparisonWithAdvance CreateVBScriptSub(
            Options options,
            string name = null,
            ILog log    = null)
        {
            // This requires more than one statement
            StatementList statementList = new StatementList(log);

            statementList.Name = name;

            // Function end: . , ", or whitespace
            CharComparison         isDot        = new CharComparison(log, options, '.');
            CharComparison         isQuote      = new CharComparison(log, options, '\"');
            CharDelegateComparison isWhitespace = new CharDelegateComparison(log, Char.IsWhiteSpace);
            OrComparison           funcNameEnd  = new OrComparison(log);

            funcNameEnd.Add(isDot);
            funcNameEnd.Add(isQuote);
            funcNameEnd.Add(isWhitespace);

            // Identifier but not including classes/namespaces
            var identifier = TokenComparison.CreateIdentifier(
                options,
                end: funcNameEnd,
                exclusion: null,
                name: null,
                log: log);

            // List of identifiers seperated by . which will include classes/namespaces
            var sub = TokenComparison.CreateListOfTokens(
                options,
                token: identifier,
                segment: isDot,
                name: null,
                log: null);

            statementList.Add(sub);

            return(statementList);
        }
Ejemplo n.º 2
0
        // E.g.
        // class.Function _ \r\n (p1, p2, class.Function2( _\r\n p1,p2 ) )
        // or
        // class.FunctionWithNoArgs
        // or
        // variableName
        public static IComparisonWithAdvance CreateVBScriptFunctionOrVar(
            Options options,
            IComparisonWithAdvance vbScriptConcatCommaOrWhitespaceOrEnd,
            IComparison vbScriptKeywords,
            string name = null,
            ILog log    = null)
        {
            if (options == null)
            {
                options = CreateVBScriptParserOptions(log);
            }
            if (vbScriptConcatCommaOrWhitespaceOrEnd == null)
            {
                vbScriptConcatCommaOrWhitespaceOrEnd = CreateVBScriptConcatCommaOrWhitespaceOrEnd(log);
            }
            if (vbScriptKeywords == null)
            {
                vbScriptKeywords = TokenComparison.VBScriptKeywords(log, options);
            }

            if (options.SkipLineWrapOperation == null)
            {
                Parser.ThrowParseError("The line wrap comparison has not been specified. This is mandatory.");
            }

            // This requires more than one statement
            StatementList statementList = new StatementList(log);

            statementList.Name = name;

            // Function
            CharComparison isDot             = new CharComparison(log, options, '.');
            OrComparison   isDotOrParenOrEnd = new OrComparison(log);

            isDotOrParenOrEnd.Add(isDot);
            isDotOrParenOrEnd.Add(vbScriptConcatCommaOrWhitespaceOrEnd);
            CharComparison openParen = new CharComparison(log, options, '(');

            isDotOrParenOrEnd.Add(openParen);
            var identifier = TokenComparison.CreateIdentifier(
                options,
                end: isDotOrParenOrEnd,
                exclusion: vbScriptKeywords,
                name: "identifier",
                log: log);

            // List of identifiers seperated by . which will include classes/namespaces
            var sub = TokenComparison.CreateListOfTokens(
                options,
                token: identifier,
                segment: isDot,
                name: "sub",
                log: log);

            statementList.Add(sub);

            // Skip whitespace
            {
                var skip = SkipWhitespace(log);
                skip.Name = "SkipWhitespace1";
                statementList.Add(skip);
            }

            // Skip the line wrap character
            statementList.Add(options.SkipLineWrapOperation);

            // Function parenthesis and arguments
            CharComparison close = new CharComparison(log, options, ')');

            // Either the end (and don't advance past it), or function argument list
            OrComparison isEndOrArgumentList = new OrComparison(log);

            isEndOrArgumentList.Name = "IsEndOrArgumentList";
            isEndOrArgumentList.Add(new CompareNoAdvance(log, vbScriptConcatCommaOrWhitespaceOrEnd));
            isEndOrArgumentList.Add(new NestedOpenCloseComparison(log, openParen, close));

            statementList.Add(isEndOrArgumentList);

            return(statementList);
        }