Exemple #1
0
        private bool functionCall()
        {
            int line     = _line;
            int position = _position;

            if (!accept("("))
            {
                return(false);
            }

            List <Node> parameterList;

            if (accept(")"))
            {
                parameterList = new List <Node>();
            }
            else
            {
                parameterList = expressionList();
                expect(")");
            }

            FunctionCallNode node = new FunctionCallNode(null, parameterList, SymbolTable.CurrentScope, _filename, line, position);

            _stack.Push(node);

            return(true);
        }
Exemple #2
0
        private void component()
        {
            /// component = prefixOperator? ( number | identifier | '"' [^"] '"' | '(' expression ')' ) postFixOperator?
            PrefixOperatorNode prefix = null;

            if (prefixOperator())
            {
                prefix = (PrefixOperatorNode)_stack.Pop();
            }

            if (number() || characterString())
            {
                if (prefix != null)
                {
                    prefix.Target = _stack.Pop();
                    _stack.Push(prefix);
                }
                return;
            }

            else if (identifier())
            {
                if (functionCall())
                {
                    FunctionCallNode node           = (FunctionCallNode)_stack.Pop();
                    IdentifierNode   identifierNode = (IdentifierNode)_stack.Pop();
                    node.Identifier = identifierNode.Identifier;
                    _stack.Push(node);
                }
                if (prefix != null)
                {
                    prefix.Target = _stack.Pop();
                    _stack.Push(prefix);
                }
                return;
            }

            expect("(");
            expression();
            expect(")");
        }