Esempio n. 1
0
        /// <summary>
        /// Create CodeNode representing hierarchy sequence.
        /// </summary>
        /// <returns>CodeNode created according to layout.</returns>
        public CodeNode HierarchyLayout()
        {
            var node = new CodeNode(_lexer.Move(), NodeTypes.hierarchy);

            if (_checkToken("("))//function call
            {
                node.NodeType = NodeTypes.call;
                resolveBracket(() => { node.AddArgument(_nextTree()); return(false); }, "(", ",", ")", "Error in call, expected '{0}'"); //on fail throw exception
                node.EndingToken = _lexer.Current.Previous;                                                                              //aby ukazoval na zavorku
            }

            if (_shiftToken("."))
            {
                var child = HierarchyLayout();
                if (child == null)
                {
                    throw CSharpSyntax.ParsingException(_lexer.Current, "Expected identifier after '.'");
                }
                node.Child = child;
            }

            if (_checkToken("["))
            {
                var indexer = IndexerLayout();
                node.SetIndexer(indexer);
            }

            if (_checkToken("{")) //initializer
            {
                var seq = InitializerLayout();
                node.SetSubsequence(seq);
            }

            return(node);
        }